minor fixes with try catch

pull/16/head
Shrimadhav U K 2018-08-07 21:55:30 +05:30
parent 2a58f1aa25
commit 6b960a705b
2 changed files with 14 additions and 9 deletions

View File

@ -4,6 +4,8 @@
from telethon import events
import subprocess
from telethon.errors import MessageEmptyError
@borg.on(events.NewMessage(pattern=r"\.exec (.*)", outgoing=True))
async def _(event):
@ -15,7 +17,11 @@ async def _(event):
try:
t_response = subprocess.check_output(input_command, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as exc:
await event.edit("Status : FAIL", exc.returncode, exc.output)
await event.edit("process returned {}\n output: {}".format(exc.returncode, exc.output))
else:
x_reponse = t_response.decode("UTF-8")
await event.edit(x_reponse)
try:
await event.edit(x_reponse)
except MessageEmptyError as exc:
await event.edit("process did not return anything")

View File

@ -10,13 +10,6 @@ from datetime import datetime
current_date_time = "./DOWNLOADS/"
def progress(current, total):
percent = str((current / total) * 100)
await event.edit(
"Upload Progress: {}".format(percent)
)
@borg.on(events.NewMessage(pattern=r".download (.*)", outgoing=True))
async def _(event):
if event.fwd_from:
@ -50,6 +43,11 @@ async def _(event):
@borg.on(events.NewMessage(pattern=r".upload (.*)", outgoing=True))
async def _(event):
async def progress(current, total):
percent = str((current / total) * 100)
await event.edit(
"Upload Progress: {}".format(percent)
)
if event.fwd_from:
return
await event.edit("Processing ...")
@ -69,3 +67,4 @@ async def _(event):
await event.edit("Uploaded in {} seconds.".format(ms))
else:
await event.edit("404: File Not Found")