Description of problem: The subscription-manager status --ondate with a past date in valid format is throwing the wrong error. This appears to work on rhel6 and rhel7, but is failing on rhel5.11. Version-Release number of selected component (if applicable): [root@jsefler-5 ~]# subscription-manager version server type: This system is currently not registered. subscription management server: 0.9.10-1 subscription-manager: 1.11.3-1.git.12.94c021f.el5 python-rhsm: 1.11.3-2.git.0.5968608.el5 How reproducible: Steps to Reproduce: [root@jsefler-5 ~]# subscription-manager status --ondate=2000-01-01 Past dates are not allowed Date entered is invalid. Date should be in YYYY-MM-DD format (example: 2014-04-29 ) Actual results: above Expected results: should not have been told the format is wrong Additional info:
This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux release. Product Management has requested further review of this request by Red Hat Engineering, for potential inclusion in a Red Hat Enterprise Linux release for currently deployed products. This request is not yet committed for inclusion in a release.
The python 2.4 sys.exit/Exception this seems to be in play here. if self.options.on_date: try: # doing it this ugly way for pre python 2.5 on_date = datetime.datetime( *(strptime(self.options.on_date, '%Y-%m-%d')[0:6])) if on_date.date() < datetime.datetime.now().date(): print (_("Past dates are not allowed")) sys.exit(1) self.sorter = ComplianceManager(on_date) except Exception: print(_("Date entered is invalid. Date should be in YYYY-MM-DD format (example: ") + strftime("%Y-%> sys.exit(1) The first system.exit() raise SystemExit, which the "except Exception" will catch it, show the "Date entered is invalid. Date should be..." error, and sys.exit again. Could either check exception type is not SystemExit in the handler, or change to avoid the earlier sys.exit(). Or figure out a more specific exceptions to catch in stead of "Exception".
except StandardError instead of except Exception would probably work
commit 4a716dfe6997846afb8769cb99343c6054a917b5 Author: Carter Kozak <ckozak> Date: Tue Apr 29 10:42:14 2014 -0400 1092594: don't catch SystemExit for past dates in "status --ondate=x"
Version: # subscription-manager version server type: Red Hat Subscription Management subscription management server: 0.9.12-1 subscription-manager: 1.11.3-3.el5 python-rhsm: 1.11.3-3.el5 Verfication: Past Date: # subscription-manager status --ondate=2008-02-29 Past dates are not allowed Present date: # subscription-manager status --ondate=2014-05-21 +-------------------------------------------+ System Status Details +-------------------------------------------+ Overall Status: Current Future Date: # subscription-manager status --ondate=2016-02-29 +-------------------------------------------+ System Status Details +-------------------------------------------+ Overall Status: Current Invalid Dates: # subscription-manager status --ondate=2017-04-31 Date entered is invalid. Date should be in YYYY-MM-DD format (example: 2014-05-21 ) # subscription-manager status --ondate=2017-02-29 Date entered is invalid. Date should be in YYYY-MM-DD format (example: 2014-05-21 ) VERIFIED
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2014-1225.html