Skip to content

Commit aa7a408

Browse files
committed
standardize command handling
1 parent 4ca8aae commit aa7a408

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

jupyter_releaser/tee.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,15 +156,6 @@ def run(args: Union[str, List[str]], **kwargs: Any) -> CompletedProcess:
156156

157157
check = kwargs.get("check", False)
158158

159-
if kwargs.get("echo", False):
160-
# This is modified from the default implementation since
161-
# we want all output to be interleved on the same stream
162-
prefix = "COMMAND"
163-
if kwargs.pop("show_cwd", False):
164-
prefix += f" (in '{os.getcwd()}')"
165-
prefix += ":"
166-
print(f"{prefix} {cmd}", file=sys.stderr)
167-
168159
loop = asyncio.get_event_loop()
169160
result = loop.run_until_complete(_stream_subprocess(cmd, **kwargs))
170161

jupyter_releaser/util.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,23 @@
5454
def run(cmd, **kwargs):
5555
"""Run a command as a subprocess and get the output as a string"""
5656
quiet_error = kwargs.pop("quiet_error", False)
57+
show_cwd = kwargs.pop("show_cwd", False)
58+
quiet = kwargs.pop("quiet", False)
59+
echo = kwargs.pop("echo", False)
60+
61+
if echo:
62+
prefix = "COMMAND"
63+
if show_cwd:
64+
prefix += f" (in '{os.getcwd()}')"
65+
prefix += ":"
66+
print(f"{prefix} {cmd}", file=sys.stderr)
67+
5768
if sys.platform.startswith("win"):
5869
# Async subprocesses do not work well on Windows, use standard
5970
# subprocess methods
6071
return _run_win(cmd, **kwargs)
6172

6273
quiet = kwargs.get("quiet")
63-
kwargs.setdefault("echo", True)
6474
kwargs.setdefault("check", True)
6575

6676
try:
@@ -77,12 +87,11 @@ def run(cmd, **kwargs):
7787

7888
def _run_win(cmd, **kwargs):
7989
"""Run a command as a subprocess and get the output as a string"""
80-
kwargs.pop("show_cwd", False)
8190
quiet = kwargs.pop("quiet", False)
91+
8292
if not quiet:
83-
log(f"> {cmd}")
84-
else:
8593
kwargs.setdefault("stderr", PIPE)
94+
8695
kwargs.setdefault("shell", True)
8796

8897
parts = shlex.split(cmd)

0 commit comments

Comments
 (0)