Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit d9027694 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update Automaton to add the method process_recjson.

parent 4414c211
......@@ -551,49 +551,30 @@ class Automaton(object):
# process the remaining identifiers
[self.process_recid(rec_id) for rec_id in rec_ids]
def process_recid(self, rec_id):
"""Process the publication:
def process_recjson(self, recjson):
"""Process the publication provided as a JSON record:
* get the publication data from the store using its identifier
* instantiate the record (RecordPubli, REcordConf, RecordThesis)
* process OAI data
* check the record
* insert new record in the database
Note:
* Design to never stop although exception are raised
* Have a look to the collection_logs and logs in order to
understand what happen.
Args:
rec_id (int):
identifier of the publication in the store.
recjson (dict):
record provided by the store.
"""
if self.dbg:
print("\nprocessing record", rec_id)
print("\nprocessing record")
collection_logs = self.collection_logs
harvester = self.harvester
logs = self.logs
# instantiate the record
try:
recjson = self.store.get_record(rec_id)
record = build_record(recjson)
if self.dbg:
print("\t", record.title())
record = build_record(recjson)
except Exception as e:
print(traceback.format_exc())
url = OAI_URL % (harvester.host, rec_id)
logs.append(Msg(harvester=harvester,
collection=collection_logs[-1].title,
record_id=rec_id,
title=url))
logs[-1].reject(e)
return
if self.dbg:
print("\t", record.title().encode("utf-8"))
# start the log for the record
logs.append(Msg(harvester=harvester,
......@@ -620,6 +601,46 @@ class Automaton(object):
action = (action.upper() if isinstance(action, str) else action)
print("\tlog:", action, log.txt)
def process_recid(self, rec_id):
"""Process the publication identified by its record identifier:
* get the publication data from the store using its identifier
* instantiate the record (RecordPubli, REcordConf, RecordThesis)
* process OAI data
* check the record
* insert new record in the database
Note:
* Design to never stop although exception are raised
* Have a look to the collection_logs and logs in order to
understand what happen.
Args:
rec_id (int):
identifier of the publication in the store.
"""
if self.dbg:
print("\nprocessing record", rec_id)
collection_logs = self.collection_logs
harvester = self.harvester
logs = self.logs
try:
recjson = self.store.get_record(rec_id)
self.process_recjson(recjson)
except Exception as e:
print(traceback.format_exc())
url = OAI_URL % (harvester.host, rec_id)
logs.append(Msg(harvester=harvester,
collection=collection_logs[-1].title,
record_id=rec_id,
title=url))
logs[-1].reject(e)
return
def process_url(self, host, collections):
"""Retrieve JSON objects from the invenio store and
insert corresponding records in the database.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment