From fd54e0eca9a8ddcfae00fc50f119de0299a3c420 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 12 Aug 2010 20:49:45 +0200 Subject: [PATCH] add an options parser. only handles verbosity for now. --- nephilim.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nephilim.py b/nephilim.py index e0780cb..aa86fe6 100755 --- a/nephilim.py +++ b/nephilim.py @@ -23,6 +23,7 @@ import sys import logging from traceback import print_exc +from optparse import OptionParser try: import sip sip.setapi('QString', 2) @@ -33,13 +34,20 @@ except ImportError: from nephilim.nephilim_app import NephilimApp def main(): - logging.basicConfig(level = logging.WARNING) + # parse cmdline options + parser = OptionParser() + parser.add_option('-v', '--verbose', default = 'warning', choices = ['debug', 'info', + 'warning', 'error', 'critical'], help = 'Set verbosity level.') + + options, args = parser.parse_args() + logging.basicConfig(level = logging.__getattribute__(options.verbose.upper())) + try: app = NephilimApp(sys.argv) app.exec_() app.quit() - except Exception, e: + except: print_exc() if __name__ == "__main__": -- 2.11.4.GIT