Expose clear harvester source as a paster command

This commit is contained in:
Stefan Oderbolz 2015-06-10 11:19:10 +02:00
parent 5fbfa2a4c1
commit 61bc150ae6
1 changed files with 12 additions and 0 deletions

View File

@ -112,6 +112,8 @@ class Harvester(CkanCommand):
self.create_harvest_source()
elif cmd == "rmsource":
self.remove_harvest_source()
elif cmd == 'clearsource':
self.clear_harvest_source()
elif cmd == 'sources':
self.list_harvest_sources()
elif cmd == 'job':
@ -248,6 +250,16 @@ class Harvester(CkanCommand):
get_action('harvest_source_delete')(context,{'id':source_id})
print 'Removed harvest source: %s' % source_id
def clear_harvest_source(self):
if len(self.args) >= 2:
source_id = unicode(self.args[1])
else:
print 'Please provide a source id'
sys.exit(1)
context = {'model': model, 'user': self.admin_user['name'], 'session':model.Session}
get_action('harvest_source_clear')(context,{'id':source_id})
print 'Cleared harvest source: %s' % source_id
def list_harvest_sources(self):
if len(self.args) >= 2 and self.args[1] == 'all':
data_dict = {}