diff options
| author | Xavier Morel <xmo@openerp.com> | 2011-09-02 08:39:56 +0200 |
|---|---|---|
| committer | Xavier Morel <xmo@openerp.com> | 2011-09-02 08:39:56 +0200 |
| commit | 55250f10065821ed8326ea384d2efcc0ba4aa575 (patch) | |
| tree | de2dd6803f10d1049dc3688702e2c045e5dbc9d4 | |
| parent | c1fcb132e90675295e4a7afc63d18472e8130f57 (diff) | |
Take options parsing outside of main() function
bzr revid: xmo@openerp.com-20110902063956-dlpnvj27ond11bqr
| -rwxr-xr-x | openerp-web.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/openerp-web.py b/openerp-web.py index e9a4682e4aa..911b8fcafe8 100755 --- a/openerp-web.py +++ b/openerp-web.py @@ -24,7 +24,7 @@ if path_addons not in sys.path: import base -def main(argv): +def main(options): # change the timezone of the program to the OpenERP server's assumed timezone os.environ["TZ"] = "UTC" @@ -35,19 +35,12 @@ def main(argv): 'tools.sessions.timeout': 60 } - # Parse config - (o, args) = optparser.parse_args(argv[1:]) - o = vars(o) - for k in o.keys(): - if o[k] is None: - del(o[k]) - cherrypy.config.update(config=DEFAULT_CONFIG) if os.path.exists(os.path.join(path_root,'openerp-web.cfg')): cherrypy.config.update(os.path.join(path_root,'openerp-web.cfg')) if os.path.exists(os.path.expanduser('~/.openerp_webrc')): cherrypy.config.update(os.path.expanduser('~/.openerp_webrc')) - cherrypy.config.update(o) + cherrypy.config.update(options) if not os.path.exists(cherrypy.config['tools.sessions.storage_path']): os.makedirs(cherrypy.config['tools.sessions.storage_path'], 0700) @@ -55,7 +48,10 @@ def main(argv): return base.common.Root() if __name__ == "__main__": - cherrypy.tree.mount(main(sys.argv)) + (o, args) = optparser.parse_args(sys.argv[1:]) + o = dict((k, v) for k, v in vars(o).iteritems() if v is not None) + + cherrypy.tree.mount(main(o)) cherrypy.server.subscribe() cherrypy.engine.start() cherrypy.engine.block() |
