Package: ckanny
# ckanny## Introductionckanny is a [command line interface](#cli) for interacting with remote and local [CKAN](http://ckan.org/) instances. Under the hood, it uses [ckanutils](https://github.com/reubano/ckanutils).With ckanny, you can- Download a CKAN resource- Create a CKAN package- Update a CKAN DataStore from data in the FileStore- Copy a FileStore resource from one CKAN instance to another- and much more...ckanny performs smart updates by computing the hash of a file and will only update the datastore if the file has changed. This allows you to schedule a script to run on a frequent basis, e.g., `@hourly` via a cron job, without updating the CKAN instance unnecessarily.## Requirementsckanny has been tested on the following configuration:- MacOS X 10.9.5- Python 2.7.9ckanny requires the following in order to run properly:- [Python >= 2.7](http://www.python.org/download) (MacOS X comes with python preinstalled)## Installation(You are using a [virtualenv](http://www.virtualenv.org/en/latest/index.html), right?)sudo pip install ckanny## CLIckanny comes with a built in command line interface `ckanny`.### Usageckanny [<namespace>.]<command> [<args>]### Examples*show help*ckanny -h```bashusage: ckanny [<namespace>.]<command> [<args>]positional arguments:command     the command to runoptional arguments:-h, --help  show this help message and exitavailable commands:ver                      Show ckanny version[ds]delete                 Deletes a datastore tableupdate                 Updates a datastore table based on the current filestore resourceupload                 Uploads a file to a datastore table[fs]fetch                  Downloads a filestore resourcemigrate                Copies a filestore resource from one ckan instance to anotherupload                 Updates the filestore of an existing resource or creates a new one[hdx]customize              Introspects custom organization values[pk]create                 Creates a package (aka dataset)```*show version*ckanny ver*fetch a resource*ckanny fs.fetch -k <CKAN_API_KEY> -r <CKAN_URL> <resource_id>*show fs.fetch help*ckanny fs.fetch -h```bashusage: ckanny fs.fetch[-h] [-q] [-n] [-c CHUNKSIZE_BYTES] [-u UA] [-k API_KEY] [-r REMOTE][-d DESTINATION][resource_id]Downloads a filestore resourcepositional arguments:resource_id           the resource idoptional arguments:-h, --help            show this help message and exit-q, --quiet           suppress debug statements-n, --name-from-id    Use resource id for filename-c CHUNKSIZE_BYTES, --chunksize-bytes CHUNKSIZE_BYTESnumber of bytes to read/write at a time (default:1048576)-u UA, --ua UA        the user agent (uses `CKAN_USER_AGENT` ENV ifavailable) (default: None)-k API_KEY, --api-key API_KEYthe api key (uses `CKAN_API_KEY` ENV if available)(default: None)-r REMOTE, --remote REMOTEthe remote ckan url (uses `CKAN_REMOTE_URL` ENV ifavailable) (default: None)-d DESTINATION, --destination DESTINATIONthe destination folder or file path (default:.)```*create a package*ckanny pk.create -k <CKAN_API_KEY> -r <CKAN_URL> <org_id>*create a package with resources*ckanny pk.create -k <CKAN_API_KEY> -r <CKAN_URL> -f 'file1.csv,file2.csv' <org_id>*show pk.create help*ckanny pk.create -h```bashusage: /Users/reubano/.virtualenvs/ckan/bin/ckanny pk.create[-h] [-q] [-u UA] [-k API_KEY][-r REMOTE] [-e END] [-S START][-L LOCATION] [-c CAVEATS] [-y TYPE][-T TAGS] [-t TITLE][-m {observed,other,census,survey,registry}][-d DESCRIPTION] [-f FILES] [-s SOURCE][-l LICENSE_ID][org_id]Creates a package (aka dataset)positional arguments:org_id                the organization idoptional arguments:-h, --help            show this help message and exit-q, --quiet           suppress debug statements-u UA, --ua UAthe user agent (uses `CKAN_USER_AGENT` ENV ifavailable) (default: None)-k API_KEY, --api-key API_KEYthe api key (uses `CKAN_API_KEY` ENV if available)(default: None)-r REMOTE, --remote REMOTEthe remote ckan url (uses `CKAN_REMOTE_URL` ENV ifavailable) (default: None)-e END, --end ENDData end date-S START, --start STARTData start date (default: 09/25/2015)-L LOCATION, --location LOCATIONLocation the data represents (default: world)-c CAVEATS, --caveats CAVEATSPackage caveats-y TYPE, --type TYPEPackage type (default: dataset)-T TAGS, --tags TAGSComma separated list of tags-t TITLE, --title TITLEPackage title (default: Untitled 2015-09-2512:36:14.141533)-m {observed,other,census,survey,registry}, --methodology {observed,other,census,survey,registry}Data collection methodology (default: observed)-d DESCRIPTION, --description DESCRIPTIONDataset description (default: same as `title`)-f FILES, --files FILESComma separated list of file paths to add-s SOURCE, --source SOURCEData source (default: Multiple sources)-l LICENSE_ID, --license-id LICENSE_IDData license (default: cc-by-igo)```## Configurationckanny will use the following [Environment Variables](http://www.cyberciti.biz/faq/set-environment-variable-linux/) if set:Environment Variable|Description--------------------|-----------CKAN_API_KEY|Your CKAN API KeyCKAN_REMOTE_URL|Your CKAN instance remote urlCKAN_USER_AGENT|Your user agent## Hash TableIn order to support file hashing, ckanny creates a hash table resource called `hash_table.csv` with the following schema:field|type------|----datastore_id|texthash|textBy default the hash table resource will be placed in the package `hash_table`. ckanny will create this package if it doesn't exist. Optionally, you can set the hash table package in the command line with the `-H, --hash-table` option, or in a Python file as the `hash_table` keyword argument to `CKAN`.Example:ckanny ds.update -H custom_hash_table 36f33846-cb43-438e-95fd-f518104a32ed## Scriptsckanny comes with a built in task manager `manage.py` and a `Makefile`.### Setuppip install -r dev-requirements.txt### Examples*Run python linter and nose tests*```bashmanage lintmanage test```Or if `make` is more your speed...```bashmake lintmake test```## ContributingView [CONTRIBUTING.rst](https://github.com/reubano/ckanny/blob/master/CONTRIBUTING.rst)## Licenseckanny is distributed under the [MIT License](http://opensource.org/licenses/MIT), the same as [ckanutils](https://github.com/reubano/ckanutils).=========Changelog=========Here you can find the recent changes to ckanny.... changelog:::version: dev:released: Ongoing.. change:::tags:  docsUpdated CHANGES... changelog:::version: 0.1.0:released: 2015-06-12.. change:::tags: projectFirst release on PyPi... todo:: vim: set filetype=rst: