mirror of https://gitlab.com/bashrc2/epicyon
More error handling on post
parent
142088a0ca
commit
4b9db09263
17
session.py
17
session.py
|
@ -86,11 +86,18 @@ def postJsonString(session,postJsonStr: str, \
|
||||||
return None
|
return None
|
||||||
|
|
||||||
postResult = session.post(url = inboxUrl, data = postJsonStr, headers=headers)
|
postResult = session.post(url = inboxUrl, data = postJsonStr, headers=headers)
|
||||||
print('>>>>>>>>>postResult: '+str(postResult))
|
if not postResult:
|
||||||
if postResult:
|
return None
|
||||||
if 'not found' in postResult.text:
|
postResultCode=str(postResult)
|
||||||
print('WARN: Failed to post to '+inboxUrl)
|
if '[' in postResultCode and ']' in postResultCode:
|
||||||
return None
|
postResultCode=postResultCode.split('[')[1]
|
||||||
|
postResultCode=postResultCode.split(']')[0]
|
||||||
|
if postResultCode.isdigit():
|
||||||
|
postResultCode=int(postResultCode)
|
||||||
|
if postResultCode<200 or postResultCode>202:
|
||||||
|
print('WARN: Failed to post to '+inboxUrl)
|
||||||
|
print('http code '+str(postResultCode))
|
||||||
|
return None
|
||||||
return postResult.text
|
return postResult.text
|
||||||
|
|
||||||
def postImage(session,attachImageFilename: str,federationList: [],inboxUrl: str,headers: {},capability: str) -> str:
|
def postImage(session,attachImageFilename: str,federationList: [],inboxUrl: str,headers: {},capability: str) -> str:
|
||||||
|
|
Loading…
Reference in New Issue