fancy-subprocess 1.0__tar.gz → 1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fancy_subprocess-1.0 → fancy_subprocess-1.1}/PKG-INFO +1 -1
- {fancy_subprocess-1.0 → fancy_subprocess-1.1}/fancy_subprocess/__init__.py +9 -5
- {fancy_subprocess-1.0 → fancy_subprocess-1.1}/pyproject.toml +1 -1
- {fancy_subprocess-1.0 → fancy_subprocess-1.1}/.editorconfig +0 -0
- {fancy_subprocess-1.0 → fancy_subprocess-1.1}/.gitignore +0 -0
- {fancy_subprocess-1.0 → fancy_subprocess-1.1}/LICENSE +0 -0
- {fancy_subprocess-1.0 → fancy_subprocess-1.1}/README.md +0 -0
- {fancy_subprocess-1.0 → fancy_subprocess-1.1}/fancy_subprocess/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fancy_subprocess
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1
|
|
4
4
|
Summary: subprocess.run() with formatted output, detailed error messages and retry capabilities
|
|
5
5
|
Project-URL: Homepage, https://github.com/petamas/fancy-subprocess
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/petamas/fancy-subprocess/issues
|
|
@@ -99,12 +99,12 @@ class RunProcessResult:
|
|
|
99
99
|
`fancy_subprocess.run()` and similar functions return a `RunProcessResult` instance on success.
|
|
100
100
|
|
|
101
101
|
`RunProcessResult` has the following properties:
|
|
102
|
-
- `exit_code: int` - Exit code of the finished process. (On Windows, this is a signed `int32` value, i.e. in the range of
|
|
102
|
+
- `exit_code: int` - Exit code of the finished process. (On Windows, this is a signed `int32` value, i.e. in the range of [-2<sup>31</sup>, 2<sup>31</sup>-1].)
|
|
103
103
|
- `output: str` - Combination of the process's output on stdout and stderr.
|
|
104
104
|
"""
|
|
105
105
|
|
|
106
|
-
exit_code: int
|
|
107
|
-
output: str
|
|
106
|
+
exit_code: int = 0
|
|
107
|
+
output: str = ''
|
|
108
108
|
|
|
109
109
|
@dataclass(kw_only=True, frozen=True)
|
|
110
110
|
class RunProcessError(Exception):
|
|
@@ -128,7 +128,7 @@ class RunProcessError(Exception):
|
|
|
128
128
|
"""
|
|
129
129
|
|
|
130
130
|
cmd: Sequence[str | Path]
|
|
131
|
-
result: RunProcessResult | OSError
|
|
131
|
+
result: RunProcessResult | OSError = RunProcessResult()
|
|
132
132
|
|
|
133
133
|
@property
|
|
134
134
|
def completed(self) -> bool:
|
|
@@ -155,7 +155,8 @@ class RunProcessError(Exception):
|
|
|
155
155
|
else:
|
|
156
156
|
raise ValueError('...')
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
@property
|
|
159
|
+
def message(self) -> str:
|
|
159
160
|
if isinstance(self.result, RunProcessResult):
|
|
160
161
|
exit_code_str = _stringify_exit_code(self.exit_code)
|
|
161
162
|
if exit_code_str is not None:
|
|
@@ -166,6 +167,9 @@ class RunProcessError(Exception):
|
|
|
166
167
|
else:
|
|
167
168
|
return f'Exception {type(self.result).__name__} with message "{str(self.result)}" was raised while trying to run command: {_oslex_join(self.cmd)}'
|
|
168
169
|
|
|
170
|
+
def __str__(self) -> str:
|
|
171
|
+
return self.message
|
|
172
|
+
|
|
169
173
|
def SILENCE(msg: str) -> None:
|
|
170
174
|
"""
|
|
171
175
|
Helper function that takes a string, and does nothing with it. Meant to be passed as the print_message or print_output argument of run() and related functions to silence the corresponding output stream.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|