Skip to content

Commit ba892d9

Browse files
committed
Properly capture STDERR from Podman
1 parent 5a50ee1 commit ba892d9

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

surveyor/podman.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import json
3+
import select
34
import time
45
import subprocess
56
import contextlib
@@ -174,13 +175,18 @@ def invokePodmanCommandPoll(command, output):
174175
Invoke podman command and continuously output stdout and stderr via a callback
175176
"""
176177
command = podmanBaseCommand(command)
177-
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
178-
for line in iter(p.stdout.readline, b''):
179-
output(line.decode("utf-8"))
180-
output(p.stdout.read().decode("utf-8"))
178+
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
179+
180+
while True:
181+
readable, _, _ = select.select([p.stdout, p.stderr], [], [], 0.1)
182+
for file in readable:
183+
line = file.readline().decode("utf-8")
184+
output(line)
185+
if p.poll() is not None:
186+
break
181187
exitcode = p.wait()
182188
if exitcode != 0:
183-
raise PodmanError(f"{' '.join(command)}", "")
189+
raise RuntimeError(f"{' '.join(command)}", "")
184190

185191
def imageExists(name):
186192
"""

0 commit comments

Comments
 (0)