[ckan-changes] commit/ckanext-harvest: amercader: Add new command to create new jobs for all active sources
Bitbucket
commits-noreply at bitbucket.org
Tue Sep 6 17:25:32 UTC 2011
1 new changeset in ckanext-harvest:
http://bitbucket.org/okfn/ckanext-harvest/changeset/24dd54110304/
changeset: 24dd54110304
user: amercader
date: 2011-09-06 19:25:17
summary: Add new command to create new jobs for all active sources
affected #: 3 files (648 bytes)
--- a/README.rst Wed Aug 10 16:25:57 2011 +0100
+++ b/README.rst Tue Sep 06 18:25:17 2011 +0100
@@ -94,6 +94,9 @@
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::
--- a/ckanext/harvest/commands/harvester.py Wed Aug 10 16:25:57 2011 +0100
+++ b/ckanext/harvest/commands/harvester.py Tue Sep 06 18:25:17 2011 +0100
@@ -44,6 +44,9 @@
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 @@
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 @@
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 ''
--- a/ckanext/harvest/lib/__init__.py Wed Aug 10 16:25:57 2011 +0100
+++ b/ckanext/harvest/lib/__init__.py Tue Sep 06 18:25:17 2011 +0100
@@ -377,6 +377,18 @@
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):
Repository URL: https://bitbucket.org/okfn/ckanext-harvest/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list