More configurability when loading json

main
Bob Mottram 2020-08-29 10:09:15 +01:00
parent 213478ed42
commit 01397b3dad
2 changed files with 3 additions and 2 deletions

View File

@ -75,12 +75,12 @@ def saveJson(jsonObject: {}, filename: str) -> bool:
return False return False
def loadJson(filename: str, delaySec=2) -> {}: def loadJson(filename: str, delaySec=2, maxTries=5) -> {}:
"""Makes a few attempts to load a json formatted file """Makes a few attempts to load a json formatted file
""" """
jsonObject = None jsonObject = None
tries = 0 tries = 0
while tries < 5: while tries < maxTries:
try: try:
with open(filename, 'r') as fp: with open(filename, 'r') as fp:
data = fp.read() data = fp.read()

View File

@ -294,6 +294,7 @@ def getPersonAvatarUrl(baseDir: str, personUrl: str, personCache: {}) -> str:
personJson = getPersonFromCache(baseDir, personUrl, personCache) personJson = getPersonFromCache(baseDir, personUrl, personCache)
if not personJson: if not personJson:
return None return None
# get from locally stored image # get from locally stored image
actorStr = personJson['id'].replace('/', '-') actorStr = personJson['id'].replace('/', '-')
avatarImagePath = baseDir + '/cache/avatars/' + actorStr avatarImagePath = baseDir + '/cache/avatars/' + actorStr