From: Alexis Lothoré <[email protected]> As for other scripts in yocto-autobuilder-helper or oecore, use python logger class instead of raw print calls to allow log level distinction
Signed-off-by: Alexis Lothoré <[email protected]> --- scripts/send_qa_email.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/send_qa_email.py b/scripts/send_qa_email.py index 4613bff892e0..8a8454d09c2f 100755 --- a/scripts/send_qa_email.py +++ b/scripts/send_qa_email.py @@ -11,6 +11,7 @@ import sys import subprocess import tempfile import re +import logging import utils @@ -64,8 +65,8 @@ def get_regression_base_and_target(basebranch, comparebranch, release, targetrep #Default case: return previous tag as base return get_previous_tag(targetrepodir, release), basebranch -def generate_regression_report(querytool, targetrepodir, base, target, resultdir, outputdir): - print(f"Comparing {target} to {base}") +def generate_regression_report(querytool, targetrepodir, base, target, resultdir, outputdir, log): + log.info(f"Comparing {target} to {base}") try: regreport = subprocess.check_output([querytool, "regression-report", base, target, '-t', resultdir]) @@ -73,9 +74,13 @@ def generate_regression_report(querytool, targetrepodir, base, target, resultdir f.write(regreport) except subprocess.CalledProcessError as e: error = str(e) - print(f"Error while generating report between {target} and {base} : {error}") + log.error(f"Error while generating report between {target} and {base} : {error}") def send_qa_email(): + # Setup logging + logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s") + log = logging.getLogger('send-qa-email') + parser = utils.ArgParser(description='Process test results and optionally send an email about the build to prompt QA to begin testing.') parser.add_argument('send', @@ -132,7 +137,7 @@ def send_qa_email(): try: subprocess.check_call(["git", "clone", "[email protected]:yocto-testresults", tempdir, "--depth", "1"] + cloneopts) except subprocess.CalledProcessError: - print("No comparision branch found, falling back to master") + log.info("No comparision branch found, falling back to master") subprocess.check_call(["git", "clone", "[email protected]:yocto-testresults", tempdir, "--depth", "1"]) # If the base comparision branch isn't present regression comparision won't work @@ -157,7 +162,7 @@ def send_qa_email(): regression_base, regression_target = get_regression_base_and_target(basebranch, comparebranch, args.release, targetrepodir) if regression_base and regression_target: - generate_regression_report(querytool, targetrepodir, regression_base, regression_target, tempdir, args.results_dir) + generate_regression_report(querytool, targetrepodir, regression_base, regression_target, tempdir, args.results_dir, log) finally: subprocess.check_call(["rm", "-rf", tempdir]) -- 2.41.0
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#60289): https://lists.yoctoproject.org/g/yocto/message/60289 Mute This Topic: https://lists.yoctoproject.org/mt/99523810/21656 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
