mirror of
https://github.com/sartography/cr-connect-workflow.git
synced 2025-02-23 05:08:32 +00:00
Merge branch 'dev' into rrt/dev
This commit is contained in:
commit
8ce8f05321
@ -1,4 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
|
from json import JSONDecodeError
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
@ -26,10 +27,17 @@ class ProtocolBuilderService(object):
|
|||||||
ProtocolBuilderService.__enabled_or_raise()
|
ProtocolBuilderService.__enabled_or_raise()
|
||||||
if not isinstance(user_id, str):
|
if not isinstance(user_id, str):
|
||||||
raise ApiError("protocol_builder_error", "This user id is invalid: " + str(user_id))
|
raise ApiError("protocol_builder_error", "This user id is invalid: " + str(user_id))
|
||||||
response = requests.get(ProtocolBuilderService.STUDY_URL % user_id)
|
url = ProtocolBuilderService.STUDY_URL % user_id
|
||||||
|
response = requests.get(url)
|
||||||
if response.ok and response.text:
|
if response.ok and response.text:
|
||||||
pb_studies = ProtocolBuilderStudySchema(many=True).loads(response.text)
|
try:
|
||||||
return pb_studies
|
pb_studies = ProtocolBuilderStudySchema(many=True).loads(response.text)
|
||||||
|
return pb_studies
|
||||||
|
except JSONDecodeError as err:
|
||||||
|
raise ApiError("protocol_builder_error",
|
||||||
|
"Received an invalid response from the protocol builder. The response is not "
|
||||||
|
"valid json. Url: %s, Response: %s, error: %s" %
|
||||||
|
(url, response.text, err.msg))
|
||||||
else:
|
else:
|
||||||
raise ApiError("protocol_builder_error",
|
raise ApiError("protocol_builder_error",
|
||||||
"Received an invalid response from the protocol builder (status %s): %s" %
|
"Received an invalid response from the protocol builder (status %s): %s" %
|
||||||
|
Loading…
x
Reference in New Issue
Block a user