Commit f30efe43 authored by Nicolas Delaby's avatar Nicolas Delaby

According python documentation:

"optparse is a more convenient, flexible, and powerful library for parsing command-line options than the old getopt module. "
get rid of getopt

Obviously --server_cloudooo_conf is not an option but mandatory

Remove unused Option log_path.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@42047 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1963d1a2
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import sys import sys
import unittest import unittest
from getopt import getopt, GetoptError from optparse import OptionParser
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
...@@ -55,48 +55,37 @@ def run_test(test_name): ...@@ -55,48 +55,37 @@ def run_test(test_name):
def run(): def run():
DAEMON = OPENOFFICE = XVFB = False usage = "usage: %prog [options] server_cloudooo_conf Unit_Test_Name"
try: parser = OptionParser(usage=usage)
opt_list, arg_list = getopt(sys.argv[1:], "h", ["help", parser.add_option('-w', '--with-daemon', dest='DAEMON',
"with-daemon", action='store_true')
"with-openoffice", parser.add_option('-o', '--with-openoffice', dest='OPENOFFICE',
"with-xvfb", action='store_true')
"log_path=", parser.add_option('-x', '--with-xvfb', dest='XVFB',
"cloudooo_runner=", action='store_true')
"server_cloudooo_conf=", parser.add_option('-t', '--timeout_limit', dest='timeout_limit',
"timeout_limit=", type="long", default=30)
"paster_path="]) parser.add_option('-p', '--paster_path', dest='paster_path',
except GetoptError, msg: default='paster')
exit(msg.msg) options_instance, argument_list = parser.parse_args()
if len(argument_list) != 2:
paster_path = "paster" parser.error("incorrect number of arguments")
for opt, arg in opt_list: server_cloudooo_conf, test_name = argument_list
if opt in ("-h", "--help"): if server_cloudooo_conf.startswith(curdir):
print >> sys.stderr, __doc__ % {"program": path.basename(sys.argv[0])} server_cloudooo_conf = path.join(path.abspath(curdir),
sys.exit(2) server_cloudooo_conf)
if opt == "--with-daemon":
DAEMON = True DAEMON = options_instance.DAEMON
elif opt == "--with-openoffice": OPENOFFICE = options_instance.OPENOFFICE
OPENOFFICE = True XVFB = options_instance.XVFB
elif opt == "--with-xvfb": paster_path = options_instance.paster_path
XVFB = True
elif opt == "--log_path": python_extension = '.py'
log_path = arg if test_name[-3:] == python_extension:
elif opt == "--cloudooo_runner": test_name = test_name[:-3]
cloudooo_runner = arg if not path.exists(path.join(ENVIRONMENT_PATH,
elif opt == "--server_cloudooo_conf": '%s%s' % (test_name, python_extension))):
if arg.startswith(curdir):
arg = path.join(path.abspath(curdir), arg)
server_cloudooo_conf = arg
environ["server_cloudooo_conf"] = arg
elif opt == "--timeout_limit":
timeout_limit = arg
elif opt == "--paster_path":
paster_path = arg
test_name = sys.argv[-1]
if not path.exists(path.join(ENVIRONMENT_PATH, '%s.py' % test_name)):
exit("%s not exists\n" % test_name) exit("%s not exists\n" % test_name)
from cloudoooTestCase import loadConfig, startFakeEnvironment, stopFakeEnvironment from cloudoooTestCase import loadConfig, startFakeEnvironment, stopFakeEnvironment
......
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