Skip to content

Commit

Permalink
pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
tino097 committed Aug 22, 2018
1 parent 0ced794 commit 6faafd4
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions ckan/lib/flask_cli.py
Expand Up @@ -22,45 +22,47 @@ def _load_config(config=None):

if config:
filename = os.path.abspath(config)
config_source = '-c parameter'
elif os.environ.get('CKAN_INI'):
filename = os.environ.get('CKAN_INI')
config_source = '$CKAN_INI'
config_source = u'-c parameter'
elif os.environ.get(u'CKAN_INI'):
filename = os.environ.get(u'CKAN_INI')
config_source = u'$CKAN_INI'
else:
default_filename = 'development.ini'
default_filename = u'development.ini'
filename = os.path.join(os.getcwd(), default_filename)
if not os.path.exists(filename):
# give really clear error message for this common situation
msg = 'ERROR: You need to specify the CKAN config (.ini) '\
'file path.'\
'\nUse the --config parameter or set environment ' \
'variable CKAN_INI or have {}\nin the current directory.' \
msg = u'ERROR: You need to specify the CKAN config (.ini) '\
u'file path.'\
u'\nUse the --config parameter or set environment ' \
u'variable CKAN_INI or have {}\nin the current directory.' \
.format(default_filename)
exit(msg)

if not os.path.exists(filename):
msg = 'Config file not found: %s' % filename
msg += '\n(Given by: %s)' % config_source
msg = u'Config file not found: %s' % filename
msg += u'\n(Given by: %s)' % config_source
exit(msg)

fileConfig(filename)
return appconfig('config:' + filename)
return appconfig(u'config:' + filename)


@click.group()
@click.help_option(u'-h', u'--help')
@click.pass_context
def main(*args, **kwargs):
def main(ctx, *args, **kwargs):
# ctx.obj['CUSTOM_CKAN_DEV_SERVER'] = True
pass


@click.help_option(u'-h', u'--help')
@main.command(u'run', short_help=u'Start development server')
@click.help_option(u'-h', u'--help')
@click_config_option
@click.option(u'-H', u'--host', default=u'localhost', help=u'Set host')
@click.option(u'-p', u'--port', default=5000, help=u'Set port')
@click.option(u'-r', u'--reloader', default=True, help=u'Use reloader')
def run(config, port, reloader):
# click.echo(u'Starting CKAN')
def run(config, host, port, reloader):
'''Runs development server'''
conf = _load_config(config)
app = make_app(conf.global_conf, **conf.local_conf)
run_simple(u'localhost', port, app, use_reloader=reloader, use_evalex=True)
run_simple(host, port, app, use_reloader=reloader, use_evalex=True)

0 comments on commit 6faafd4

Please sign in to comment.