diff --git a/webinterface.py b/webinterface.py index 21ada677..3db1a422 100644 --- a/webinterface.py +++ b/webinterface.py @@ -68,7 +68,9 @@ from happening import thisWeeksEventsCheck from happening import getCalendarEvents from happening import getTodaysEvents -def updateAvatarImageCache(session,baseDir: str,httpPrefix: str,actor: str,avatarUrl: str,personCache: {},force=False) -> str: +def updateAvatarImageCache(session,baseDir: str,httpPrefix: str, \ + actor: str,avatarUrl: str, \ + personCache: {},force=False) -> str: """Updates the cached avatar for the given actor """ if not avatarUrl: @@ -95,7 +97,8 @@ def updateAvatarImageCache(session,baseDir: str,httpPrefix: str,actor: str,avata 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)) + print('Avatar image download failed with status '+ \ + str(result.status_code)) # remove partial download if os.path.isfile(avatarImageFilename): os.remove(avatarImageFilename) @@ -108,10 +111,16 @@ def updateAvatarImageCache(session,baseDir: str,httpPrefix: str,actor: str,avata print('Failed to download avatar image: '+str(avatarUrl)) print(e) if '/channel/' not in actor: - sessionHeaders = {'Accept': 'application/activity+json; profile="https://www.w3.org/ns/activitystreams"'} + sessionHeaders = { + 'Accept': 'application/activity+json; profile="https://www.w3.org/ns/activitystreams"' + } else: - sessionHeaders = {'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'} - personJson = getJson(session,actor,sessionHeaders,None,__version__,httpPrefix,None) + sessionHeaders = { + 'Accept': 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' + } + personJson = \ + getJson(session,actor,sessionHeaders,None,__version__, \ + httpPrefix,None) if personJson: if not personJson.get('id'): return None @@ -123,7 +132,8 @@ def updateAvatarImageCache(session,baseDir: str,httpPrefix: str,actor: str,avata return None if not personCache.get(actor): return None - if personCache[actor]['actor']['publicKey']['publicKeyPem']!=personJson['publicKey']['publicKeyPem']: + if personCache[actor]['actor']['publicKey']['publicKeyPem']!= \ + personJson['publicKey']['publicKeyPem']: print("ERROR: public keys don't match when downloading actor for "+actor) return None storePersonInCache(baseDir,actor,personJson,personCache) @@ -156,7 +166,8 @@ def getPersonAvatarUrl(baseDir: str,personUrl: str,personCache: {}) -> str: return personJson['icon']['url'] return None -def htmlSearchEmoji(translate: {},baseDir: str,httpPrefix: str,searchStr: str) -> str: +def htmlSearchEmoji(translate: {},baseDir: str,httpPrefix: str, \ + searchStr: str) -> str: """Search results for emoji """ @@ -199,9 +210,15 @@ def htmlSearchEmoji(translate: {},baseDir: str,httpPrefix: str,searchStr: str) - for emojiName,filename in results.items(): if os.path.isfile(baseDir+'/emoji/'+filename): if not headingShown: - emojiForm+='
'+sharedItem['summary']+'
' sharedItemsForm+=''+translate['Type']+': '+sharedItem['itemType']+' ' sharedItemsForm+=''+translate['Category']+': '+sharedItem['category']+' ' sharedItemsForm+=''+translate['Location']+': '+sharedItem['location']+'
' contactActor=httpPrefix+'://'+domainFull+'/users/'+contactNickname - sharedItemsForm+='' if actor.endswith('/users/'+contactNickname): - sharedItemsForm+=' ' + sharedItemsForm+= \ + ' ' sharedItemsForm+='