Skip to content

Commit 6af5237

Browse files
committed
Forward stdout and stderr from Python to terminal
1 parent 09141a5 commit 6af5237

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

tools/pcmsolver.py.in

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,18 @@ def parse_pcm_input(inputFile):
189189
def execute(parsedFile):
190190
executable = os.path.join(os.path.dirname(__file__), "run_pcm" + "@CMAKE_EXECUTABLE_SUFFIX@")
191191
if (executable):
192-
try:
193-
subprocess.check_output([executable, parsedFile])
194-
except subprocess.CalledProcessError as e:
195-
print((e.output))
196-
sys.exit(1)
192+
p = subprocess.Popen([executable, parsedFile],
193+
shell=False,
194+
stdin=subprocess.PIPE,
195+
stdout=subprocess.PIPE,
196+
stderr=subprocess.PIPE)
197+
stdout_coded, stderr_coded = p.communicate()
198+
stdout = stdout_coded.decode('UTF-8')
199+
stderr = stderr_coded.decode('UTF-8')
200+
201+
print(stdout)
202+
# Print the contents of stderr, without exiting
203+
sys.stderr.write(stderr)
197204
else:
198205
print('No executable available for standalone run')
199206
sys.exit(1)

0 commit comments

Comments
 (0)