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
2bcee882
Commit
2bcee882
authored
Mar 03, 2020
by
LE GAC Renaud
Browse files
Update controller and views wizards/update_citations to add protection.
parent
cd69868e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
3 deletions
+25
-3
controllers/wizards.py
controllers/wizards.py
+17
-1
languages/fr-fr.py
languages/fr-fr.py
+2
-0
views/wizards/update_citations.html
views/wizards/update_citations.html
+2
-0
views/wizards/update_citations.txt
views/wizards/update_citations.txt
+4
-2
No files found.
controllers/wizards.py
View file @
2bcee882
...
...
@@ -453,6 +453,8 @@ def update_citations():
http_error
=
0
,
insert
=
0
,
json_error
=
0
,
list_size
=
0
,
not_list
=
0
,
url_error
=
0
)
# get user requirement
...
...
@@ -474,7 +476,19 @@ def update_citations():
try
:
url
=
rex_ins
.
search
(
row
.
origin
).
group
(
1
)
rep
=
store
.
interogate
(
url
,
timeout
=
60
,
**
kwargs
)
count
=
rep
.
json
()[
0
].
get
(
"number_of_citations"
)
lst
=
rep
.
json
()
if
not
isinstance
(
lst
,
list
):
logger
.
warning
(
f
"JSON response is not a list"
)
counters
.
not_list
+=
1
continue
if
len
(
lst
)
!=
1
:
logger
.
warning
(
f
"size of the return list is not one"
)
counters
.
list_size
+=
1
continue
count
=
lst
[
0
].
get
(
"number_of_citations"
)
except
AttributeError
:
logger
.
warning
(
f
"inspirehep URL not well formed
{
row
.
origin
}
"
)
...
...
@@ -518,6 +532,8 @@ def update_citations():
logger
.
info
(
f
" bad inspirehep URL:
{
counters
.
url_error
}
"
)
logger
.
info
(
f
" HTTP connection error:
{
counters
.
url_error
}
"
)
logger
.
info
(
f
" JSON decoding error:
{
counters
.
json_error
}
"
)
logger
.
info
(
f
" response is not a list:
{
counters
.
not_list
}
"
)
logger
.
info
(
f
" list size is not one:
{
counters
.
list_size
}
"
)
logger
.
info
(
f
" insert or update in db:
{
counters
.
insert
}
"
)
return
dict
(
counters
=
counters
,
...
...
languages/fr-fr.py
View file @
2bcee882
...
...
@@ -377,6 +377,7 @@
'List of university separated by comma'
:
'Liste des universités séparé par une virgule'
,
'List shorted by AERES category, by project and by year'
:
'Liste triée par catégorie AERES par projet et par année'
,
'List shorted by usual category, by team and by year'
:
'Liste triée par catégorie usuelle par équipe et par année'
,
'list size is not one'
:
"La liste a plus d'un élément"
,
'lists'
:
'listes'
,
'Load'
:
'Charger'
,
'load in the database'
:
'chargé dans la base de données'
,
...
...
@@ -623,6 +624,7 @@
'Reports or notes signed by members of the institute'
:
'Rapports ou notes signés par des membres du laboratoire'
,
'Request reset password'
:
'Request reset password'
,
'Reset Password key'
:
'Reset Password key'
,
'response is not a list'
:
"La réponse n'est pas une liste"
,
'Review'
:
'Revue'
,
'Revue'
:
'Revue'
,
'Revues'
:
'Revues'
,
...
...
views/wizards/update_citations.html
View file @
2bcee882
...
...
@@ -9,6 +9,8 @@
[T("URL not well formed"), TD(f"{counters.url_error}", _style=mytd)],
[T("HTTP connection error"), TD(f"{counters.http_error}", _style=mytd)],
[T("JSON decoding error"), TD(f"{counters.json_error}", _style=mytd)],
[T("response is not a list"), TD(f"{counters.not_list}", _style=mytd)],
[T("list size is not one"), TD(f"{counters.list_size}", _style=mytd)],
[T("Number of articles modified"), TD(f"{counters.insert}", _style=mytd)]]
title = f"{T('Update citations')} {team_project}"
...
...
views/wizards/update_citations.txt
View file @
2bcee882
...
...
@@ -7,16 +7,18 @@
start = request.now
end = datetime.now()
delta =
(
end - start
).total_seconds()
delta = end - start
response.write(f"\t Scan start: {start:%d %b %Y %H:%M}\n")
response.write(f"\t Scan end: {end:%d %b %Y %H:%M}\n")
response.write(f"\t Scan duration: {delta
:.0f}s
\n\n")
response.write(f"\t Scan duration: {delta
}
\n\n")
response.write(f"\tNumber of articles analysed: {counters.article}\n")
response.write(f"\t URL not well formed: {counters.url_error}\n")
response.write(f"\t HTTP connection error: {counters.http_error}\n")
response.write(f"\t JSON decoding error: {counters.json_error}\n")
response.write(f"\t response is not a list: {counters.not_list}\n")
response.write(f"\t list size is not one: {counters.list_size}\n")
response.write(f"\tNumber of articles modified: {counters.insert}\n\n")
}}
\ No newline at end of file
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