From 6e0259d7a9de49339c5c9099cab1b65aa520b098 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 9 Mar 2015 14:58:31 +0100 Subject: [PATCH] Allow an [extra] section in w.c.s. configuration files --- wcs/ctl/start.py | 2 +- wcs/publisher.py | 8 ++++---- wcs/qommon/ctl.py | 5 +++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/wcs/ctl/start.py b/wcs/ctl/start.py index ddac39d..c486afc 100644 --- a/wcs/ctl/start.py +++ b/wcs/ctl/start.py @@ -71,7 +71,7 @@ class CmdStart(Command): run_kwargs['port'] = int(sub_options.port) run_kwargs['spawn_cron'] = True run_function = qommon.scgi_server.run - publisher.WcsPublisher.configure(self.config, sub_options.extra) + publisher.WcsPublisher.configure(self.config) if sub_options.handler_connection_limit: run_kwargs['handler_connection_limit'] = int(sub_options.handler_connection_limit) elif self.config.has_option('main', 'handler_connection_limit'): diff --git a/wcs/publisher.py b/wcs/publisher.py index 70c5bac..931c5b0 100644 --- a/wcs/publisher.py +++ b/wcs/publisher.py @@ -89,10 +89,10 @@ class WcsPublisher(StubWcsPublisher): return admin get_admin_module = classmethod(get_admin_module) - def configure(cls, config, extra=[]): - for directory in extra: - cls.register_extra_dir(directory) - + def configure(cls, config): + if config.has_section('extra'): + for name, directory in config.items('extra'): + cls.register_extra_dir(directory) if config.has_option("main", "app_dir"): cls.APP_DIR = config.get("main", "app_dir") if config.has_option("main", "data_dir"): diff --git a/wcs/qommon/ctl.py b/wcs/qommon/ctl.py index 0878008..5ee33f1 100644 --- a/wcs/qommon/ctl.py +++ b/wcs/qommon/ctl.py @@ -61,6 +61,11 @@ class Command(object): self.config.set("main", "app_dir", sub_options.app_dir) if sub_options.data_dir: self.config.set("main", "data_dir", sub_options.data_dir) + if sub_options.extra: + if not self.config.has_section('extra'): + self.config.add_section('extra') + for i, extra in enumerate(sub_options.extra): + self.config.set("extra", "cmd_line_extra_%d" % i, extra) return self.execute(base_options, sub_options, args) def parse_args(self, args): -- 2.1.4