Skip to content

Commit

Permalink
Merge branch '533' of git://github.com/vitorbaptista/ckan into vitorb…
Browse files Browse the repository at this point in the history
…aptista-533
  • Loading branch information
amercader committed Apr 15, 2013
2 parents 5354769 + b865422 commit deef56f
Show file tree
Hide file tree
Showing 4 changed files with 231 additions and 84 deletions.
107 changes: 54 additions & 53 deletions ckan/lib/cli.py
Expand Up @@ -99,21 +99,21 @@ def _setup_app(self):
class ManageDb(CkanCommand):
'''Perform various tasks on the database.
db create # alias of db upgrade
db init # create and put in default data
db create - alias of db upgrade
db init - create and put in default data
db clean
db upgrade [{version no.}] # Data migrate
db version # returns current version of data schema
db dump {file-path} # dump to a pg_dump file
db dump-rdf {dataset-name} {file-path}
db simple-dump-csv {file-path} # dump just datasets in CSV format
db simple-dump-json {file-path} # dump just datasets in JSON format
db user-dump-csv {file-path} # dump user information to a CSV file
db send-rdf {talis-store} {username} {password}
db load {file-path} # load a pg_dump from a file
db load-only {file-path} # load a pg_dump from a file but don\'t do
# the schema upgrade or search indexing
db create-from-model # create database from the model (indexes not made)
db upgrade [version no.] - Data migrate
db version - returns current version of data schema
db dump FILE_PATH - dump to a pg_dump file
db dump-rdf DATASET_NAME FILE_PATH
db simple-dump-csv FILE_PATH - dump just datasets in CSV format
db simple-dump-json FILE_PATH - dump just datasets in JSON format
db user-dump-csv FILE_PATH - dump user information to a CSV file
db send-rdf TALIS_STORE USERNAME PASSWORD
db load FILE_PATH - load a pg_dump from a file
db load-only FILE_PATH - load a pg_dump from a file but don\'t do
the schema upgrade or search indexing
db create-from-model - create database from the model (indexes not made)
'''
summary = __doc__.split('\n')[0]
usage = __doc__
Expand Down Expand Up @@ -312,10 +312,12 @@ class SearchIndexCommand(CkanCommand):
'''Creates a search index for all datasets
Usage:
search-index [-i] [-o] [-r] [-e] rebuild [dataset-name] - reindex dataset-name if given, if not then rebuild full search index (all datasets)
search-index check - checks for datasets not indexed
search-index show {dataset-name} - shows index of a dataset
search-index clear [dataset-name] - clears the search index for the provided dataset or for the whole ckan instance
search-index [-i] [-o] [-r] [-e] rebuild [dataset_name] - reindex dataset_name if given, if not then rebuild
full search index (all datasets)
search-index check - checks for datasets not indexed
search-index show DATASET_NAME - shows index of a dataset
search-index clear [dataset_name] - clears the search index for the provided dataset or
for the whole ckan instance
'''

summary = __doc__.split('\n')[0]
Expand Down Expand Up @@ -434,7 +436,7 @@ def command(self):


class RDFExport(CkanCommand):
'''
'''Export active datasets as RDF
This command dumps out all currently active datasets as RDF into the
specified folder.
Expand Down Expand Up @@ -498,8 +500,8 @@ class Sysadmin(CkanCommand):
Usage:
sysadmin - lists sysadmins
sysadmin list - lists sysadmins
sysadmin add <user-name> - add a user as a sysadmin
sysadmin remove <user-name> - removes user from sysadmins
sysadmin add USERNAME - add a user as a sysadmin
sysadmin remove USERNAME - removes user from sysadmins
'''

summary = __doc__.split('\n')[0]
Expand Down Expand Up @@ -579,16 +581,16 @@ class UserCmd(CkanCommand):
Usage:
user - lists users
user list - lists users
user <user-name> - shows user properties
user add <user-name> [<field>=<value>]
user USERNAME - shows user properties
user add USERNAME [FIELD1=VALUE1 FIELD2=VALUE2 ...]
- add a user (prompts for password
if not supplied).
Field can be: apikey
password
email
user setpass <user-name> - set user password (prompts)
user remove <user-name> - removes user from users
user search <query> - searches for a user name
user setpass USERNAME - set user password (prompts)
user remove USERNAME - removes user from users
user search QUERY - searches for a user name
'''
summary = __doc__.split('\n')[0]
usage = __doc__
Expand Down Expand Up @@ -735,11 +737,11 @@ class DatasetCmd(CkanCommand):
'''Manage datasets
Usage:
dataset <dataset-name/id> - shows dataset properties
dataset show <dataset-name/id> - shows dataset properties
dataset DATASET_NAME|ID - shows dataset properties
dataset show DATASET_NAME|ID - shows dataset properties
dataset list - lists datasets
dataset delete <dataset-name/id> - changes dataset state to 'deleted'
dataset purge <dataset-name/id> - removes dataset from db entirely
dataset delete [DATASET_NAME|ID] - changes dataset state to 'deleted'
dataset purge [DATASET_NAME|ID] - removes dataset from db entirely
'''
summary = __doc__.split('\n')[0]
usage = __doc__
Expand Down Expand Up @@ -816,12 +818,11 @@ class Celery(CkanCommand):
'''Celery daemon
Usage:
celeryd - run the celery daemon
celeryd run - run the celery daemon
celeryd run concurrency - run the celery daemon with
argument 'concurrency'
celeryd view - view all tasks in the queue
celeryd clean - delete all tasks in the queue
celeryd <run> - run the celery daemon
celeryd run concurrency - run the celery daemon with
argument 'concurrency'
celeryd view - view all tasks in the queue
celeryd clean - delete all tasks in the queue
'''
min_args = 0
max_args = 2
Expand Down Expand Up @@ -940,8 +941,8 @@ class Tracking(CkanCommand):
'''Update tracking statistics
Usage:
tracking update [start-date] - update tracking stats
tracking export <file> [start-date] - export tracking stats to a csv file
tracking update [start_date] - update tracking stats
tracking export FILE [start_date] - export tracking stats to a csv file
'''

summary = __doc__.split('\n')[0]
Expand Down Expand Up @@ -1116,7 +1117,7 @@ def update_tracking(self, engine, summary_date):
engine.execute(sql)

class PluginInfo(CkanCommand):
''' Provide info on installed plugins.
'''Provide info on installed plugins.
'''

summary = __doc__.split('\n')[0]
Expand Down Expand Up @@ -1220,8 +1221,8 @@ class CreateTestDataCommand(CkanCommand):
create-test-data user - create a user 'tester' with api key 'tester'
create-test-data translations - annakarenina, warandpeace, and some test
translations of terms
create-test-data vocabs - annakerenina, warandpeace, and some test
vocabularies
create-test-data vocabs - annakerenina, warandpeace, and some test
vocabularies
'''
summary = __doc__.split('\n')[0]
Expand Down Expand Up @@ -1271,7 +1272,7 @@ class Profile(CkanCommand):
by runsnakerun.
Usage:
profile {url}
profile URL
e.g. profile /data/search
Expand Down Expand Up @@ -1328,15 +1329,15 @@ def profile_url(url):


class CreateColorSchemeCommand(CkanCommand):
''' Create or remove a color scheme.
'''Create or remove a color scheme.
less will need to generate the css files after this has been run
After running this, you'll need to regenerate the css files. See paster's less command for details.
color - creates a random color scheme
color clear - clears any color scheme
color '<hex>' - uses as base color eg '#ff00ff' must be quoted.
color <value> - a float between 0.0 and 1.0 used as base hue
color <color name> - html color name used for base color eg lightblue
color - creates a random color scheme
color clear - clears any color scheme
color <'HEX'> - uses as base color eg '#ff00ff' must be quoted.
color <VALUE> - a float between 0.0 and 1.0 used as base hue
color <COLOR_NAME> - html color name used for base color eg lightblue
'''

summary = __doc__.split('\n')[0]
Expand Down Expand Up @@ -1587,8 +1588,8 @@ def command(self):
class TranslationsCommand(CkanCommand):
'''Translation helper functions
trans js - generate the javascript translations
trans mangle - mangle the zh_TW translations for testing
trans js - generate the javascript translations
trans mangle - mangle the zh_TW translations for testing
'''

summary = __doc__.split('\n')[0]
Expand Down Expand Up @@ -1744,7 +1745,7 @@ class MinifyCommand(CkanCommand):
Usage:
paster minify [--clean] <path>
paster minify [--clean] PATH
for example:
Expand Down Expand Up @@ -1919,7 +1920,7 @@ def compile_less(self, root, less_bin, color):


class FrontEndBuildCommand(CkanCommand):
''' Creates and minifies css and JavaScript files
'''Creates and minifies css and JavaScript files
Usage:
Expand Down
8 changes: 4 additions & 4 deletions ckanext/datastore/commands.py
Expand Up @@ -8,17 +8,17 @@

class SetupDatastoreCommand(cli.CkanCommand):
'''Perform commands to set up the datastore.
Make sure that the datastore urls are set properly before you run these commands.
Make sure that the datastore URLs are set properly before you run these commands.
Usage::
paster datastore set-permissions SQL_SUPER_USER
Where:
SQL_SUPER_USER is the name of a postgres user with sufficient
permissions to create new tables, users, and grant
and revoke new permissions. Typically, this would
be the "postgres" user.
permissions to create new tables, users, and grant
and revoke new permissions. Typically, this would
be the "postgres" user.
'''
summary = __doc__.split('\n')[0]
Expand Down
6 changes: 5 additions & 1 deletion doc/database-dumps.rst
Expand Up @@ -11,6 +11,8 @@ Creating a Dump
We provide two ``paster`` methods to create dumpfiles.

* ``db simple-dump-json`` - A simple dumpfile, useful to create a public listing of the datasets with no user information. All datasets are dumped, including deleted datasets and ones with strict authorization. These may be in JSON or CSV format.
* ``db user-dump-csv`` - It works the same way as simple-dump-json, but dumps the users, instead of datasets.
* ``db dump-rdf`` - A dump of a specific dataset, in RDF format.
* ``db dump`` - A more complicated dumpfile, useful for backups. Replicates the database completely, including users, their personal info and API keys, and hence should be kept private. This is in the format of SQL commands.

For more information on paster, see :doc:`paster`.
Expand All @@ -27,7 +29,9 @@ Then create and zip the dumpfile::
paster --plugin=ckan db simple-dump-json /var/srvc/ckan/dumps/ckan.net-daily.json --config=/etc/ckan/std/std.ini
gzip /var/srvc/ckan/dumps/ckan.net-daily.json

Change ``simple-dump-json`` to ``simple-dump-csv`` if you want CSV format instead of JSON.
Change ``simple-dump-json`` to ``simple-dump-csv`` if you want CSV format instead of JSON.

Use ``user-dump-csv`` if you want a dump of the users instead.

Backing up - db dump
++++++++++++++++++++
Expand Down

0 comments on commit deef56f

Please sign in to comment.