mirror of https://gitlab.com/bashrc2/epicyon
Less verbose
parent
6dc85f69dc
commit
2f12c9833a
|
@ -473,24 +473,28 @@ def updateAvatarImageCache(session, baseDir: str, httpPrefix: str,
|
||||||
|
|
||||||
if (not os.path.isfile(avatarImageFilename) or force) and allowDownloads:
|
if (not os.path.isfile(avatarImageFilename) or force) and allowDownloads:
|
||||||
try:
|
try:
|
||||||
print('avatar image url: ' + avatarUrl)
|
if debug:
|
||||||
|
print('avatar image url: ' + avatarUrl)
|
||||||
result = session.get(avatarUrl,
|
result = session.get(avatarUrl,
|
||||||
headers=sessionHeaders,
|
headers=sessionHeaders,
|
||||||
params=None)
|
params=None)
|
||||||
if result.status_code < 200 or \
|
if result.status_code < 200 or \
|
||||||
result.status_code > 202:
|
result.status_code > 202:
|
||||||
print('Avatar image download failed with status ' +
|
if debug:
|
||||||
str(result.status_code))
|
print('Avatar image download failed with status ' +
|
||||||
|
str(result.status_code))
|
||||||
# remove partial download
|
# remove partial download
|
||||||
if os.path.isfile(avatarImageFilename):
|
if os.path.isfile(avatarImageFilename):
|
||||||
os.remove(avatarImageFilename)
|
os.remove(avatarImageFilename)
|
||||||
else:
|
else:
|
||||||
with open(avatarImageFilename, 'wb') as f:
|
with open(avatarImageFilename, 'wb') as f:
|
||||||
f.write(result.content)
|
f.write(result.content)
|
||||||
print('avatar image downloaded for ' + actor)
|
if debug:
|
||||||
|
print('avatar image downloaded for ' + actor)
|
||||||
return avatarImageFilename.replace(baseDir + '/cache', '')
|
return avatarImageFilename.replace(baseDir + '/cache', '')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('Failed to download avatar image: ' + str(avatarUrl))
|
if debug:
|
||||||
|
print('Failed to download avatar image: ' + str(avatarUrl))
|
||||||
print(e)
|
print(e)
|
||||||
prof = 'https://www.w3.org/ns/activitystreams'
|
prof = 'https://www.w3.org/ns/activitystreams'
|
||||||
if '/channel/' not in actor or '/accounts/' not in actor:
|
if '/channel/' not in actor or '/accounts/' not in actor:
|
||||||
|
|
Loading…
Reference in New Issue