From 5e99eb1c69c03f002eae1d4fab639367014c8879 Mon Sep 17 00:00:00 2001 From: Michael Polidori Date: Wed, 22 Jan 2020 09:00:55 -0500 Subject: [PATCH] [fix][s]: Move config check due to master changes and change config file name --- ckan/cli/cli.py | 7 +++++++ ckan/cli/generate.py | 11 ++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ckan/cli/cli.py b/ckan/cli/cli.py index 2d7fd787079..5797eacbf76 100644 --- a/ckan/cli/cli.py +++ b/ckan/cli/cli.py @@ -5,6 +5,7 @@ import six import click +import sys import ckan.plugins as p from ckan.config.middleware import make_app @@ -44,6 +45,12 @@ def __init__(self, conf=None): def _init_ckan_config(ctx, param, value): + + # This is necessary to allow the user to create + # a config file when one isn't already present + if len(sys.argv) > 1 and sys.argv[1] == 'generate' and not value: + return + ctx.obj = CkanCommand(value) if six.PY2: ctx.meta["flask_app"] = ctx.obj.app.apps["flask_app"]._wsgi_app diff --git a/ckan/cli/generate.py b/ckan/cli/generate.py index f47c23b2632..d33afd9d649 100644 --- a/ckan/cli/generate.py +++ b/ckan/cli/generate.py @@ -87,16 +87,17 @@ def extension(output_dir): u'template.') def make_config(output_dir): if output_dir is None: - print('\nERROR: Try again with \'-o path/to/file.ini\'') + print('\nERROR: Try again with \'-o path/to/ckan.ini\'') sys.exit(1) - names = ['development.ini', 'production.ini'] + name = 'ckan.ini' - if not any(name in output_dir for name in names): - print('\nERROR: File name must be development.ini or production.ini') + if name not in output_dir: + print('\nERROR: Config file must be named "ckan.ini"') sys.exit(1) - if output_dir in names: + # Output to current directory if no path is specified + if output_dir == name: output_dir = os.getcwd() + '/' + output_dir cur_loc = os.path.dirname(os.path.abspath(__file__))