/usr/lib/python2.7/dist-packages/spur/results.py is in python-spur 0.3.15-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | from __future__ import unicode_literals
import sys
def result(return_code, allow_error, output, stderr_output):
result = ExecutionResult(return_code, output, stderr_output)
if return_code == 0 or allow_error:
return result
else:
raise result.to_error()
class ExecutionResult(object):
def __init__(self, return_code, output, stderr_output):
self.return_code = return_code
self.output = output
self.stderr_output = stderr_output
def to_error(self):
return RunProcessError(
self.return_code,
self.output,
self.stderr_output
)
class RunProcessError(RuntimeError):
def __init__(self, return_code, output, stderr_output):
message = "return code: {0}\noutput:{1}\nstderr output:{2}".format(
return_code, _render_output(output), _render_output(stderr_output))
super(type(self), self).__init__(message)
self.return_code = return_code
self.output = output
self.stderr_output = stderr_output
def _render_output(output):
if isinstance(output, unicode):
return "\n" + output
else:
result = repr(output)
if result.startswith("b"):
return " " + result
else:
return " b" + result
if sys.version_info[0] >= 3:
unicode = str
|