[#56] Update parameters on source create command

Add missing title and owner_org fields, remove deprecated user_id and
publisher_id
This commit is contained in:
amercader 2013-08-14 11:54:51 +01:00
parent 3494727d3f
commit ffea49ca62
2 changed files with 22 additions and 22 deletions

View File

@ -75,7 +75,7 @@ The following operations can be run from the command line using the
harvester initdb harvester initdb
- Creates the necessary tables in the database - Creates the necessary tables in the database
harvester source {name} {url} {type} [{config}] [{active}] [{user-id}] [{publisher-id}] [{frequency}] harvester source {name} {url} {type} [{title}] [{active}] [{owner_org}] [{frequency}] [{config}]
- create new harvest source - create new harvest source
harvester rmsource {id} harvester rmsource {id}

View File

@ -1,5 +1,4 @@
import sys import sys
import re
from pprint import pprint from pprint import pprint
from ckan import model from ckan import model
@ -15,7 +14,7 @@ class Harvester(CkanCommand):
harvester initdb harvester initdb
- Creates the necessary tables in the database - Creates the necessary tables in the database
harvester source {name} {url} {type} [{config}] [{active}] [{user-id}] [{publisher-id}] [{frequency}] harvester source {name} {url} {type} [{title}] [{active}] [{owner_org}] [{frequency}] [{config}]
- create new harvest source - create new harvest source
harvester rmsource {id} harvester rmsource {id}
@ -172,38 +171,40 @@ class Harvester(CkanCommand):
sys.exit(1) sys.exit(1)
if len(self.args) >= 5: if len(self.args) >= 5:
config = unicode(self.args[4]) title = unicode(self.args[4])
else: else:
config = None title = None
if len(self.args) >= 6: if len(self.args) >= 6:
active = not(self.args[5].lower() == 'false' or \ active = not(self.args[5].lower() == 'false' or \
self.args[5] == '0') self.args[5] == '0')
else: else:
active = True active = True
if len(self.args) >= 7: if len(self.args) >= 7:
user_id = unicode(self.args[6]) owner_org = unicode(self.args[6])
else: else:
user_id = u'' owner_org = None
if len(self.args) >= 8: if len(self.args) >= 8:
publisher_id = unicode(self.args[7]) frequency = unicode(self.args[7])
else:
publisher_id = u''
if len(self.args) >= 9:
frequency = unicode(self.args[8])
if not frequency: if not frequency:
frequency = 'MANUAL' frequency = 'MANUAL'
else: else:
frequency = 'MANUAL' frequency = 'MANUAL'
if len(self.args) >= 9:
config = unicode(self.args[8])
else:
config = None
try: try:
data_dict = { data_dict = {
'url':url, 'name': name,
'source_type':type, 'url': url,
'name':name, 'source_type': type,
'config':config, 'title': title,
'frequency':frequency,
'active':active, 'active':active,
'user_id':user_id, 'owner_org': owner_org,
'publisher_id':publisher_id} 'frequency': frequency,
'config': config,
}
context = {'model':model, 'session':model.Session, 'user': self.admin_user['name']} context = {'model':model, 'session':model.Session, 'user': self.admin_user['name']}
source = get_action('harvest_source_create')(context,data_dict) source = get_action('harvest_source_create')(context,data_dict)
@ -309,9 +310,8 @@ class Harvester(CkanCommand):
print 'Source id: %s' % source.get('id') print 'Source id: %s' % source.get('id')
print ' url: %s' % source.get('url') print ' url: %s' % source.get('url')
print ' type: %s' % source.get('source_type') print ' type: %s' % source.get('source_type')
print ' active: %s' % source.get('active') print ' active: %s' % (source.get('active') if 'active' in source else source.get('state') == 'active')
print ' user: %s' % source.get('user_id') print 'owner org: %s' % source.get('owner_org')
print 'publisher: %s' % source.get('publisher_id')
print 'frequency: %s' % source.get('frequency') print 'frequency: %s' % source.get('frequency')
print ' jobs: %s' % source.get('status').get('job_count') print ' jobs: %s' % source.get('status').get('job_count')
print '' print ''