pipeline: return logs in --json mode
A pipeline run only returned logs in the `StageFailed` and `AssemblerFailed` exceptions. Remove those and always return structured data instead. It only returns data for stages that actually ran (i.e., didn't come from the cache). This is similar to the output in interactive mode. Also change osbuildtest to be able to deal with output that is larger than the pipe buffer by using subprocess.communicate().
This commit is contained in:
parent
f1b9361837
commit
82a2be53d4
4 changed files with 67 additions and 73 deletions
|
|
@ -38,29 +38,24 @@ def main():
|
|||
pipeline.prepend_build_env(build_pipeline, runner)
|
||||
|
||||
try:
|
||||
pipeline.run(args.store, interactive=not args.json, libdir=args.libdir)
|
||||
r = pipeline.run(args.store, interactive=not args.json, libdir=args.libdir)
|
||||
except KeyboardInterrupt:
|
||||
print()
|
||||
print(f"{RESET}{BOLD}{RED}Aborted{RESET}")
|
||||
return 130
|
||||
except (osbuild.StageFailed, osbuild.AssemblerFailed) as error:
|
||||
print()
|
||||
print(f"{RESET}{BOLD}{RED}{error.name} failed with code {error.returncode}{RESET}")
|
||||
if args.json:
|
||||
print(error.output)
|
||||
return 1
|
||||
|
||||
if args.json:
|
||||
json.dump({
|
||||
"tree_id": pipeline.tree_id,
|
||||
"output_id": pipeline.output_id,
|
||||
}, sys.stdout)
|
||||
json.dump(r, sys.stdout)
|
||||
sys.stdout.write("\n")
|
||||
else:
|
||||
print("tree id:", pipeline.tree_id)
|
||||
print("output id:", pipeline.output_id)
|
||||
if r["success"]:
|
||||
print("tree id:", pipeline.tree_id)
|
||||
print("output id:", pipeline.output_id)
|
||||
else:
|
||||
print()
|
||||
print(f"{RESET}{BOLD}{RED}Failed{RESET}")
|
||||
|
||||
return 0
|
||||
return 0 if r["success"] else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue