Commit 5ece888e authored by Nicolas Delaby's avatar Nicolas Delaby

argparse deprecate optparse

Argmument handling is even more easy than before.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@42051 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 36cd997d
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import sys import sys
import unittest import unittest
from optparse import OptionParser from argparse import ArgumentParser
from time import sleep from time import sleep
from cloudooo.handler.ooo.utils.utils import socketStatus from cloudooo.handler.ooo.utils.utils import socketStatus
from ConfigParser import ConfigParser from ConfigParser import ConfigParser
...@@ -56,31 +56,31 @@ def run_test(test_name): ...@@ -56,31 +56,31 @@ def run_test(test_name):
def run(): def run():
usage = "usage: %prog [options] server_cloudooo_conf Unit_Test_Name" parser = ArgumentParser()
parser = OptionParser(usage=usage) parser.add_argument('server_cloudooo_conf')
parser.add_option('-w', '--with-daemon', dest='DAEMON', parser.add_argument('test_name')
action='store_true') parser.add_argument('--with-daemon', dest='DAEMON',
parser.add_option('-o', '--with-openoffice', dest='OPENOFFICE', action='store_true')
action='store_true') parser.add_argument('--with-openoffice', dest='OPENOFFICE',
parser.add_option('-x', '--with-xvfb', dest='XVFB', action='store_true')
action='store_true') parser.add_argument('--with-xvfb', dest='XVFB',
parser.add_option('-t', '--timeout_limit', dest='timeout_limit', action='store_true')
type="long", default=30) parser.add_argument('--timeout_limit', dest='timeout_limit',
parser.add_option('-p', '--paster_path', dest='paster_path', type=long, default=30)
default='paster') parser.add_argument('--paster_path', dest='paster_path',
options_instance, argument_list = parser.parse_args() default='paster')
if len(argument_list) != 2: namespace = parser.parse_args()
parser.error("incorrect number of arguments")
server_cloudooo_conf = namespace.server_cloudooo_conf
server_cloudooo_conf, test_name = argument_list test_name = namespace.test_name
if server_cloudooo_conf.startswith(curdir): if server_cloudooo_conf.startswith(curdir):
server_cloudooo_conf = path.join(path.abspath(curdir), server_cloudooo_conf = path.join(path.abspath(curdir),
server_cloudooo_conf) server_cloudooo_conf)
DAEMON = options_instance.DAEMON DAEMON = namespace.DAEMON
OPENOFFICE = options_instance.OPENOFFICE OPENOFFICE = namespace.OPENOFFICE
XVFB = options_instance.XVFB XVFB = namespace.XVFB
paster_path = options_instance.paster_path paster_path = namespace.paster_path
python_extension = '.py' python_extension = '.py'
if test_name[-3:] == python_extension: if test_name[-3:] == python_extension:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment