Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
limbra
limbra
Commits
06a99c68
Commit
06a99c68
authored
Jan 30, 2020
by
LE GAC Renaud
Browse files
Update controller harvest and InveniStore to improve error reporting.
parent
69c33735
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
controllers/harvest.py
controllers/harvest.py
+8
-1
modules/invenio_tools/inveniostore.py
modules/invenio_tools/inveniostore.py
+3
-3
No files found.
controllers/harvest.py
View file @
06a99c68
...
...
@@ -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
)
...
...
modules/invenio_tools/inveniostore.py
View file @
06a99c68
...
...
@@ -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
=
"Fail
ed
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
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment