diff options
author | Baruch Sterin <baruchs@gmail.com> | 2011-10-24 15:21:08 -0700 |
---|---|---|
committer | Baruch Sterin <baruchs@gmail.com> | 2011-10-24 15:21:08 -0700 |
commit | 521ec0fcf93faf213e3ad5346785a85a61560c71 (patch) | |
tree | d8d265bc2aac26ed42fd6e86466015f42c9dd26a | |
parent | 16e12f1852008d477a2340484764b627947b7b38 (diff) | |
download | abc-521ec0fcf93faf213e3ad5346785a85a61560c71.tar.gz abc-521ec0fcf93faf213e3ad5346785a85a61560c71.tar.bz2 abc-521ec0fcf93faf213e3ad5346785a85a61560c71.zip |
pyabc: fix command line parser in reachx_cmx.py and abcpy_test.py
-rw-r--r-- | scripts/reachx_cmd.py | 17 | ||||
-rw-r--r-- | src/python/abcpy_test.py | 2 |
2 files changed, 3 insertions, 16 deletions
diff --git a/scripts/reachx_cmd.py b/scripts/reachx_cmd.py index 0ed2876c..8461cb1d 100644 --- a/scripts/reachx_cmd.py +++ b/scripts/reachx_cmd.py @@ -43,18 +43,6 @@ def popen_and_wait_with_timeout(timeout,cmd, *args, **kwargs): return -1 @contextmanager -def replace_sys_argv(argv): - if 'argv' in sys.__dict__: - old_argv = sys.argv - sys.argv = argv - yield - sys.argv = old_argv - else: - sys.argv = argv - yield - del sys.argv - -@contextmanager def temp_file_name(suffix=""): file = tempfile.NamedTemporaryFile(delete=False, suffix=suffix) name = file.name @@ -105,13 +93,12 @@ def run_reachx_cmd(effort, timeout): def reachx_cmd(argv): usage = "usage: %prog [options]" - parser = optparse.OptionParser(usage) + parser = optparse.OptionParser(usage, prog="reachx") parser.add_option("-e", "--effort", dest="effort", type=int, default=0, help="effort level. [default=0, means unlimited]") parser.add_option("-t", "--timeout", dest="timeout", type=int, default=0, help="timeout in seconds [default=0, unlimited]") - with replace_sys_argv(argv): - options, args = parser.parse_args() + options, args = parser.parse_args(argv) rc = run_reachx_cmd(options.effort, options.timeout) print "%s command: jabc returned: %d"%(argv[0], rc) diff --git a/src/python/abcpy_test.py b/src/python/abcpy_test.py index 912cae9f..28c3505b 100644 --- a/src/python/abcpy_test.py +++ b/src/python/abcpy_test.py @@ -34,7 +34,7 @@ import optparse def pytest3_cmd(args): usage = "usage: %prog [options]" - parser = optparse.OptionParser(usage) + parser = optparse.OptionParser(usage, prog="pytest3") parser.add_option("-c", "--cmd", dest="cmd", help="command to ask help for") parser.add_option("-v", "--version", action="store_true", dest="version", help="display Python Version") |