Use check_output to stop blocking
This commit is contained in:
parent
0d3ec6f46f
commit
936040a6c8
|
@ -253,12 +253,9 @@ class Owner:
|
||||||
@commands.check(utils.is_owner)
|
@commands.check(utils.is_owner)
|
||||||
async def bash(self, ctx, *, cmd: str):
|
async def bash(self, ctx, *, cmd: str):
|
||||||
"""Runs a bash command"""
|
"""Runs a bash command"""
|
||||||
proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
output = subprocess.check_output("{}; exit 0".format(cmd), stderr=subprocess.STDOUT, shell=True)
|
||||||
output, error = proc.communicate()
|
|
||||||
if output:
|
if output:
|
||||||
await ctx.send("STDOUT:\n```\n{}```".format(output.decode("utf-8", "ignore").strip()))
|
await ctx.send("\n```\n{}```".format(output.decode("utf-8", "ignore").strip()))
|
||||||
if error:
|
|
||||||
await ctx.send("STDERR:\n```\n{}```".format(error.decode("utf-8", "ignore").strip()))
|
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@commands.check(utils.is_owner)
|
@commands.check(utils.is_owner)
|
||||||
|
|
Loading…
Reference in a new issue