mirror of
https://github.com/dobin/SuperMega
synced 2026-06-02 17:27:10 +00:00
refactor: consolidate all three log things (cmd output, logger, files) into observer
This commit is contained in:
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user