Commit 58ee526c authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update controllers/harvest/run_all to add protection.

parent fa3e7a33
......@@ -492,15 +492,28 @@ def run_all():
for harvester in harvesters:
id_teams = harvester.id_teams
id_projects = harvester.id_projects
controller = harvester.controller
id_categories = harvester.id_categories
logger.info("-"*79)
logger.info(f"run harvester {harvester.controller}")
logger.info(f"run harvester {controller}")
logger.info(f" team: {id_teams}")
logger.info(f" project: {id_projects}")
logger.info(f" controller: {controller}")
logger.info(f" category: {id_categories}")
if id_teams is None or id_projects is None or id_categories is None:
continue
tool = build_harvester_tool(
db,
harvester.id_teams,
harvester.id_projects,
harvester.controller,
harvester.id_categories,
id_teams,
id_projects,
controller,
id_categories,
year_start=selector.year_start,
year_end=selector.year_end,
dry_run=(selector.mode == MODE_DRY_RUN))
......@@ -514,15 +527,23 @@ def run_all():
logs.extend(tool.logs)
except ToolException as e:
log = tool.logs[-1]
msg = "<h4>Error on record %s (%s)</h4>" % (log.url, log.collection)
msg = ""
if len(tool.logs) > 0:
log = tool.logs[-1]
msg = f"<h4>Error on record {log.url} ({log.collection})</h4>"
msg += T(str(e))
logger.error(msg)
logger.info("-"*79)
return msg
except Exception as e:
msg = "<hr/>"
msg += CODE(traceback.format_exc()).xml()
msg += "<hr/>"
logger.error(msg)
logger.info("-"*79)
return msg
if logger.getEffectiveLevel() <= logging.INFO:
......
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