mirror of https://gitlab.com/bashrc2/epicyon
Consistent message
parent
3330ed1601
commit
a1f677e380
|
@ -58,7 +58,7 @@ def getJson(session, url: str, headers: {}, params: {},
|
||||||
domain='testdomain') -> {}:
|
domain='testdomain') -> {}:
|
||||||
if not isinstance(url, str):
|
if not isinstance(url, str):
|
||||||
print('url: ' + str(url))
|
print('url: ' + str(url))
|
||||||
print('ERROR: getJson url should be a string')
|
print('ERROR: getJson failed, url should be a string')
|
||||||
return None
|
return None
|
||||||
sessionParams = {}
|
sessionParams = {}
|
||||||
sessionHeaders = {}
|
sessionHeaders = {}
|
||||||
|
@ -71,7 +71,7 @@ def getJson(session, url: str, headers: {}, params: {},
|
||||||
sessionHeaders['User-Agent'] += \
|
sessionHeaders['User-Agent'] += \
|
||||||
'; +' + httpPrefix + '://' + domain + '/'
|
'; +' + httpPrefix + '://' + domain + '/'
|
||||||
if not session:
|
if not session:
|
||||||
print('WARN: no session specified for getJson')
|
print('WARN: getJson failed, no session specified for getJson')
|
||||||
try:
|
try:
|
||||||
result = session.get(url, headers=sessionHeaders, params=sessionParams)
|
result = session.get(url, headers=sessionHeaders, params=sessionParams)
|
||||||
return result.json()
|
return result.json()
|
||||||
|
@ -87,7 +87,7 @@ def getJson(session, url: str, headers: {}, params: {},
|
||||||
print(e)
|
print(e)
|
||||||
except SocketError as e:
|
except SocketError as e:
|
||||||
if e.errno == errno.ECONNRESET:
|
if e.errno == errno.ECONNRESET:
|
||||||
print('WARN: connection was reset during getJson')
|
print('WARN: getJson failed, connection was reset during getJson')
|
||||||
print(e)
|
print(e)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue