From 739c7469838ce2e52f623a43f7b99678c0aba5c2 Mon Sep 17 00:00:00 2001 From: Troy Dawson Date: Aug 28 2023 16:14:12 +0000 Subject: On errors: output to stderr, exit with code 1 Signed-off-by: Troy Dawson --- diff --git a/src/centpkg/cli.py b/src/centpkg/cli.py index 19d1f8b..ad42cda 100755 --- a/src/centpkg/cli.py +++ b/src/centpkg/cli.py @@ -197,11 +197,11 @@ class centpkgClient(cliClient): try: active_y, in_stabilization = centpkg.utils.determine_active_y_version(rhel_version, pp_api_url) except AssertionError as e: - self.log.info(" Error: centpkg cannot determine the development phase.") - self.log.info(" Please file an issue at https://git.centos.org/centos/centpkg") - self.log.info(" Workaround: Use the --rhel-target option") - self.log.info("Exiting") - raise SystemExit + self.log.error(" Error: centpkg cannot determine the development phase.") + self.log.error(" Please file an issue at https://git.centos.org/centos/centpkg") + self.log.error(" Workaround: Use the --rhel-target option") + self.log.error("Exiting") + raise SystemExit(1) divergent_branch = centpkg.utils.does_divergent_branch_exist( self.cmd.repo_name, rhel_version, @@ -233,11 +233,11 @@ class centpkgClient(cliClient): elif not divergent_branch and not in_stabilization : temp_custom_user_metadata["rhel-target"] = "zstream" else: - self.log.info("We are currently in Stabalization mode") - self.log.info("You must either set the rhel-target (--rhel-target)") - self.log.info("or branch for the previous version.") - self.log.info("Exiting") - raise SystemExit + self.log.error("We are currently in Stabalization mode") + self.log.error("You must either set the rhel-target (--rhel-target)") + self.log.error("or branch for the previous version.") + self.log.error("Exiting") + raise SystemExit(1) self.args.custom_user_metadata = json.dumps(temp_custom_user_metadata) else: if divergent_branch: @@ -245,21 +245,21 @@ class centpkgClient(cliClient): elif not divergent_branch and not in_stabilization : self.args.custom_user_metadata = '{"rhel-target": "zstream"}' else: - self.log.info("We are currently in Stabalization mode") - self.log.info("You must either set the rhel-target (--rhel-target)") - self.log.info("or branch for the previous version.") - self.log.info("Exiting") - raise SystemExit + self.log.error("We are currently in Stabalization mode") + self.log.error("You must either set the rhel-target (--rhel-target)") + self.log.error("or branch for the previous version.") + self.log.error("Exiting") + raise SystemExit(1) # Good to know self.log.info(" rhel-target: " + json.loads(self.args.custom_user_metadata)['rhel-target']) else: - self.log.info("NO INTERNAL CONFIGURATION") - self.log.info("Only scratch builds are allowed without internal configurations") - self.log.info("Hint: Install the rhel-packager package from https://download.devel.redhat.com/rel-eng/RCMTOOLS/latest-RCMTOOLS-2-RHEL-9/compose/BaseOS/x86_64/os/Packages/ if you want to build the package via internal (Red Hat) configuration.") - self.log.info("Exiting") - raise SystemExit + self.log.error("NO INTERNAL CONFIGURATION") + self.log.error("Only scratch builds are allowed without internal configurations") + self.log.error("Hint: Install the rhel-packager package from https://download.devel.redhat.com/rel-eng/RCMTOOLS/latest-RCMTOOLS-2-RHEL-9/compose/BaseOS/x86_64/os/Packages/ if you want to build the package via internal (Red Hat) configuration.") + self.log.error("Exiting") + raise SystemExit(1) # Proceed with build return super(centpkgClient, self)._build(sets) @@ -291,12 +291,12 @@ class centpkgClient(cliClient): try: project = gl.projects.get(project_name_with_namespace) except gitlab.exceptions.GitlabGetError as e: - self.log.info("There is no repository with the given name. Did you spell it correctly?") - self.log.info("Fatal: ") - self.log.info(e) - raise SystemExit + self.log.error("There is no repository with the given name. Did you spell it correctly?") + self.log.error("Fatal: ") + self.log.error(e) + raise SystemExit(1) if not project.name == short_name: - self.log.info("Fatal: ") - self.log.info("Project name is wrong: " + short_name + " it should be: " + project.name) - raise SystemExit + self.log.error("Fatal: ") + self.log.error("Project name is wrong: " + short_name + " it should be: " + project.name) + raise SystemExit(1) super(centpkgClient, self).clone() diff --git a/src/centpkg/lookaside.py b/src/centpkg/lookaside.py index fde0922..4c72c88 100644 --- a/src/centpkg/lookaside.py +++ b/src/centpkg/lookaside.py @@ -101,10 +101,10 @@ class StreamLookasideCache(CGILookasideCache): status = super(StreamLookasideCache, self).remote_file_exists( _name, filename, hashstr) except UploadError as e: - self.log.info('Error checking for %s at %s' + self.log.error('Error checking for %s at %s' % (filename, self.upload_url)) - self.log.info(e) - raise SystemExit + self.log.error(e) + raise SystemExit(1) return status