Skip to content

Commit

Permalink
[#1597] Refactored for code clarity and improved error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Read committed Nov 13, 2014
1 parent ba51a43 commit 44c8c7c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ckan/lib/cli.py
Expand Up @@ -117,16 +117,19 @@ class CkanCommand(paste.script.command.Command):
def _get_config(self):
from paste.deploy import appconfig

self.filename = os.environ.get('CKAN_INI')

if self.options.config:
self.filename = os.path.abspath(self.options.config)

if not self.filename:
config_source = '-c parameter'
elif os.environ.get('CKAN_INI'):
self.filename = os.environ.get('CKAN_INI')
config_source = '$CKAN_INI'
else:
self.filename = 'development.ini'
config_source = 'default value'

if not os.path.exists(self.filename):
msg = 'No config file found and not specified in $CKAN_INI'
msg = 'Config file not found: %s' % self.filename
msg += '\n(Given by: %s)' % config_source
raise self.BadCommand(msg)

fileConfig(self.filename)
Expand Down

0 comments on commit 44c8c7c

Please sign in to comment.