Handle errors in sh command

Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
This commit is contained in:
Ari Archer 2022-08-15 01:28:25 +03:00
parent 2dd258d0b0
commit 3d7fef228f
Signed by untrusted user who does not match committer: ari
GPG key ID: A50D5B4B599AF8A2

View file

@ -323,6 +323,12 @@ Executed query `{uncode(sql_query)}`
await self._send_message(m("No command specified", message))
return
output: str
try:
output = check_command_output(sh_command.split(" ")).decode()
except FileNotFoundError:
output = "Command not found"
await self._send_message(
m(
f"""
@ -330,7 +336,7 @@ Command: `{uncode(sh_command)}`
Output:
```
{uncode(check_command_output(sh_command.split(" ")).decode())}
{uncode(output)}
```
""",
message,