[forms] Adapt CLI commands to changes in lib
This commit is contained in:
parent
bbe459527f
commit
b3a88070e3
|
@ -128,7 +128,7 @@ class Harvester(CkanCommand):
|
||||||
publisher_id = unicode(self.args[5])
|
publisher_id = unicode(self.args[5])
|
||||||
else:
|
else:
|
||||||
publisher_id = u''
|
publisher_id = u''
|
||||||
|
try:
|
||||||
source = create_harvest_source({
|
source = create_harvest_source({
|
||||||
'url':url,
|
'url':url,
|
||||||
'type':type,
|
'type':type,
|
||||||
|
@ -146,6 +146,12 @@ class Harvester(CkanCommand):
|
||||||
create_harvest_job(source['id'])
|
create_harvest_job(source['id'])
|
||||||
print 'A new Harvest Job for this source has also been created'
|
print 'A new Harvest Job for this source has also been created'
|
||||||
|
|
||||||
|
except ValidationError,e:
|
||||||
|
print 'An error occurred:'
|
||||||
|
print str(e.error_dict)
|
||||||
|
raise e
|
||||||
|
|
||||||
|
|
||||||
def remove_harvest_source(self):
|
def remove_harvest_source(self):
|
||||||
if len(self.args) >= 2:
|
if len(self.args) >= 2:
|
||||||
source_id = unicode(self.args[1])
|
source_id = unicode(self.args[1])
|
||||||
|
|
|
@ -240,6 +240,8 @@ def edit_harvest_source(source_id,data_dict):
|
||||||
schema = harvest_source_form_schema()
|
schema = harvest_source_form_schema()
|
||||||
|
|
||||||
source = HarvestSource.get(source_id)
|
source = HarvestSource.get(source_id)
|
||||||
|
if not source:
|
||||||
|
raise NotFound('Harvest source %s does not exist' % source_id)
|
||||||
|
|
||||||
# Add source id to the dict, as some validators will need it
|
# Add source id to the dict, as some validators will need it
|
||||||
data_dict["id"] = source.id
|
data_dict["id"] = source.id
|
||||||
|
@ -260,10 +262,10 @@ def edit_harvest_source(source_id,data_dict):
|
||||||
|
|
||||||
|
|
||||||
def remove_harvest_source(source_id):
|
def remove_harvest_source(source_id):
|
||||||
try:
|
|
||||||
source = HarvestSource.get(source_id)
|
source = HarvestSource.get(source_id)
|
||||||
except:
|
if not source:
|
||||||
raise Exception('Source %s does not exist' % source_id)
|
raise NotFound('Harvest source %s does not exist' % source_id)
|
||||||
|
|
||||||
# Don't actually delete the record, just flag it as inactive
|
# Don't actually delete the record, just flag it as inactive
|
||||||
source.active = False
|
source.active = False
|
||||||
|
@ -291,11 +293,9 @@ def get_harvest_jobs(**kwds):
|
||||||
|
|
||||||
def create_harvest_job(source_id):
|
def create_harvest_job(source_id):
|
||||||
# Check if source exists
|
# Check if source exists
|
||||||
try:
|
|
||||||
#We'll need the actual HarvestSource
|
|
||||||
source = HarvestSource.get(source_id)
|
source = HarvestSource.get(source_id)
|
||||||
except:
|
if not source:
|
||||||
raise Exception('Source %s does not exist' % source_id)
|
raise NotFound('Harvest source %s does not exist' % source_id)
|
||||||
|
|
||||||
# Check if the source is active
|
# Check if the source is active
|
||||||
if not source.active:
|
if not source.active:
|
||||||
|
@ -344,10 +344,10 @@ def get_harvest_objects(**kwds):
|
||||||
|
|
||||||
def import_last_objects(source_id=None):
|
def import_last_objects(source_id=None):
|
||||||
if source_id:
|
if source_id:
|
||||||
try:
|
|
||||||
source = HarvestSource.get(source_id)
|
source = HarvestSource.get(source_id)
|
||||||
except:
|
if not source:
|
||||||
raise Exception('Source %s does not exist' % source_id)
|
raise NotFound('Harvest source %s does not exist' % source_id)
|
||||||
|
|
||||||
last_objects = Session.query(HarvestObject) \
|
last_objects = Session.query(HarvestObject) \
|
||||||
.join(HarvestJob) \
|
.join(HarvestJob) \
|
||||||
.filter(HarvestJob.source==source) \
|
.filter(HarvestJob.source==source) \
|
||||||
|
|
Loading…
Reference in New Issue