Skip to content

Commit b35b941

Browse files
committed
Fixing broken tests and linting
1 parent 740a9b3 commit b35b941

File tree

3 files changed

+13
-429
lines changed

3 files changed

+13
-429
lines changed

src/pipx/animate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ def print_animation(
8383
) -> None:
8484
(term_cols, _) = shutil.get_terminal_size(fallback=(9999, 24))
8585
event.wait(delay)
86-
last_received_stream = ""
8786
while not event.wait(0):
8887
for s in symbols:
88+
last_received_stream = ""
8989
if stream is not None and not stream.empty():
9090
last_received_stream = f": {stream.get_nowait().strip()}"
9191
if animate_at_beginning_of_line:
@@ -95,7 +95,7 @@ def print_animation(
9595
cur_line += "..."
9696
else:
9797
max_message_len = term_cols - len("... ")
98-
cur_line = f"{f'{message}{last_received_stream}':.{max_message_len}} {s}"
98+
cur_line = f"{f'{message}{last_received_stream}':.{max_message_len}}{s}"
9999

100100
clear_line()
101101
sys.stderr.write(cur_line)

src/pipx/util.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,6 @@ def run_subprocess(
195195
text=True,
196196
cwd=run_dir,
197197
) as process:
198-
try:
199-
importlib.util.find_spec("msvcrt")
200-
except ModuleNotFoundError:
201-
_mswindows = False
202-
else:
203-
_mswindows = True
204-
205198
try:
206199
stdout, stderr = "", ""
207200
while True:
@@ -211,14 +204,19 @@ def run_subprocess(
211204
stdout += out
212205
if stream is not None:
213206
stream.put_nowait(out)
207+
if err:
208+
stderr += err
214209
if not out and not err:
215210
break
216-
except TimeoutExpired:
211+
except TimeoutExpired as exc:
217212
process.kill()
218-
if _mswindows:
219-
process.communicate()
220-
else:
213+
try:
214+
importlib.util.find_spec("msvcrt")
215+
except ModuleNotFoundError:
221216
process.wait()
217+
else:
218+
communication_result = process.communicate()
219+
exc.stdout, exc.stderr = bytes(communication_result[0], "utf-8"), bytes(communication_result[1], "utf-8")
222220
raise
223221
except:
224222
process.kill()
@@ -227,6 +225,8 @@ def run_subprocess(
227225

228226
if type(retcode) is int:
229227
completed_process = subprocess.CompletedProcess(process.args, retcode, stdout, stderr)
228+
else:
229+
completed_process = subprocess.CompletedProcess(process.args, 0, stdout, stderr)
230230

231231
if capture_stdout and log_stdout:
232232
logger.debug(f"stdout: {completed_process.stdout}".rstrip())

0 commit comments

Comments
 (0)