Skip to content
Snippets Groups Projects

Add parameter to specify configuration section to load for databases_provider

Merged Samuel GAIST requested to merge improve_database_executor into master
1 file
+ 23
5
Compare changes
  • Side-by-side
  • Inline
@@ -29,15 +29,16 @@
"""Executes some database views. (%(version)s)
usage:
%(prog)s [--debug] <addr> <dir> <cache>
%(prog)s [--debug] <addr> <dir> <cache> [<conf_name>]
%(prog)s (--help)
%(prog)s (--version)
arguments:
<addr> Listen for incoming request on this address ('host:port')
<dir> Directory containing all configuration required to run the views
<cache> Path to the cache
<addr> Listen for incoming request on this address ('host:port')
<dir> Directory containing all configuration required to run the views
<cache> Path to the cache
<conf_name> Name of the configuration to load
options:
@@ -55,6 +56,7 @@ import docopt
import simplejson
import pwd
import stat
import json
import zmq
@@ -167,10 +169,26 @@ def main(arguments=None):
database_cache = {}
try:
configuration_path = os.path.join(args['<dir>'], 'configuration.json')
if not os.path.exists(configuration_path):
raise RuntimeError("Configuration file '%s' not found" %
configuration_path)
with open(configuration_path) as f:
configuration_data = json.load(f)
configuration_name = args.get('<conf_name>', None)
if configuration_name is not None:
configuration_data = configuration_data.get(configuration_name,
None)
if configuration_data is None:
raise RuntimeError("Configuration section '%s' not found" %
configuration_name)
dbexecutor = DBExecutor(message_handler,
os.path.join(args['<dir>'], 'prefix'),
args['<cache>'],
os.path.join(args['<dir>'], 'configuration.json'),
configuration_data,
dataformat_cache,
database_cache)
except (MemoryError):
Loading