diff --git a/README.rst b/README.rst index 2456375..a7fb2ef 100644 --- a/README.rst +++ b/README.rst @@ -113,7 +113,10 @@ The following operations can be run from the command line using the - create new harvest source harvester rmsource {id} - - remove (inactivate) a harvester source + - remove (deactivate) a harvester source, whilst leaving any related datasets, jobs and objects + + harvester clearsource {id} + - clears all datasets, jobs and objects related to a harvest source, but keeps the source itself harvester sources [all] - lists harvest sources diff --git a/ckanext/harvest/commands/harvester.py b/ckanext/harvest/commands/harvester.py index fadd669..ba546fe 100644 --- a/ckanext/harvest/commands/harvester.py +++ b/ckanext/harvest/commands/harvester.py @@ -18,7 +18,10 @@ class Harvester(CkanCommand): - create new harvest source harvester rmsource {id} - - remove (inactivate) a harvester source + - remove (deactivate) a harvester source, whilst leaving any related datasets, jobs and objects + + harvester clearsource {id} + - clears all datasets, jobs and objects related to a harvest source, but keeps the source itself harvester sources [all] - lists harvest sources @@ -110,8 +113,10 @@ class Harvester(CkanCommand): cmd = self.args[0] if cmd == 'source': self.create_harvest_source() - elif cmd == "rmsource": + 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 +253,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 = {}