From 936040a6c88f279dae16d4a91e7ad43d890432e8 Mon Sep 17 00:00:00 2001 From: Phxntxm Date: Thu, 11 Jan 2018 11:32:41 -0600 Subject: [PATCH] Use check_output to stop blocking --- cogs/owner.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cogs/owner.py b/cogs/owner.py index e561604..5a89603 100644 --- a/cogs/owner.py +++ b/cogs/owner.py @@ -253,12 +253,9 @@ class Owner: @commands.check(utils.is_owner) async def bash(self, ctx, *, cmd: str): """Runs a bash command""" - proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) - output, error = proc.communicate() + output = subprocess.check_output("{}; exit 0".format(cmd), stderr=subprocess.STDOUT, shell=True) if output: - await ctx.send("STDOUT:\n```\n{}```".format(output.decode("utf-8", "ignore").strip())) - if error: - await ctx.send("STDERR:\n```\n{}```".format(error.decode("utf-8", "ignore").strip())) + await ctx.send("\n```\n{}```".format(output.decode("utf-8", "ignore").strip())) @commands.command() @commands.check(utils.is_owner)