Commit fe95099c authored by Jonathan Michalon's avatar Jonathan Michalon

Enhance error message building from command outputs

Don't show empty outputs and decode bytes (so that things like newlines
are printed as such and not as litteral "\n").
parent 894ab63e
......@@ -65,8 +65,10 @@ class Check(object):
self.errmsg += "Operation timed out\n"
return False
if p.returncode != 0:
self.errmsg += "stdout: " + str(out) + '\n' + \
"stderr: " + str(err) + '\n'
if len(out) > 0:
self.errmsg += "stdout:\n" + out.decode() + '\n'
if len(err) > 0:
self.errmsg += "stderr:\n" + err.decode() + '\n'
if re.search(pattern, str(out), flags=re.M) is None:
self.errmsg += "Pattern not found in reply: '%s'\n" + \
"stdout: %s" % (pattern, out.decode())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment