diff --git a/ckan/lib/flask_cli.py b/ckan/lib/flask_cli.py index 9795733d48a..a15307ce7e9 100644 --- a/ckan/lib/flask_cli.py +++ b/ckan/lib/flask_cli.py @@ -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)