Add new command to create new jobs for all active sources
This commit is contained in:
parent
dd00e98d9d
commit
c36d9bdd8e
|
@ -94,6 +94,9 @@ The following operations can be run from the command line using the
|
|||
It will only affect the last fetched objects already present in the
|
||||
database.
|
||||
|
||||
harvester job-all
|
||||
- create new harvest jobs for all active sources.
|
||||
|
||||
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
|
||||
the config explicitly though::
|
||||
|
|
|
@ -44,6 +44,9 @@ class Harvester(CkanCommand):
|
|||
Please note that no objects will be fetched from the remote server. It will only affect
|
||||
the last fetched objects already present in the database.
|
||||
|
||||
harvester job-all
|
||||
- create new harvest jobs for all active sources.
|
||||
|
||||
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 the config explicitly though::
|
||||
|
@ -91,6 +94,8 @@ class Harvester(CkanCommand):
|
|||
self.initdb()
|
||||
elif cmd == 'import':
|
||||
self.import_stage()
|
||||
elif cmd == 'job-all':
|
||||
self.create_harvest_job_all()
|
||||
else:
|
||||
print 'Command %s not recognized' % cmd
|
||||
|
||||
|
@ -212,6 +217,10 @@ class Harvester(CkanCommand):
|
|||
source_id = None
|
||||
import_last_objects(source_id)
|
||||
|
||||
def create_harvest_job_all(self):
|
||||
jobs = create_harvest_job_all()
|
||||
print "Created %s new harvest jobs" % len(jobs)
|
||||
|
||||
def print_harvest_sources(self, sources):
|
||||
if sources:
|
||||
print ''
|
||||
|
|
|
@ -377,6 +377,18 @@ def import_last_objects(source_id=None):
|
|||
|
||||
return imported_objects
|
||||
|
||||
def create_harvest_job_all():
|
||||
|
||||
# Get all active sources
|
||||
sources = get_harvest_sources(active=True)
|
||||
jobs = []
|
||||
# Create a new job for each
|
||||
for source in sources:
|
||||
job = create_harvest_job(source['id'])
|
||||
jobs.append(job)
|
||||
|
||||
return jobs
|
||||
|
||||
def get_registered_harvesters_info():
|
||||
available_harvesters = []
|
||||
for harvester in PluginImplementations(IHarvester):
|
||||
|
|
Loading…
Reference in New Issue