[Erp5-report] r42047 nicolas - /erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu Jan 6 10:41:27 CET 2011
Author: nicolas
Date: Thu Jan 6 10:41:27 2011
New Revision: 42047
URL: http://svn.erp5.org?rev=42047&view=rev
Log:
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.
Modified:
erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/runCloudOOoUnitTest.py
Modified: erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/runCloudOOoUnitTest.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/runCloudOOoUnitTest.py?rev=42047&r1=42046&r2=42047&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/runCloudOOoUnitTest.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/handler/ooo/tests/runCloudOOoUnitTest.py [utf8] Thu Jan 6 10:41:27 2011
@@ -2,7 +2,7 @@
import sys
import unittest
-from getopt import getopt, GetoptError
+from optparse import OptionParser
from time import sleep
from cloudooo.handler.ooo.utils.utils import socketStatus
from ConfigParser import ConfigParser
@@ -55,48 +55,37 @@ def run_test(test_name):
def run():
- DAEMON = OPENOFFICE = XVFB = False
- try:
- opt_list, arg_list = getopt(sys.argv[1:], "h", ["help",
- "with-daemon",
- "with-openoffice",
- "with-xvfb",
- "log_path=",
- "cloudooo_runner=",
- "server_cloudooo_conf=",
- "timeout_limit=",
- "paster_path="])
- except GetoptError, msg:
- exit(msg.msg)
-
- paster_path = "paster"
-
- for opt, arg in opt_list:
- if opt in ("-h", "--help"):
- print >> sys.stderr, __doc__ % {"program": path.basename(sys.argv[0])}
- sys.exit(2)
- if opt == "--with-daemon":
- DAEMON = True
- elif opt == "--with-openoffice":
- OPENOFFICE = True
- elif opt == "--with-xvfb":
- XVFB = True
- elif opt == "--log_path":
- log_path = arg
- elif opt == "--cloudooo_runner":
- cloudooo_runner = arg
- elif opt == "--server_cloudooo_conf":
- 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)):
+ usage = "usage: %prog [options] server_cloudooo_conf Unit_Test_Name"
+ parser = OptionParser(usage=usage)
+ parser.add_option('-w', '--with-daemon', dest='DAEMON',
+ action='store_true')
+ parser.add_option('-o', '--with-openoffice', dest='OPENOFFICE',
+ action='store_true')
+ parser.add_option('-x', '--with-xvfb', dest='XVFB',
+ action='store_true')
+ parser.add_option('-t', '--timeout_limit', dest='timeout_limit',
+ type="long", default=30)
+ parser.add_option('-p', '--paster_path', dest='paster_path',
+ default='paster')
+ options_instance, argument_list = parser.parse_args()
+ if len(argument_list) != 2:
+ parser.error("incorrect number of arguments")
+
+ server_cloudooo_conf, test_name = argument_list
+ if server_cloudooo_conf.startswith(curdir):
+ server_cloudooo_conf = path.join(path.abspath(curdir),
+ server_cloudooo_conf)
+
+ DAEMON = options_instance.DAEMON
+ OPENOFFICE = options_instance.OPENOFFICE
+ XVFB = options_instance.XVFB
+ paster_path = options_instance.paster_path
+
+ python_extension = '.py'
+ if test_name[-3:] == python_extension:
+ test_name = test_name[:-3]
+ if not path.exists(path.join(ENVIRONMENT_PATH,
+ '%s%s' % (test_name, python_extension))):
exit("%s not exists\n" % test_name)
from cloudoooTestCase import loadConfig, startFakeEnvironment, stopFakeEnvironment
More information about the Erp5-report
mailing list