|
23 | 23 | Protocol, |
24 | 24 | Sequence, |
25 | 25 | Union, |
26 | | - overload, |
27 | 26 | ) |
28 | 27 |
|
29 | 28 | from typing_extensions import TypeAlias |
@@ -164,89 +163,38 @@ def __call__(self, output: Union[str, bytes], timestamp: datetime.datetime): |
164 | 163 | _CMD = Union[StrOrBytesPath, Sequence[StrOrBytesPath]] |
165 | 164 | _FILE: TypeAlias = None | int | IO[Any] |
166 | 165 |
|
167 | | -# def run( |
168 | | -# args: _CMD, |
169 | | -# bufsize: int = -1, |
170 | | -# executable: StrOrBytesPath | None = None, |
171 | | -# stdin: _FILE | None = None, |
172 | | -# stdout: _FILE | None = None, |
173 | | -# stderr: _FILE | None = None, |
174 | | -# preexec_fn: Callable[[], Any] | None = None, |
175 | | -# close_fds: bool = True, |
176 | | -# shell: bool = False, |
177 | | -# cwd: StrOrBytesPath | None = None, |
178 | | -# env: _ENV | None = None, |
179 | | -# universal_newlines: bool = False, |
180 | | -# startupinfo: Any | None = None, |
181 | | -# creationflags: int = 0, |
182 | | -# restore_signals: bool = True, |
183 | | -# start_new_session: bool = False, |
184 | | -# pass_fds: Any = None, |
185 | | -# *, |
186 | | -# text: bool | None = None, |
187 | | -# encoding: str = "utf-8", |
188 | | -# errors: str | None = None, |
189 | | -# user: str | int | None = None, |
190 | | -# group: str | int | None = None, |
191 | | -# extra_groups: Iterable[str | int] | None = None, |
192 | | -# umask: int = -1, |
193 | | -# pipesize: int = -1, |
194 | | -# |
195 | | -# |
196 | | -# # custom |
197 | | -# log_in_real_time: bool = True, |
198 | | -# check_returncode: bool = True, |
199 | | -# callback: Optional[ProgressCallbackProtocol] = None, |
200 | | -# ): |
201 | | - |
202 | | - |
203 | | -@overload |
204 | | -def run( |
205 | | - args: _CMD, |
206 | | - bufsize: int = ..., |
207 | | - executable: StrOrBytesPath | None = ..., |
208 | | - stdin: _FILE | None = ..., |
209 | | - stdout: _FILE | None = ..., |
210 | | - stderr: _FILE | None = ..., |
211 | | - preexec_fn: Callable[[], Any] | None = ..., |
212 | | - close_fds: bool = ..., |
213 | | - shell: bool = ..., |
214 | | - cwd: Optional[StrOrBytesPath] = ..., |
215 | | - env: _ENV | None = ..., |
216 | | - universal_newlines: bool = ..., |
217 | | - startupinfo: Any | None = ..., |
218 | | - creationflags: int = ..., |
219 | | - restore_signals: bool = ..., |
220 | | - start_new_session: bool = ..., |
221 | | - pass_fds: Any = ..., |
222 | | - *, |
223 | | - text: bool | None = ..., |
224 | | - encoding: str = "utf-8", |
225 | | - errors: str | None = ..., |
226 | | - user: str | int | None = ..., |
227 | | - group: str | int | None = ..., |
228 | | - extra_groups: Iterable[str | int] | None = ..., |
229 | | - umask: int = ..., |
230 | | - pipesize: int = ..., |
231 | | - # custom |
232 | | - log_in_real_time: bool = True, |
233 | | - check_returncode: bool = True, |
234 | | - callback: Optional[ProgressCallbackProtocol] = None, |
235 | | -): |
236 | | - ... |
237 | | - |
238 | 166 |
|
239 | 167 | def run( |
240 | | - # args: Union[str, list[str]], |
241 | 168 | args: _CMD, |
| 169 | + bufsize: int = -1, |
| 170 | + executable: StrOrBytesPath | None = None, |
| 171 | + stdin: _FILE | None = None, |
| 172 | + stdout: _FILE | None = None, |
| 173 | + stderr: _FILE | None = None, |
| 174 | + preexec_fn: Callable[[], Any] | None = None, |
| 175 | + close_fds: bool = True, |
242 | 176 | shell: bool = False, |
243 | | - cwd: Optional[StrOrBytesPath] = None, |
| 177 | + cwd: StrOrBytesPath | None = None, |
| 178 | + env: _ENV | None = None, |
| 179 | + universal_newlines: bool | None = None, |
| 180 | + startupinfo: Any | None = None, |
| 181 | + creationflags: int = 0, |
| 182 | + restore_signals: bool = True, |
| 183 | + start_new_session: bool = False, |
| 184 | + pass_fds: Any = (), |
244 | 185 | *, |
| 186 | + text: bool | None = None, |
| 187 | + encoding: str | None = None, |
| 188 | + errors: str | None = None, |
| 189 | + user: str | int | None = None, |
| 190 | + group: str | int | None = None, |
| 191 | + extra_groups: Iterable[str | int] | None = None, |
| 192 | + umask: int = -1, |
| 193 | + pipesize: int = -1, |
245 | 194 | # custom |
246 | 195 | log_in_real_time: bool = True, |
247 | 196 | check_returncode: bool = True, |
248 | 197 | callback: Optional[ProgressCallbackProtocol] = None, |
249 | | - **kwargs, |
250 | 198 | ): |
251 | 199 | """Run 'cmd' in a shell and return the combined contents of stdout and |
252 | 200 | stderr (Blocking). Throws an exception if the command exits non-zero. |
@@ -285,11 +233,30 @@ def progress_cb(output, timestamp): |
285 | 233 | """ |
286 | 234 | proc = subprocess.Popen( |
287 | 235 | args, |
| 236 | + bufsize=bufsize, |
| 237 | + executable=executable, |
| 238 | + stdin=stdin, |
| 239 | + stdout=stdout or subprocess.PIPE, |
| 240 | + stderr=stderr or subprocess.PIPE, |
| 241 | + preexec_fn=preexec_fn, |
| 242 | + close_fds=close_fds, |
288 | 243 | shell=shell, |
289 | | - stderr=subprocess.PIPE, |
290 | | - stdout=subprocess.PIPE, |
291 | 244 | cwd=cwd, |
292 | | - **kwargs, |
| 245 | + env=env, |
| 246 | + universal_newlines=universal_newlines, |
| 247 | + startupinfo=startupinfo, |
| 248 | + creationflags=creationflags, |
| 249 | + restore_signals=restore_signals, |
| 250 | + start_new_session=start_new_session, |
| 251 | + pass_fds=pass_fds, |
| 252 | + text=text, |
| 253 | + encoding=encoding, |
| 254 | + errors=errors, |
| 255 | + user=user, |
| 256 | + group=group, |
| 257 | + extra_groups=extra_groups, |
| 258 | + umask=umask, |
| 259 | + pipesize=pipesize, |
293 | 260 | ) |
294 | 261 |
|
295 | 262 | all_output = [] |
|
0 commit comments