Skip to content

Commit

Permalink
[fix][s]: Adds bypass to requirement of a pre-existing config file
Browse files Browse the repository at this point in the history
  • Loading branch information
mpolidori committed Dec 27, 2019
1 parent f67d450 commit 1a29732
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions ckan/cli/cli.py
@@ -1,6 +1,7 @@
# encoding: utf-8

import logging
import sys

import click
from ckan.cli import config_tool
Expand Down Expand Up @@ -43,6 +44,10 @@ def __init__(self, conf=None):
@click_config_option
@click.pass_context
def ckan(ctx, config, *args, **kwargs):
# This is necessary to allow the user to create
# a config file when one isn't already present
if all(arg in sys.argv for arg in ['generate', 'config']):
return
ctx.obj = CkanCommand(config)


Expand Down
11 changes: 7 additions & 4 deletions ckan/cli/generate.py
Expand Up @@ -83,13 +83,17 @@ def extension(output_dir):

@generate.command(name=u'config', short_help=u'Create config from template.')
@click.option(u'-o', u'--output-dir', help=u'Location to put the generated '
u'template.', default=u'.')
u'template.')
def make_config(output_dir):
if not any(name in output_dir for name in
['development.ini', 'production.ini']):
names = ['development.ini', 'production.ini']

if not any(name in output_dir for name in names):
print('\nERROR: File name must be development.ini or production.ini')
sys.exit(1)

if output_dir in names:
output_dir = os.getcwd() + '/' + output_dir

cur_loc = os.path.dirname(os.path.abspath(__file__))
os.chdir(cur_loc)
os.chdir('../config')
Expand All @@ -103,7 +107,6 @@ def make_config(output_dir):

with open(template_loc, 'r') as file_in:
template = string.Template(file_in.read())
print(output_dir)

try:
with open(output_dir, 'w') as file_out:
Expand Down

0 comments on commit 1a29732

Please sign in to comment.