From d807e0789b279a1176de17b5169e7301296738ee Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 19 Jan 2024 13:29:35 +0100 Subject: doc: Fix error handling in qdoc_spawner Check on the exit code, not on the presence of warnings on stderr to determine failures. Amends 9bbbb29809ec7552698680a40e20ec271d929c67, cb4d09368dd3719e3e17afa07020c4d41fb03100 Task-number: PYSIDE-1106 Change-Id: I092b5f991c1bb114a1d51f73bd833da5aedaeda8 Reviewed-by: Cristian Maureira-Fredes (cherry picked from commit 5dabf393f6175070890483040ee361ee59a84da2) Reviewed-by: Qt Cherry-pick Bot --- sources/pyside6/doc/qdoc_spawner.py.in | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/sources/pyside6/doc/qdoc_spawner.py.in b/sources/pyside6/doc/qdoc_spawner.py.in index fb0a8f2cd..0223e50ee 100644 --- a/sources/pyside6/doc/qdoc_spawner.py.in +++ b/sources/pyside6/doc/qdoc_spawner.py.in @@ -5,6 +5,7 @@ import argparse import subprocess import os import sys +import time from multiprocessing import Pool, cpu_count from pathlib import Path @@ -27,23 +28,23 @@ def run_qdoc(file, qdoc_args, args): args.doc_data_dir, ] + start_time = time.time() _ = subprocess.Popen(command, env=env, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out, err = _.communicate() + returncode = _.wait() + duration = round(time.time() - start_time) - if args.verbose: - _out, _err = _.communicate() - out = _out.decode("utf-8") - err = _err.decode("utf-8") + if args.verbose or returncode != 0 or err: + cmd_str = " ".join(command) + print(f"> Output of: {cmd_str}") + if out: + print(out.decode("utf-8"), file=sys.stdout) + if err: + print(err.decode("utf-8"), file=sys.stderr) + print(f"> Finished: {file} {duration}s (exit code {returncode})") - if out: - print(out, file=sys.stdout) - if err: - print(err, file=sys.stderr) - raise Exception(f"Failing executing the command {command}") - else: - _.wait() - - if args.verbose: - print(f"> Finished: {file}") + if returncode != 0: + raise Exception(f"Failing executing the command {command} ({returncode})") def get_qdocconf_files(): @@ -94,5 +95,5 @@ if __name__ == "__main__": with Pool(int(parallel)) as p: p.starmap(run_qdoc, [(str(f), ["-single-exec"], args) for f in files_single_exec]) except Exception as e: - print(f"Error while running qdoc_spawner: {e}", file=sys.stderr) + print(f"qdoc_spawner: error: {e}", file=sys.stderr) sys.exit(-1) -- cgit v1.2.3