mirror of https://gitlab.com/bashrc2/epicyon
Check status code
parent
a99eb91544
commit
78fcf1618f
|
@ -64,6 +64,12 @@ def updateAvatarImageCache(session,baseDir: str,httpPrefix: str,actor: str,avata
|
|||
try:
|
||||
print('avatar image url: '+avatarUrl)
|
||||
result=session.get(avatarUrl, headers=sessionHeaders, params=None)
|
||||
if result.status_code<200 or result.status_code>202:
|
||||
print('Avatar image download failed with status '+str(result.status_code))
|
||||
# remove partial download
|
||||
if os.path.isfile(avatarImageFilename):
|
||||
os.remove(avatarImageFilename)
|
||||
else:
|
||||
with open(avatarImageFilename, 'wb') as f:
|
||||
f.write(result.content)
|
||||
print('avatar image downloaded for '+actor)
|
||||
|
@ -71,9 +77,6 @@ def updateAvatarImageCache(session,baseDir: str,httpPrefix: str,actor: str,avata
|
|||
except Exception as e:
|
||||
print('Failed to download avatar image: '+str(avatarUrl))
|
||||
print(e)
|
||||
# remove partial download
|
||||
if os.path.isfile(avatarImageFilename):
|
||||
os.remove(avatarImageFilename)
|
||||
sessionHeaders = {'Accept': 'application/activity+json; profile="https://www.w3.org/ns/activitystreams"'}
|
||||
personJson = getJson(session,actor,sessionHeaders,None,__version__,httpPrefix,None)
|
||||
if personJson:
|
||||
|
|
Loading…
Reference in New Issue