Skip to content

Commit e87b4cb

Browse files
committed
drop decode
1 parent 0b8b049 commit e87b4cb

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

myst_libre/tools/myst_client.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,32 +115,27 @@ def run_command(self, *args, env_vars={}, user=None, group=None):
115115
else:
116116
process = subprocess.Popen(command, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, cwd=self.build_dir)
117117

118+
# Initialize logs
118119
stdout_log = ""
119120
stderr_log = ""
120121
# Stream stdout in real-time
121122
while True:
122123
output = process.stdout.readline()
123-
if output == b"" and process.poll() is not None:
124+
if output == "" and process.poll() is not None:
124125
break
125126
if output:
126-
stdout_log += output.decode()
127-
self.cprint(output.decode(), "light_grey") # Print stdout in real-time
128-
127+
stdout_log += output # No need to decode
128+
self.cprint(output, "light_grey") # Print stdout in real-time
129+
# Stream stderr in real-time
129130
while True:
130131
error = process.stderr.readline()
131-
if error == b"" and process.poll() is not None:
132+
if error == "" and process.poll() is not None:
132133
break
133134
if error:
134-
stderr_log += error.decode()
135-
self.cprint(error.decode(), "red") # Print stderr in real-time
136-
135+
stderr_log += error # No need to decode
136+
self.cprint(error, "red") # Print stderr in real-time
137137
process.wait()
138-
139-
if process.returncode != 0:
140-
raise subprocess.CalledProcessError(process.returncode, command, output=stdout_log, stderr=stderr_log)
141-
142-
self.cprint(f"🐞 Command output: {stdout_log}", "light_grey")
143-
return stdout_log
138+
return stdout_log, stderr_log # Return both logs
144139

145140
except subprocess.CalledProcessError as e:
146141
print(f"Error running command: {e}")

0 commit comments

Comments
 (0)