projects
/
python_utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Let text_utils work with strings that contain ansi escape sequences.
[python_utils.git]
/
exec_utils.py
diff --git
a/exec_utils.py
b/exec_utils.py
index dcd30a2e937e271ffe75109c019b3b345fa5997d..a440de5375c1546d0bf46835bc00ecada06b7d9d 100644
(file)
--- a/
exec_utils.py
+++ b/
exec_utils.py
@@
-1,5
+1,7
@@
#!/usr/bin/env python3
#!/usr/bin/env python3
+"""Helper methods concerned with executing subprocesses."""
+
import atexit
import logging
import os
import atexit
import logging
import os
@@
-9,7
+11,6
@@
import subprocess
import sys
from typing import List, Optional
import sys
from typing import List, Optional
-
logger = logging.getLogger(__file__)
logger = logging.getLogger(__file__)
@@
-31,12
+32,12
@@
def cmd_showing_output(
stderr=subprocess.PIPE,
universal_newlines=False,
) as p:
stderr=subprocess.PIPE,
universal_newlines=False,
) as p:
- sel.register(p.stdout, selectors.EVENT_READ)
- sel.register(p.stderr, selectors.EVENT_READ)
+ sel.register(p.stdout, selectors.EVENT_READ)
# type: ignore
+ sel.register(p.stderr, selectors.EVENT_READ)
# type: ignore
done = False
while not done:
for key, _ in sel.select():
done = False
while not done:
for key, _ in sel.select():
- char = key.fileobj.read(1)
+ char = key.fileobj.read(1)
# type: ignore
if not char:
sel.unregister(key.fileobj)
if len(sel.get_map()) == 0:
if not char:
sel.unregister(key.fileobj)
if len(sel.get_map()) == 0:
@@
-138,7
+139,7
@@
def cmd_in_background(command: str, *, silent: bool = False) -> subprocess.Popen
def kill_subproc() -> None:
try:
if subproc.poll() is None:
def kill_subproc() -> None:
try:
if subproc.poll() is None:
- logger.info(
f'At exit handler: killing {subproc} ({command})'
)
+ logger.info(
'At exit handler: killing %s (%s)', subproc, command
)
subproc.terminate()
subproc.wait(timeout=10.0)
except BaseException as be:
subproc.terminate()
subproc.wait(timeout=10.0)
except BaseException as be: