MCPcopy Create free account
hub / github.com/apache/httpd / ExecResult

Class ExecResult

test/pyhttpd/result.py:6–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4
5
6class ExecResult:
7
8 def __init__(self, args: List[str], exit_code: int,
9 stdout: bytes, stderr: bytes = None,
10 stdout_as_list: List[bytes] = None,
11 duration: timedelta = None):
12 self._args = args
13 self._exit_code = exit_code
14 self._stdout = stdout if stdout is not None else b''
15 self._stderr = stderr if stderr is not None else b''
16 self._duration = duration if duration is not None else timedelta()
17 self._response = None
18 self._results = {}
19 self._assets = []
20 # noinspection PyBroadException
21 try:
22 if stdout_as_list is None:
23 out = self._stdout.decode()
24 else:
25 out = "[" + ','.join(stdout_as_list) + "]"
26 self._json_out = json.loads(out)
27 except:
28 self._json_out = None
29
30 def __repr__(self):
31 out = [
32 f"ExecResult[code={self.exit_code}, args={self._args}\n",
33 "----stdout---------------------------------------\n",
34 self._stdout.decode(),
35 "----stderr---------------------------------------\n",
36 self._stderr.decode()
37 ]
38 return ''.join(out)
39
40 @property
41 def exit_code(self) -> int:
42 return self._exit_code
43
44 @property
45 def args(self) -> List[str]:
46 return self._args
47
48 @property
49 def outraw(self) -> bytes:
50 return self._stdout
51
52 @property
53 def stdout(self) -> str:
54 return self._stdout.decode()
55
56 @property
57 def json(self) -> Optional[Dict]:
58 """Output as JSON dictionary or None if not parseable."""
59 return self._json_out
60
61 @property
62 def stderr(self) -> str:
63 return self._stderr.decode()

Callers 5

parse_responseMethod · 0.90
ws_runFunction · 0.90
_runMethod · 0.85
runMethod · 0.85
curl_parse_headerfileMethod · 0.85

Calls

no outgoing calls

Tested by 2

parse_responseMethod · 0.72
ws_runFunction · 0.72