From 61bc150ae6f313bd34583b4711319566c86c470b Mon Sep 17 00:00:00 2001 From: Stefan Oderbolz Date: Wed, 10 Jun 2015 11:19:10 +0200 Subject: [PATCH 1/4] Expose clear harvester source as a paster command --- ckanext/harvest/commands/harvester.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ckanext/harvest/commands/harvester.py b/ckanext/harvest/commands/harvester.py index fadd669..75fa163 100644 --- a/ckanext/harvest/commands/harvester.py +++ b/ckanext/harvest/commands/harvester.py @@ -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 = {} From 8ebb8430527a445765404847174deaa3ec501453 Mon Sep 17 00:00:00 2001 From: Stefan Oderbolz Date: Wed, 10 Jun 2015 11:26:22 +0200 Subject: [PATCH 2/4] Add documentation for clearsource command --- README.rst | 3 +++ ckanext/harvest/commands/harvester.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/README.rst b/README.rst index 2456375..2f7a00d 100644 --- a/README.rst +++ b/README.rst @@ -115,6 +115,9 @@ The following operations can be run from the command line using the harvester rmsource {id} - remove (inactivate) a harvester source + harvester clearsource {id} + - clear a harvester source (delete all associtated datasets) + harvester sources [all] - lists harvest sources If 'all' is defined, it also shows the Inactive sources diff --git a/ckanext/harvest/commands/harvester.py b/ckanext/harvest/commands/harvester.py index 75fa163..6499eda 100644 --- a/ckanext/harvest/commands/harvester.py +++ b/ckanext/harvest/commands/harvester.py @@ -20,6 +20,9 @@ class Harvester(CkanCommand): harvester rmsource {id} - remove (inactivate) a harvester source + harvester clearsource {id} + - clear a harvester source (delete all associtated datasets) + harvester sources [all] - lists harvest sources If 'all' is defined, it also shows the Inactive sources From 2a2d85f60cf1ef7ada15da9cd24e5de541079067 Mon Sep 17 00:00:00 2001 From: Stefan Oderbolz Date: Wed, 10 Jun 2015 16:19:23 +0200 Subject: [PATCH 3/4] Wording changes for clearsource and rmsource --- README.rst | 4 ++-- ckanext/harvest/commands/harvester.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 2f7a00d..a7fb2ef 100644 --- a/README.rst +++ b/README.rst @@ -113,10 +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} - - clear a harvester source (delete all associtated datasets) + - 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 6499eda..06a7cf0 100644 --- a/ckanext/harvest/commands/harvester.py +++ b/ckanext/harvest/commands/harvester.py @@ -18,10 +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} - - clear a harvester source (delete all associtated datasets) + - clears all datasets, jobs and objects related to a harvest source, but keeps the source itself harvester sources [all] - lists harvest sources From 64ff0f3a3a10897e41c54fb6709a74ef1ea66d5d Mon Sep 17 00:00:00 2001 From: Stefan Oderbolz Date: Wed, 10 Jun 2015 16:22:04 +0200 Subject: [PATCH 4/4] Use single quotes to be consistent --- ckanext/harvest/commands/harvester.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ckanext/harvest/commands/harvester.py b/ckanext/harvest/commands/harvester.py index 06a7cf0..ba546fe 100644 --- a/ckanext/harvest/commands/harvester.py +++ b/ckanext/harvest/commands/harvester.py @@ -113,7 +113,7 @@ 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()