Commit 06a99c68 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update controller harvest and InveniStore to improve error reporting.

parent 69c33735
......@@ -22,8 +22,11 @@ from plugin_dbui import (inline_alert,
Selector,
to_formPanel,
UNDEF_ID)
from requests.exceptions import RequestException
MODE_DRY_RUN = T(DRY_RUN)
MSG_GREMLIN = "Oops a gremlin..."
MSG_LOST_CONNECTION = "Lost HTTP connection (timeout or site unavailable)"
MSG_NO_AFFILIATION = "Affiliation keys are not defined !!!"
MSG_NO_HARVESTER = "No harvesters for your selection !!!"
MSG_NO_RECORD = "Sorry, the record does not exist."
......@@ -143,7 +146,7 @@ def edit_insert():
record = load_record(selector.host, selector.record_id)
if record is None:
return inline_alert(T("Error"), T(MSG_NO_RECORD))
return inline_alert(T(MSG_GREMLIN), T(MSG_NO_RECORD))
except Exception as e:
logger.error(str(e))
......@@ -424,6 +427,10 @@ def run():
collection_logs.extend(tool.collection_logs)
logs.extend(tool.logs)
except RequestException as e:
logger.error(MSG_LOST_CONNECTION)
return inline_alert(T(MSG_GREMLIN), T(MSG_LOST_CONNECTION))
except ToolException as e:
log = tool.logs[-1]
msg = "<h4>Error on record %s (%s)</h4>" % (log.url, log.collection)
......
......@@ -14,7 +14,7 @@ CDS_SEARCH_KEYS = ("req", "cc", "c", "ec", "p", "f", "rg", "sf", "so", "sp",
"d1y", "d1m", "d1d", "d2", "d2y", "d2m", "d2d", "dt",
"verbose", "ap", "ln", "ec")
MSG_HTTP_DECODE = "Failed to decode HTTP response"
MSG_HTTP_DECODE = "Fail to decode HTTP response"
MSG_HTTP_ERROR = "HTTP Error"
MSG_NO_IDS = "Invalid list of record identifiers"
MSG_WRONG_KEYWORD = "Invalid keyword argument"
......@@ -401,7 +401,7 @@ class InvenioStore(object):
kwargs["jrec"] += N_IDS
url = "https://%s/search" % self._host
rep = self.interogate(url, **kwargs)
rep = self.interogate(url, timeout=30, **kwargs)
try:
li = rep.json()
......@@ -448,7 +448,7 @@ class InvenioStore(object):
try:
li = rep.json()
except ValueError as e:
except ValueError:
raise CdsException(MSG_HTTP_DECODE)
return li[0]
......
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