Skip to content

Commit 41e7032

Browse files
committed
fix logging
1 parent ec3c024 commit 41e7032

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

myst_libre/tools/myst_client.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -114,32 +114,18 @@ def run_command(self, *args, env_vars={}, user=None, group=None):
114114
cwd=self.build_dir)
115115
else:
116116
process = subprocess.Popen(command, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, cwd=self.build_dir)
117-
118-
output = []
119-
error_output = []
120117

121118
# Stream stdout and stderr in real-time
122-
while True:
123-
stdout_line = process.stdout.readline()
124-
stderr_line = process.stderr.readline()
125-
if not stdout_line and not stderr_line and process.poll() is not None:
126-
break
127-
if stdout_line:
128-
print(stdout_line, end='')
129-
output.append(stdout_line)
130-
if stderr_line:
131-
print(stderr_line, end='', file=sys.stderr)
132-
error_output.append(stderr_line)
119+
stdout_log, stderr_log = process.communicate()
133120

134121
process.wait()
135122

136123
if process.returncode != 0:
137-
raise subprocess.CalledProcessError(process.returncode, command, output='\n'.join(output), stderr='\n'.join(error_output))
124+
raise subprocess.CalledProcessError(process.returncode, command, output=stdout_log, stderr=stderr_log)
138125

139-
# Capture the output in a variable for logging
140-
command_output = ''.join(output)
126+
self.cprint(f"🐞 Command output: {stdout_log}", "light_grey")
127+
return stdout_log
141128

142-
return command_output
143129
except subprocess.CalledProcessError as e:
144130
print(f"Error running command: {e}")
145131
print(f"Command output: {e.output}")

0 commit comments

Comments
 (0)