From 3f5e5e4a8fa9118f3d59933de7597a01f76a0dd7 Mon Sep 17 00:00:00 2001 From: Stephane Wirtel Date: Wed, 24 Dec 2008 01:57:34 +0100 Subject: [PATCH] [REF] Cleanup bzr revid: stephane@tinyerp.com-20081224005734-1nyn35skk55hqx6e --- bin/tools/config.py | 57 ++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/bin/tools/config.py b/bin/tools/config.py index 9d3d552a749..d8d507dca03 100644 --- a/bin/tools/config.py +++ b/bin/tools/config.py @@ -88,7 +88,8 @@ class configmanager(object): parser = optparse.OptionParser(version=version) parser.add_option("-c", "--config", dest="config", help="specify alternate config file") - parser.add_option("-s", "--save", action="store_true", dest="save", default=False, help="save configuration to ~/.openerp_serverrc") + parser.add_option("-s", "--save", action="store_true", dest="save", default=False, + help="save configuration to ~/.openerp_serverrc") parser.add_option("--pidfile", dest="pidfile", help="file where the server pid will be stored") parser.add_option("-n", "--interface", dest="interface", help="specify the TCP IP address") @@ -97,19 +98,24 @@ class configmanager(object): parser.add_option("--net_port", dest="netport", help="specify the TCP port for netrpc", type="int") parser.add_option("--no-netrpc", dest="netrpc", action="store_false", default=True, help="disable netrpc") parser.add_option("--no-xmlrpc", dest="xmlrpc", action="store_false", default=True, help="disable xmlrpc") - parser.add_option("-i", "--init", dest="init", help="init a module (use \"all\" for all modules)") - parser.add_option("--without-demo", dest="without_demo", help="load demo data for a module (use \"all\" for all modules)", default=False) - parser.add_option("-u", "--update", dest="update", help="update a module (use \"all\" for all modules)") - parser.add_option("--cache-timeout", dest="cache_timeout", help="set the timeout for the cache system", default=100000, type="int") + parser.add_option("--without-demo", dest="without_demo", + help="load demo data for a module (use \"all\" for all modules)", default=False) + parser.add_option("-u", "--update", dest="update", + help="update a module (use \"all\" for all modules)") + parser.add_option("--cache-timeout", dest="cache_timeout", + help="set the timeout for the cache system", default=100000, type="int") # stops the server from launching after initialization - parser.add_option("--stop-after-init", action="store_true", dest="stop_after_init", default=False, help="stop the server after it initializes") + parser.add_option("--stop-after-init", action="store_true", dest="stop_after_init", default=False, + help="stop the server after it initializes") parser.add_option('--debug', dest='debug_mode', action='store_true', default=False, help='enable debug mode') - parser.add_option("--assert-exit-level", dest='assert_exit_level', type="choice", choices=loglevels.keys(), help="specify the level at which a failed assertion will stop the server. Accepted values: " + str(loglevels.keys())) + parser.add_option("--assert-exit-level", dest='assert_exit_level', type="choice", choices=loglevels.keys(), + help="specify the level at which a failed assertion will stop the server. Accepted values: %s" % (loglevels.keys(),)) if hasSSL: group = optparse.OptionGroup(parser, "SSL Configuration") - group.add_option("-S", "--secure", dest="secure", action="store_true", help="launch server over https instead of http", default=False) + group.add_option("-S", "--secure", dest="secure", action="store_true", + help="launch server over https instead of http", default=False) group.add_option("--cert-file", dest="secure_cert_file", default="server.cert", help="specify the certificate file for the SSL connection") @@ -146,8 +152,10 @@ class configmanager(object): group.add_option("--pg_path", dest="pg_path", help="specify the pg executable path") group.add_option("--db_host", dest="db_host", help="specify the database host") group.add_option("--db_port", dest="db_port", help="specify the database port", type="int") - group.add_option("--db_maxconn", dest="db_maxconn", default='64', help="specify the the maximum number of physical connections to posgresql") - group.add_option("-P", "--import-partial", dest="import_partial", help="Use this for big data importation, if it crashes you will be able to continue at the current state. Provide a filename to store intermediate importation states.", default=False) + group.add_option("--db_maxconn", dest="db_maxconn", default='64', + help="specify the the maximum number of physical connections to posgresql") + group.add_option("-P", "--import-partial", dest="import_partial", + help="Use this for big data importation, if it crashes you will be able to continue at the current state. Provide a filename to store intermediate importation states.", default=False) parser.add_option_group(group) group = optparse.OptionGroup(parser, "Internationalisation options", @@ -156,11 +164,17 @@ class configmanager(object): "Option '-l' is mandatory in case of importation" ) - group.add_option('-l', "--language", dest="language", help="specify the language of the translation file. Use it with --i18n-export or --i18n-import") - group.add_option("--i18n-export", dest="translate_out", help="export all sentences to be translated to a CSV file, a PO file or a TGZ archive and exit") - group.add_option("--i18n-import", dest="translate_in", help="import a CSV or a PO file with translations and exit. The '-l' option is required.") - group.add_option("--modules", dest="translate_modules", help="specify modules to export. Use in combination with --i18n-export") - group.add_option("--addons-path", dest="addons_path", help="specify an alternative addons path.", action="callback", callback=self._check_addons_path, nargs=1, type="string") + group.add_option('-l', "--language", dest="language", + help="specify the language of the translation file. Use it with --i18n-export or --i18n-import") + group.add_option("--i18n-export", dest="translate_out", + help="export all sentences to be translated to a CSV file, a PO file or a TGZ archive and exit") + group.add_option("--i18n-import", dest="translate_in", + help="import a CSV or a PO file with translations and exit. The '-l' option is required.") + group.add_option("--modules", dest="translate_modules", + help="specify modules to export. Use in combination with --i18n-export") + group.add_option("--addons-path", dest="addons_path", + help="specify an alternative addons path.", + action="callback", callback=self._check_addons_path, nargs=1, type="string") parser.add_option_group(group) (opt, args) = parser.parse_args() @@ -220,18 +234,9 @@ class configmanager(object): if not self.options['addons_path'] or self.options['addons_path']=='None': self.options['addons_path'] = os.path.join(self.options['root_path'], 'addons') - init = {} - if opt.init: - for i in opt.init.split(','): - init[i] = 1 - self.options['init'] = init + self.options['init'] = opt.init and dict.fromkeys(opt.init.split(','), 1) or {} self.options["demo"] = not opt.without_demo and self.options['init'] or {} - - update = {} - if opt.update: - for i in opt.update.split(','): - update[i] = 1 - self.options['update'] = update + self.options['update'] = opt.update and dict.fromkeys(opt.update.split(','), 1) or {} self.options['translate_modules'] = opt.translate_modules and map(lambda m: m.strip(), opt.translate_modules.split(',')) or ['all'] self.options['translate_modules'].sort()