[refactoring] Add a command to create the necessary tables in the database
This commit is contained in:
parent
312e9b8209
commit
040e4d6956
68
README.rst
68
README.rst
|
@ -5,28 +5,15 @@ ckanext-harvest - Remote harvesting extension
|
|||
This extension will contain all harvesting related code, now present
|
||||
in ckan core, ckanext-dgu and ckanext-csw.
|
||||
|
||||
Dependencies
|
||||
============
|
||||
|
||||
You will need ckan installed, as well as the ckanext-dgu and ckanext-csw
|
||||
plugins activated.
|
||||
|
||||
Tests
|
||||
=====
|
||||
|
||||
To run the tests, this is the basic command::
|
||||
|
||||
$ nosetests --ckan tests/
|
||||
|
||||
Or with postgres::
|
||||
|
||||
$ nosetests --ckan --with-pylons=../ckan/test-core.ini tests/
|
||||
|
||||
(See the Ckan README for more information.)
|
||||
|
||||
Configuration
|
||||
=============
|
||||
|
||||
Run the following command (in the ckanext-harvest directory) to create
|
||||
the necessary tables in the database::
|
||||
|
||||
paster harvester initdb --config=../ckan/development.ini
|
||||
|
||||
|
||||
The extension needs a user with sysadmin privileges to perform the
|
||||
harvesting jobs. You can create such a user running these two commands in
|
||||
the ckan directory::
|
||||
|
@ -46,32 +33,53 @@ http://localhost:5000/)::
|
|||
|
||||
ckan.api_url = <api_url>
|
||||
|
||||
Tests
|
||||
=====
|
||||
|
||||
To run the tests, this is the basic command::
|
||||
|
||||
$ nosetests --ckan tests/
|
||||
|
||||
Or with postgres::
|
||||
|
||||
$ nosetests --ckan --with-pylons=../ckan/test-core.ini tests/
|
||||
|
||||
(See the Ckan README for more information.)
|
||||
|
||||
|
||||
Command line interface
|
||||
======================
|
||||
|
||||
The following operations can be run from the command line using the
|
||||
``paster harvester`` command::
|
||||
|
||||
harvester source {url} [{user-ref} [{publisher-ref}]]
|
||||
harvester initdb
|
||||
- Creates the necessary tables in the database
|
||||
|
||||
harvester source {url} {type} [{active}] [{user-id}] [{publisher-id}]
|
||||
- create new harvest source
|
||||
|
||||
harvester rmsource {url}
|
||||
- remove a harvester source (and associated jobs)
|
||||
harvester rmsource {id}
|
||||
- remove (inactivate) a harvester source
|
||||
|
||||
harvester sources
|
||||
harvester sources [all]
|
||||
- lists harvest sources
|
||||
If 'all' is defined, it also shows the Inactive sources
|
||||
|
||||
harvester job {source-id} [{user-ref}]
|
||||
- create new harvesting job
|
||||
|
||||
harvester rmjob {job-id}
|
||||
- remove a harvesting job
|
||||
harvester job {source-id}
|
||||
- create new harvest job
|
||||
|
||||
harvester jobs
|
||||
- lists harvesting jobs
|
||||
- lists harvest jobs
|
||||
|
||||
harvester run
|
||||
- runs harvesting jobs
|
||||
- runs harvest jobs
|
||||
|
||||
harvester gather_consumer
|
||||
- starts the consumer for the gathering queue
|
||||
|
||||
harvester fetch_consumer
|
||||
- starts the consumer for the fetching queue
|
||||
|
||||
The commands should be run from the ckanext-harvest directory and expect
|
||||
a development.ini file to be present. Most of the time you will specify
|
||||
|
|
|
@ -10,6 +10,10 @@ class Harvester(CkanCommand):
|
|||
'''Harvests remotely mastered metadata
|
||||
|
||||
Usage:
|
||||
|
||||
harvester initdb
|
||||
- Creates the necessary tables in the database
|
||||
|
||||
harvester source {url} {type} [{active}] [{user-id}] [{publisher-id}]
|
||||
- create new harvest source
|
||||
|
||||
|
@ -78,12 +82,20 @@ class Harvester(CkanCommand):
|
|||
logging.getLogger('amqplib').setLevel(logging.INFO)
|
||||
consumer = get_fetch_consumer()
|
||||
consumer.wait()
|
||||
elif cmd == "initdb":
|
||||
self.initdb()
|
||||
|
||||
else:
|
||||
print 'Command %s not recognized' % cmd
|
||||
|
||||
def _load_config(self):
|
||||
super(Harvester, self)._load_config()
|
||||
|
||||
def initdb(self):
|
||||
from ckanext.harvest.model import setup as db_setup
|
||||
db_setup()
|
||||
|
||||
print 'DB tables created'
|
||||
|
||||
def create_harvest_source(self):
|
||||
|
||||
|
|
Loading…
Reference in New Issue