Mercurial > sqlpython
changeset 408:80413ef3699a
going to take optparse out of __main__
author | catherine@DellZilla |
---|---|
date | Thu, 15 Oct 2009 14:30:32 -0400 |
parents | 188c86d4a11e |
children | 5b88ce5f31ff |
files | sqlpython/mysqlpy.py |
diffstat | 1 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/sqlpython/mysqlpy.py Wed Oct 14 13:57:29 2009 -0400 +++ b/sqlpython/mysqlpy.py Thu Oct 15 14:30:32 2009 -0400 @@ -185,6 +185,7 @@ def run(): my=mysqlpy() print my.__doc__ + # Arguments to sqlpython: <connection info> (optional) try: if sys.argv[1][0] != '@': connectstring = sys.argv.pop(1) @@ -205,11 +206,14 @@ if __name__ == '__main__': parser = optparse.OptionParser() parser.add_option('-t', '--test', dest='unittests', action='store_true', default=False, help='Run unit test suite') - (callopts, callargs) = parser.parse_args() - if callopts.unittests: - mysqlpy.testfiles = callargs - sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main() - unittest.main() + try: + (callopts, callargs) = parser.parse_args() + if callopts.unittests: + mysqlpy.testfiles = callargs + sys.argv = [sys.argv[0]] # the --test argument upsets unittest.main() + unittest.main() + except optparse.BadOptionError: + pass else: #import cProfile, pstats #cProfile.run('run()', 'stats.txt')