From bcea55337fb7dab98877bba0ced8a60710e865b3 Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Thu, 13 Jul 2023 13:29:54 -0700 Subject: [PATCH] hotfix: add returncode checks for operator --- pv2/importer/operation.py | 8 +++++++- pv2/util/constants.py | 1 + pv2/util/error.py | 10 ++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/pv2/importer/operation.py b/pv2/importer/operation.py index 962a70d..bd3f2bc 100644 --- a/pv2/importer/operation.py +++ b/pv2/importer/operation.py @@ -80,7 +80,10 @@ class Import: f"'%_topdir {local_repo_path}'" ] command_to_send = ' '.join(command_to_send) - processor.run_proc_no_output_shell(command_to_send) + returned = processor.run_proc_no_output_shell(command_to_send) + if returned != 0: + rpmerr = returned.stderr + raise err.RpmOpenError(f'This package could not be unpacked:\n\n{rpmerr}') @staticmethod def pack_srpm(srpm_dir, spec_file, dist_tag): @@ -103,6 +106,9 @@ class Import: ] command_to_send = ' '.join(command_to_send) returned = processor.run_proc_no_output_shell(command_to_send) + if returned != 0: + rpmerr = returned.stderr + raise err.RpmBuildError(f'There was error packing the rpm:\n\n{rpmerr}') wrote_regex = r'Wrote:\s+(.*\.rpm)' regex_search = re.search(wrote_regex, returned.stdout, re.MULTILINE) if regex_search: diff --git a/pv2/util/constants.py b/pv2/util/constants.py index 538ca88..bf27166 100644 --- a/pv2/util/constants.py +++ b/pv2/util/constants.py @@ -96,6 +96,7 @@ class ErrorConstants: RPM_ERR_OPEN = 9400 RPM_ERR_SIG = 9401 RPM_ERR_INFO = 9402 + RPM_ERR_BUILD = 9403 # pylint: disable=too-few-public-methods class MockConstants: diff --git a/pv2/util/error.py b/pv2/util/error.py index 78be1f5..4d2c3b6 100644 --- a/pv2/util/error.py +++ b/pv2/util/error.py @@ -31,6 +31,7 @@ __all__ = [ 'RpmOpenError', 'RpmSigError', 'RpmInfoError', + 'RpmBuildError', ] @@ -170,7 +171,12 @@ class RpmSigError(GenericError): class RpmInfoError(GenericError): """ - There was an issue opening the RPM because the signature could not be - verified + There was an issue opening the RPM because the RPM is not valid. """ fault_code = errconst.RPM_ERR_INFO + +class RpmBuildError(GenericError): + """ + There was an issue building or packing the RPM. + """ + fault_code = errconst.RPM_ERR_BUILD