diff --git a/ckan/lib/cli.py b/ckan/lib/cli.py index 1fc8de336df..f93c39cbb68 100644 --- a/ckan/lib/cli.py +++ b/ckan/lib/cli.py @@ -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__ @@ -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] @@ -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. @@ -498,8 +500,8 @@ class Sysadmin(CkanCommand): Usage: sysadmin - lists sysadmins sysadmin list - lists sysadmins - sysadmin add - add a user as a sysadmin - sysadmin remove - 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] @@ -579,16 +581,16 @@ class UserCmd(CkanCommand): Usage: user - lists users user list - lists users - user - shows user properties - user add [=] + 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 - set user password (prompts) - user remove - removes user from users - user search - 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__ @@ -735,11 +737,11 @@ class DatasetCmd(CkanCommand): '''Manage datasets Usage: - dataset - shows dataset properties - dataset show - shows dataset properties + dataset DATASET_NAME|ID - shows dataset properties + dataset show DATASET_NAME|ID - shows dataset properties dataset list - lists datasets - dataset delete - changes dataset state to 'deleted' - dataset purge - 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__ @@ -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 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 @@ -940,8 +941,8 @@ class Tracking(CkanCommand): '''Update tracking statistics Usage: - tracking update [start-date] - update tracking stats - tracking export [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] @@ -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] @@ -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] @@ -1271,7 +1272,7 @@ class Profile(CkanCommand): by runsnakerun. Usage: - profile {url} + profile URL e.g. profile /data/search @@ -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 '' - uses as base color eg '#ff00ff' must be quoted. - color - a float between 0.0 and 1.0 used as base hue - color - 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 - a float between 0.0 and 1.0 used as base hue + color - html color name used for base color eg lightblue ''' summary = __doc__.split('\n')[0] @@ -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] @@ -1744,7 +1745,7 @@ class MinifyCommand(CkanCommand): Usage: - paster minify [--clean] + paster minify [--clean] PATH for example: @@ -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: diff --git a/ckanext/datastore/commands.py b/ckanext/datastore/commands.py index 364e163eddb..d2cf9c55d54 100644 --- a/ckanext/datastore/commands.py +++ b/ckanext/datastore/commands.py @@ -8,7 +8,7 @@ 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:: @@ -16,9 +16,9 @@ class SetupDatastoreCommand(cli.CkanCommand): 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] diff --git a/doc/database-dumps.rst b/doc/database-dumps.rst index b8200d912d3..edeca20bb73 100644 --- a/doc/database-dumps.rst +++ b/doc/database-dumps.rst @@ -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`. @@ -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 ++++++++++++++++++++ diff --git a/doc/paster.rst b/doc/paster.rst index 43fd3c9e6c7..94e5524e03e 100644 --- a/doc/paster.rst +++ b/doc/paster.rst @@ -1,8 +1,8 @@ .. _paster: -=============================== -Common CKAN Administrator Tasks -=============================== +==================== +CKAN Paster Commands +==================== The majority of common CKAN administration tasks are carried out using the **paster** script. @@ -137,14 +137,26 @@ Common Tasks Using Paster The following tasks are supported by paster. ================= ========================================================== + celeryd Control celery daemon. + check-po-files Check po files for common mistakes + color Create or remove a color scheme. create-test-data Create test data in the database. + dataset Manage datasets. + datastore Perform commands to set up the datastore. db Perform various tasks on the database. + front-end-build Creates and minifies css and JavaScript files + less Compile all root less documents into their CSS counterparts + minify Create minified versions of the given Javascript and CSS files. + notify Send out modification notifications. + plugin-info Provide info on installed plugins. + profile Code speed profiler ratings Manage the ratings stored in the db - rights Commands relating to per-object and system-wide access rights. - roles Commands relating to roles and actions. + rdf-export Export active datasets as RDF. search-index Creates a search index for all datasets - sysadmin Gives sysadmin rights to a named user - user Manage users + sysadmin Gives sysadmin rights to a named user. + tracking Update tracking statistics. + trans Translation helper functions + user Manage users. ================= ========================================================== @@ -153,12 +165,74 @@ For the full list of tasks supported by paster, you can run:: paster --plugin=ckan --help +celeryd: Control celery daemon +------------------------------- + +Usage:: + + celeryd - 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 + + +check-po-files: Check po files for common mistakes +-------------------------------------------------- + +Usage:: + + check-po-files [options] [FILE] ... + + +color: Create or remove a color scheme +-------------------------------------- + +After running this command, you'll need to regenerate the css files. See :ref:`less` for details. + +Usage:: + + color - creates a random color scheme + color clear - clears any color scheme + color <'HEX'> - uses as base color eg '#ff00ff' must be quoted. + color - a float between 0.0 and 1.0 used as base hue + color - html color name used for base color eg lightblue + + create-test-data: Create test data ---------------------------------- As the name suggests, this command lets you load test data when first setting up CKAN. See :ref:`create-test-data` for details. +dataset: Manage datasets +------------------------ + +Usage:: + + 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 + + +datastore: Perform commands to set up the datastore +--------------------------------------------------- + +Make sure that the datastore URLs are set properly before you run these commands. + +Usage:: + + 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. + + db: Manage databases -------------------- @@ -217,38 +291,89 @@ Creating dump files For information on using ``db`` to create dumpfiles, see :doc:`database-dumps`. -ratings: Manage dataset ratings -------------------------------- +front-end-build: Creates and minifies css and JavaScript files +-------------------------------------------------------------- -Manages the ratings stored in the database, and can be used to count ratings, remove all ratings, or remove only anonymous ratings. +Usage:: -For example, to remove anonymous ratings from the database:: + front-end-build - paster --plugin=ckan ratings clean-anonymous --config=/etc/ckan/std/std.ini + +.. _less: + +less: Compile all root less documents into their CSS counterparts +----------------------------------------------------------------- + +Usage:: + + less -rights: Set user permissions +minify: Create minified versions of the given Javascript and CSS files +---------------------------------------------------------------------- + +Usage:: + + paster minify [--clean] PATH + + For example: + + paster minify ckan/public/base + paster minify ckan/public/base/css/*.css + paster minify ckan/public/base/css/red.css + +If the --clean option is provided any minified files will be removed. + + +notify: Send out modification notifications +------------------------------------------- + +Usage:: + + notify replay - send out modification signals. In "replay" mode, + an update signal is sent for each dataset in the database. + + +plugin-info: Provide info on installed plugins +---------------------------------------------- + +As the name suggests, this commands shows you the installed plugins, their description, and which interfaces they implement + + +profile: Code speed profiler ---------------------------- -Sets the authorization roles of a specific user on a given object within the system. +Provide a ckan url and it will make the request and record how long each function call took in a file that can be read +by runsnakerun. -For example, to give the user named 'bar' the 'admin' role on the dataset 'foo':: +Usage:: - paster --plugin=ckan rights make bar admin package:foo --config=/etc/ckan/std/std.ini + profile URL -To list all the rights currently specified:: +The result is saved in profile.data.search. To view the profile in runsnakerun:: - paster --plugin=ckan rights list --config=/etc/ckan/std/std.ini + runsnakerun ckan.data.search.profile -For more information and examples, see :doc:`authorization`. +You may need to install the cProfile python module. -roles: Manage system-wide permissions --------------------------------------- +ratings: Manage dataset ratings +------------------------------- + +Manages the ratings stored in the database, and can be used to count ratings, remove all ratings, or remove only anonymous ratings. + +For example, to remove anonymous ratings from the database:: + + paster --plugin=ckan ratings clean-anonymous --config=/etc/ckan/std/std.ini + + +rdf-export: Export datasets as RDF +---------------------------------- + +This command dumps out all currently active datasets as RDF into the specified folder:: -This important command gives you fine-grained control over CKAN permissions, by listing and modifying the assignment of actions to roles. + paster rdf-export /path/to/store/output -The ``roles`` command has its own section: see :doc:`authorization`. .. _rebuild search index: @@ -279,9 +404,8 @@ won't clear the index before starting rebuilding it:: There are other search related commands, mostly useful for debugging purposes:: 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 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 sysadmin: Give sysadmin rights @@ -294,6 +418,24 @@ For example, to make a user called 'admin' into a sysadmin:: paster --plugin=ckan sysadmin add admin --config=/etc/ckan/std/std.ini +tracking: Update tracking statistics +------------------------------------ + +Usage:: + + tracking update [start_date] - update tracking stats + tracking export FILE [start_date] - export tracking stats to a csv file + + +trans: Translation helper functions +----------------------------------- + +Usage:: + + trans js - generate the javascript translations + trans mangle - mangle the zh_TW translations for testing + + .. _paster-user: user: Create and manage users