Made sure the command sends raw evals as raw data. Resolves #816. This removes color completely from raw evals but they will still be present if using self.msg() in the evaluation (if doing so, this particular side effect still exists too though).

This commit is contained in:
Griatch 2015-10-11 19:08:32 +02:00
parent 1348fae5a0
commit 90c6ade56d

View file

@ -194,23 +194,23 @@ class CmdPy(MuxCommand):
t0 = timemeasure()
ret = eval(pycode_compiled, {}, available_vars)
t1 = timemeasure()
duration = " (%.4f ms)" % ((t1 - t0) * 1000)
duration = " (runtime ~ %.4f ms)" % ((t1 - t0) * 1000)
else:
ret = eval(pycode_compiled, {}, available_vars)
if mode == "eval":
ret = "{n<<< %s%s" % (str(ret), duration)
ret = "<<< %s%s" % (str(ret), duration)
else:
ret = "{n<<< Done.%s" % duration
ret = "<<< Done (use self.msg() if you want to catch output)%s" % duration
except Exception:
errlist = traceback.format_exc().split('\n')
if len(errlist) > 4:
errlist = errlist[4:]
ret = "\n".join("{n<<< %s" % line for line in errlist if line)
ret = "\n".join("<<< %s" % line for line in errlist if line)
try:
self.msg(ret, sessid=self.sessid)
self.msg(ret, sessid=self.sessid, raw=True)
except TypeError:
self.msg(ret)
self.msg(ret, raw=True)
# helper function. Kept outside so it can be imported and run