From 727b40b150420cf2cc9348687f07e6346796a114 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Wed, 9 Aug 2023 12:37:51 +0200 Subject: [PATCH] rpmbuild: more verbose results.json SRPM generator Relates: #2839 --- rpmbuild/copr_rpmbuild/automation/__init__.py | 1 + rpmbuild/copr_rpmbuild/automation/rpm_results.py | 6 ++++-- rpmbuild/copr_rpmbuild/automation/srpm_results.py | 6 ++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/rpmbuild/copr_rpmbuild/automation/__init__.py b/rpmbuild/copr_rpmbuild/automation/__init__.py index 77439fe29..99cb98904 100644 --- a/rpmbuild/copr_rpmbuild/automation/__init__.py +++ b/rpmbuild/copr_rpmbuild/automation/__init__.py @@ -20,3 +20,4 @@ def run_automation_tools(task, resultdir, mock_config_file, log): continue log.info("Running %s tool", tool.__class__.__name__) tool.run() + log.info("%s finished", tool.__class__.__name__) diff --git a/rpmbuild/copr_rpmbuild/automation/rpm_results.py b/rpmbuild/copr_rpmbuild/automation/rpm_results.py index 60f26f059..ab7e6ee4d 100644 --- a/rpmbuild/copr_rpmbuild/automation/rpm_results.py +++ b/rpmbuild/copr_rpmbuild/automation/rpm_results.py @@ -27,9 +27,11 @@ def run(self): """ nevras = self.find_results_nevras_dicts() packages = {"packages": nevras} + packages_json = json.dumps(packages, indent=4) + self.log.info("Package info:\n%s", packages_json) path = os.path.join(self.resultdir, "results.json") - with open(path, "w") as dst: - json.dump(packages, dst, indent=4) + with open(path, "w", encoding="utf-8") as dst: + dst.write(packages_json) def find_results_nevras_dicts(self): """ diff --git a/rpmbuild/copr_rpmbuild/automation/srpm_results.py b/rpmbuild/copr_rpmbuild/automation/srpm_results.py index 2618008b8..478ed07bf 100644 --- a/rpmbuild/copr_rpmbuild/automation/srpm_results.py +++ b/rpmbuild/copr_rpmbuild/automation/srpm_results.py @@ -31,9 +31,11 @@ def run(self): Create `results.json` """ data = self.get_package_info() + data_json = json.dumps(data, indent=4) + self.log.info("Package info: %s", data_json) path = os.path.join(self.resultdir, "results.json") with open(path, "w", encoding="utf-8") as dst: - json.dump(data, dst, indent=4) + dst.write(data_json) def get_package_info(self): """ @@ -52,7 +54,7 @@ def get_package_info(self): msg = "Exception appeared during handling spec file: {0}".format(path) self.log.exception(msg) - # Fallback to querying NEVRA from the SRPM package header path = locate_srpm(self.resultdir) + self.log.warning("Querying NEVRA from SRPM header: %s", path) hdr = get_rpm_header(path) return {key: hdr[key] for key in keys}