Use status code

master
Bob Mottram 2019-08-26 13:04:09 +01:00
parent d8f917e4e2
commit 815c231f55
1 changed files with 3 additions and 10 deletions

View File

@ -86,16 +86,9 @@ def postJsonString(session,postJsonStr: str, \
return None
postResult = session.post(url = inboxUrl, data = postJsonStr, headers=headers)
postResultCode=str(postResult)
print('http: '+postResultCode)
if '[' in postResultCode and ']' in postResultCode:
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)
return None
if postResult.status_code<200 or postResult.status_code>202:
print('WARN: Failed to post to '+inboxUrl)
return None
return postResult.text
def postImage(session,attachImageFilename: str,federationList: [],inboxUrl: str,headers: {},capability: str) -> str: