Skip to content

Commit

Permalink
Add search index commands
Browse files Browse the repository at this point in the history
  • Loading branch information
tino097 committed Sep 6, 2018
1 parent 75c5121 commit 390ae6a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
9 changes: 3 additions & 6 deletions ckan/cli/__init__.py
Expand Up @@ -24,7 +24,7 @@
help=u'Config file to use (default: development.ini)')


def _load_config(config=None):
def load_config(config=None):

from paste.deploy import appconfig
from paste.script.util.logging_config import fileConfig
Expand All @@ -48,13 +48,10 @@ def _load_config(config=None):
exit(msg)

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

fileConfig(filename)
log.debug(u"Using " + filename)
return appconfig(u'config:' + filename)


load_config = _load_config
3 changes: 2 additions & 1 deletion ckan/cli/cli.py
Expand Up @@ -3,7 +3,7 @@
import os

import click
from ckan.cli import db, server
from ckan.cli import db, server, search_index


@click.group()
Expand All @@ -14,3 +14,4 @@ def ckan(*args, **kwargs):

ckan.add_command(server.run)
ckan.add_command(db.db)
#ckan.add_command(search_index.search)
22 changes: 11 additions & 11 deletions ckan/cli/db.py
Expand Up @@ -4,12 +4,9 @@

import click
from flask import Flask, current_app

from werkzeug.serving import run_simple

from ckan.cli import click_config_option, load_config
from ckan.config.environment import load_environment
from ckan.config.middleware import make_app
from ckan.cli import click_config_option


@click.group(name=u'db', short_help=u'Database commands')
Expand All @@ -23,24 +20,27 @@ def db():
@click_config_option
def initdb(config):
u'''Initialising the database'''
conf = load_config(config)
load_environment(conf.global_conf, conf.local_conf)
# conf = load_config(config)
# load_environment(conf.global_conf, conf.local_conf)
try:
import ckan.model as model
model.repo.init_db()
except Exception as e:
print(e)
print(u'Initialising DB: SUCCESS')

prompt_msg =u'This will delete all of your data!\nDo you want to continue?'

prompt_msg = u'This will delete all of your data!\nDo you want to continue?'


@db.command(u'clean', short_help=u'Clean the database')
@click.help_option(u'-h', u'--help')
@click_config_option
@click.confirmation_option(prompt=prompt_msg)
def cleandb(config):
u'''Cleaning the database'''
conf = load_config(config)
load_environment(conf.global_conf, conf.local_conf)
# conf = load_config(config)
# load_environment(conf.global_conf, conf.local_conf)
try:
import ckan.model as model
model.repo.clean_db()
Expand All @@ -54,8 +54,8 @@ def cleandb(config):
@click_config_option
def updatedb(config):
u'''Upgrading the database'''
conf = load_config(config)
load_environment(conf.global_conf, conf.local_conf)
# conf = load_config(config)
# load_environment(conf.global_conf, conf.local_conf)
try:
import ckan.model as model
model.repo.upgrade_db()
Expand Down

0 comments on commit 390ae6a

Please sign in to comment.