Skip to content

Commit

Permalink
Run command working
Browse files Browse the repository at this point in the history
  • Loading branch information
tino097 committed Aug 21, 2018
1 parent d1940a8 commit 4ef766f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
1 change: 1 addition & 0 deletions ckan/config/middleware/__init__.py
Expand Up @@ -53,6 +53,7 @@ def make_app(conf, full_stack=True, static_files=True, **app_conf):
middleware.
'''

import pdb; pdb.set_trace()
load_environment(conf, app_conf)

pylons_app = make_pylons_stack(conf, full_stack, static_files,
Expand Down
53 changes: 42 additions & 11 deletions ckan/lib/flask_cli.py
Expand Up @@ -4,7 +4,7 @@

import click
from flask import Flask, current_app
from flask.cli import FlaskGroup, with_appcontext
from flask.cli import AppGroup, with_appcontext
from werkzeug.serving import run_simple

from ckan.common import config
Expand All @@ -17,19 +17,50 @@

def _load_config(config=None):

# app = make_app
# app.config.from_file
# return app
pass
from paste.deploy import appconfig
from paste.script.util.logging_config import fileConfig

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'
else:
default_filename = '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.' \
.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
exit(msg)

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

def _helper():
print('nothing')

@click.group()
@click.help_option(u'-h', u'--help')
@click.pass_context
def main(*args, **kwargs):
pass


@click.help_option(u'-h', u'--help')
@main.command(u'run', short_help=u'Start development server')
@click_config_option
def run():
# app = _load_config(config)
click.echo('Starting CKAN')
run_simple('localhost', 5000, make_app, use_reloader=True, use_evalex=True)
@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')
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)
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -77,7 +77,7 @@ def parse_version(s):
'jobs = ckan.lib.cli:JobsCommand',
],
'console_scripts': [
'ckan = ckan.lib.flask_cli:run',
'ckan = ckan.lib.flask_cli:main',
'ckan-admin = bin.ckan_admin:Command',
],
'paste.paster_create_template': [
Expand Down

0 comments on commit 4ef766f

Please sign in to comment.