@@ -114,32 +114,18 @@ def run_command(self, *args, env_vars={}, user=None, group=None):
114
114
cwd = self .build_dir )
115
115
else :
116
116
process = subprocess .Popen (command , env = env , stdout = subprocess .PIPE , stderr = subprocess .PIPE , text = True , cwd = self .build_dir )
117
-
118
- output = []
119
- error_output = []
120
117
121
118
# 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 ()
133
120
134
121
process .wait ()
135
122
136
123
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 )
138
125
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
141
128
142
- return command_output
143
129
except subprocess .CalledProcessError as e :
144
130
print (f"Error running command: { e } " )
145
131
print (f"Command output: { e .output } " )
0 commit comments