|
|
@@ -20,17 +20,17 @@ def run_with_log(args, *, check = True, input = None, **kwargs): |
|
|
|
if badKwargs: |
|
|
|
raise ValueError(f'Disallowed kwargs: {", ".join(sorted(badKwargs))}') |
|
|
|
_logger.info(f'Running subprocess: {args!r}') |
|
|
|
if input: |
|
|
|
if input is not None: |
|
|
|
kwargs['stdin'] = subprocess.PIPE |
|
|
|
p = subprocess.Popen(args, **kwargs, stdout = subprocess.PIPE, stderr = subprocess.PIPE) |
|
|
|
sel = selectors.DefaultSelector() |
|
|
|
if input: |
|
|
|
if input is not None: |
|
|
|
sel.register(p.stdin, selectors.EVENT_WRITE) |
|
|
|
sel.register(p.stdout, selectors.EVENT_READ) |
|
|
|
sel.register(p.stderr, selectors.EVENT_READ) |
|
|
|
stdout = [] |
|
|
|
stderrBuf = b'' |
|
|
|
if input: |
|
|
|
if input is not None: |
|
|
|
stdinView = memoryview(input) |
|
|
|
stdinOffset = 0 |
|
|
|
PIPE_BUF = getattr(select, 'PIPE_BUF', 512) |
|
|
@@ -65,7 +65,7 @@ def run_with_log(args, *, check = True, input = None, **kwargs): |
|
|
|
if stderrBuf: |
|
|
|
_logger.info(stderrBuf.decode('utf-8')) |
|
|
|
assert p.poll() is not None |
|
|
|
if input and stdinOffset < len(input): |
|
|
|
if input is not None and stdinOffset < len(input): |
|
|
|
_logger.warning(f'Could not write all input to the stdin pipe (wanted to write {len(input)} bytes, only wrote {stdinOffset})') |
|
|
|
_logger.info(f'Process exited with status {p.returncode}') |
|
|
|
if check and p.returncode != 0: |
|
|
|