backend/satellite_tools/reports.py | 8 +++++++- backend/satellite_tools/spacewalk-report | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-)
New commits: commit ef07ee5b797ffa6f038580c0a207aa4a53851cee Author: Jan Pazdziora jpazdziora@redhat.com Date: Thu Jul 23 16:01:50 2009 +0200
reporting: after having parsed the common options, put the rest back to sys.argv.
Note that we use disable_interspersed_args() so that the report name and any repo-specific parameters are still unprocessed.
diff --git a/backend/satellite_tools/spacewalk-report b/backend/satellite_tools/spacewalk-report index 973f5f0..c0aa875 100755 --- a/backend/satellite_tools/spacewalk-report +++ b/backend/satellite_tools/spacewalk-report @@ -63,6 +63,8 @@ def processCommandline(): optionParser.disable_interspersed_args() options, args = optionParser.parse_args()
+ sys.argv[1:] = args + return options
commit 216c7bebb1f1cb2d00b210dfdda04491feda051b Author: Jan Pazdziora jpazdziora@redhat.com Date: Thu Jul 23 15:59:46 2009 +0200
reporting: show error message when unknown report is specified.
diff --git a/backend/satellite_tools/reports.py b/backend/satellite_tools/reports.py index a8afd2c..b584347 100644 --- a/backend/satellite_tools/reports.py +++ b/backend/satellite_tools/reports.py @@ -15,7 +15,10 @@ class report: self._load(full_path)
def _load(self, full_path): - fd = open(full_path, 'r') + try: + fd = open(full_path, 'r') + except (IOError): + raise spacewalk_unknown_report tag = None value = '' re_comment = re.compile('^\s*#') @@ -48,6 +51,9 @@ class report: raise spacewalk_report_unknown_tag_exception(tag)
+class spacewalk_unknown_report(Exception): + pass + class spacewalk_report_unknown_tag_exception(Exception): pass
diff --git a/backend/satellite_tools/spacewalk-report b/backend/satellite_tools/spacewalk-report index 80f0386..973f5f0 100755 --- a/backend/satellite_tools/spacewalk-report +++ b/backend/satellite_tools/spacewalk-report @@ -74,7 +74,10 @@ if __name__ == '__main__': initCFG('server') rhnSQL.initDB(options.db)
- report = reports.report(sys.argv[1]) + try: + report = reports.report(sys.argv[1]) + except(reports.spacewalk_unknown_report): + systemExit(-4, 'Unknown report [%s].' % sys.argv[1]) writer = csv.writer(sys.stdout)
h = rhnSQL.prepare(report.sql)
spacewalk-commits@lists.fedorahosted.org