refactor: consolidate all three log things (cmd output, logger, files) into observer

This commit is contained in:
Dobin
2024-03-28 20:40:57 +00:00
parent b6816604b2
commit ed9647920b
7 changed files with 45 additions and 60 deletions
+4 -4
View File
@@ -55,19 +55,19 @@ def run_process_checkret(args, check=True):
cmd += "--- " + " ".join(args) + "\n"
f.write(cmd.encode('utf-8'))
if ret.stdout != None:
observer.add_log(ret.stdout.decode('utf-8'))
observer.add_cmd_output(ret.stdout.decode('utf-8'))
f.write(ret.stdout)
if ret.stderr != None:
observer.add_log(ret.stderr.decode('utf-8'))
observer.add_cmd_output(ret.stderr.decode('utf-8'))
f.write(ret.stderr)
if ret.returncode != 0 and check:
logger.info("----! FAILED Command: {}".format(" ".join(args)))
if ret.stdout != None:
observer.add_log(ret.stdout.decode('utf-8'))
observer.add_cmd_output(ret.stdout.decode('utf-8'))
logger.info(ret.stdout.decode('utf-8'))
if ret.stderr != None:
observer.add_log(ret.stderr.decode('utf-8'))
observer.add_cmd_output(ret.stderr.decode('utf-8'))
logger.info(ret.stderr.decode('utf-8'))
raise Exception("Command failed: " + " ".join(args))