From 1b7eb022251fca905c1de4767c72a7fda4d3f228 Mon Sep 17 00:00:00 2001 From: Ross Jones Date: Thu, 13 Mar 2014 15:12:54 +0000 Subject: [PATCH] [1597] Allows use of environment var for specifying config file. Implements #1597 If you don't specify a config file using the -c option, CKAN defaults to looking for development.ini in the current directory. This patch will first check the -c parameter, and if it doesn't find it will use the content of the CKAN_INI environment variable. If it cannot find that, it will then default to development.ini in the current directory. This does not work with paster serve as this is handled by pastescript which specifically requires the -c paramter. --- ckan/lib/cli.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ckan/lib/cli.py b/ckan/lib/cli.py index 117ebfacd06..bd68c23e3c1 100644 --- a/ckan/lib/cli.py +++ b/ckan/lib/cli.py @@ -80,12 +80,17 @@ class CkanCommand(paste.script.command.Command): def _get_config(self): from paste.deploy import appconfig - if not self.options.config: - msg = 'No config file supplied' - raise self.BadCommand(msg) - self.filename = os.path.abspath(self.options.config) + + self.filename = os.environ.get('CKAN_INI', + os.path.abspath('development.ini')) + + if self.options.config: + self.filename = os.path.abspath(self.options.config) + if not os.path.exists(self.filename): - raise AssertionError('Config filename %r does not exist.' % self.filename) + msg = 'No config file supplied or found in $CKAN_INI' + raise self.BadCommand(msg) + fileConfig(self.filename) return appconfig('config:' + self.filename) @@ -389,7 +394,7 @@ class SearchIndexCommand(CkanCommand): Usage: search-index [-i] [-o] [-r] [-e] rebuild [dataset_name] - reindex dataset_name if given, if not then rebuild full search index (all datasets) - search-index rebuild_fast - reindex using multiprocessing using all cores. + search-index rebuild_fast - reindex using multiprocessing using all cores. This acts in the same way as rubuild -r [EXPERIMENTAL] search-index check - checks for datasets not indexed search-index show DATASET_NAME - shows index of a dataset