diff options
| author | 2019-06-15 18:45:51 -0700 | |
|---|---|---|
| committer | 2019-06-15 18:50:21 -0700 | |
| commit | 82be5b29c9e849aaf43b99a4ed3fd829289b12dc (patch) | |
| tree | 79a6abefb49151b177bc123d35fe3a8834f93785 | |
| parent | Snekbox: make output formatting more efficient (diff) | |
Snekbox: adjust for API change that merged stderr into stdout
| -rw-r--r-- | bot/cogs/snekbox.py | 10 | 
1 files changed, 3 insertions, 7 deletions
diff --git a/bot/cogs/snekbox.py b/bot/cogs/snekbox.py index 64e926257..fd30aebcb 100644 --- a/bot/cogs/snekbox.py +++ b/bot/cogs/snekbox.py @@ -22,11 +22,7 @@ CODE_TEMPLATE = """  venv_file = "/snekbox/.venv/bin/activate_this.py"  exec(open(venv_file).read(), dict(__file__=venv_file)) -import contextlib -import sys -  try: -    with contextlib.redirect_stderr(sys.stdout):  {CODE}  except Exception as e:      print(e) @@ -104,19 +100,19 @@ class Snekbox:                  f"stripping whitespace only:\n{code}"              ) -        code = textwrap.indent(code, "        ") +        code = textwrap.indent(code, "    ")          return CODE_TEMPLATE.replace("{CODE}", code)      @staticmethod      def get_results_message(results: dict) -> Tuple[str, str]:          """Return a user-friendly message and error corresponding to the process's return code.""" -        stderr, returncode = results["stderr"], results["returncode"] +        stdout, returncode = results["stdout"], results["returncode"]          msg = f"Your eval job has completed with return code {returncode}"          error = ""          if returncode is None:              msg = "Your eval job has failed" -            error = stderr.strip() +            error = stdout.strip()          elif returncode == 128 + Signals.SIGKILL:              msg = "Your eval job timed out or ran out of memory"          elif returncode == 255:  |