Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
Import Process
Import API
Commits
1109c0fc
Commit
1109c0fc
authored
Apr 12, 2021
by
Matthias
Browse files
implement reqparse for reporting
parent
929c9284
Changes
1
Hide whitespace changes
Inline
Side-by-side
import_api_app/resources/WriteJobResultsToDrupal.py
View file @
1109c0fc
from
flask_restful
import
Resource
,
request
from
flask_restful
import
Resource
,
request
,
reqparse
from
flask_restful
import
current_app
from
helpers.Error
import
ImportApiError
from
datetime
import
datetime
...
...
@@ -28,8 +28,6 @@ class WriteJobResultToDrupal(Resource):
name: body
required: true
schema:
items:
type: object
properties:
sessionId:
type: string
...
...
@@ -86,11 +84,28 @@ class WriteJobResultToDrupal(Resource):
"""
try
:
current_app
.
logger
.
debug
(
"report data: "
+
bytes
.
decode
(
request
.
data
))
fatal
=
request
.
json
[
0
][
'fatal'
]
parser
=
reqparse
.
RequestParser
()
parser
.
add_argument
(
'earliest'
)
parser
.
add_argument
(
'elapsedTime'
)
parser
.
add_argument
(
'fatal'
)
parser
.
add_argument
(
'ignore'
)
parser
.
add_argument
(
'institutionId'
)
parser
.
add_argument
(
'latest'
)
parser
.
add_argument
(
'messageId'
)
parser
.
add_argument
(
'previousMessageId'
)
parser
.
add_argument
(
'recordSetId'
)
parser
.
add_argument
(
'sessionId'
)
parser
.
add_argument
(
'step'
)
parser
.
add_argument
(
'success'
)
parser
.
add_argument
(
'total'
)
parser
.
add_argument
(
'version'
)
parser
.
add_argument
(
'warning'
)
args
=
parser
.
parse_args
()
fatal
=
args
[
'fatal'
]
status
=
'FAILED'
if
fatal
==
0
:
status
=
'SUCCESS'
report
=
json
.
dumps
(
request
.
json
[
0
]
,
indent
=
2
)
report
=
json
.
dumps
(
request
.
json
,
indent
=
2
)
return
write_results
(
job_drupal_uuid
,
job_log_drupal_uuid
,
status
,
report
)
except
ImportApiError
as
e
:
return
{
'error'
:
e
.
message
},
500
...
...
Write
Preview
Supports
Markdown
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