From fe738ad1502fb550c37ad4154e83c71797f58873 Mon Sep 17 00:00:00 2001 From: Pascal Lais Date: Sun, 5 Dec 2021 14:46:46 +0100 Subject: [PATCH] Use Popen to fix output order in drone --- run_all.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/run_all.py b/run_all.py index 1b5e482..97fb085 100644 --- a/run_all.py +++ b/run_all.py @@ -2,13 +2,18 @@ from os import listdir from os.path import isdir, isfile -from subprocess import run +from subprocess import Popen, PIPE, CalledProcessError for dir in [x for x in sorted(listdir('.')) if isdir(x)]: file = dir + '/' + dir + '.py' input = dir + '/input.txt' if isfile(file) and isfile(input): - print(dir, 'result:') - run(["python3", file]) + print(dir, ':', sep='') + with Popen(["python3", file], stdout=PIPE, bufsize=1, universal_newlines=True) as p: + for b in p.stdout: + print(b, end='') + if p.returncode != 0: + raise CalledProcessError(p.returncode, p.args) +