]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
test/py: multiplexed_log.py: Clean up and correct RunAndLog()
authorTom Rini <trini@konsulko.com>
Fri, 24 Oct 2025 17:26:42 +0000 (11:26 -0600)
committerTom Rini <trini@konsulko.com>
Fri, 7 Nov 2025 20:19:46 +0000 (14:19 -0600)
The general python documentation for the subprocess class recommends
that run() be used in all cases that it can handle. What we do in
RunAndLog is simple enough that run() is easy to switch to. In fact,
looking at this exposed a problem we have today, which is that we had
combined stdout and stderr but then looked at both stdout and stderr as
if they were separate. Stop combining them.

Signed-off-by: Tom Rini <trini@konsulko.com>
test/py/multiplexed_log.py

index 63237594bb405ba3e1a97d7932eb4fba8c608c60..68dc183e4638d72a8233e8393da0c4d13b1b42ac 100644 (file)
@@ -138,10 +138,10 @@ class RunAndLog(object):
         self.logfile.write(self, msg)
 
         try:
-            p = subprocess.Popen(cmd, cwd=cwd,
-                stdin=subprocess.PIPE if stdin else None,
-                stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=env)
-            (stdout, stderr) = p.communicate(input=stdin)
+            p = subprocess.run(cmd, cwd=cwd, capture_output=True, input=stdin,
+                               env=env)
+            stdout = p.stdout
+            stderr = p.stderr
             if stdout is not None:
                 stdout = stdout.decode('utf-8')
             if stderr is not None: