forked from indymedia/epicyon
More configurability when loading json
parent
213478ed42
commit
01397b3dad
4
utils.py
4
utils.py
|
@ -75,12 +75,12 @@ def saveJson(jsonObject: {}, filename: str) -> bool:
|
|||
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
|
||||
"""
|
||||
jsonObject = None
|
||||
tries = 0
|
||||
while tries < 5:
|
||||
while tries < maxTries:
|
||||
try:
|
||||
with open(filename, 'r') as fp:
|
||||
data = fp.read()
|
||||
|
|
|
@ -294,6 +294,7 @@ def getPersonAvatarUrl(baseDir: str, personUrl: str, personCache: {}) -> str:
|
|||
personJson = getPersonFromCache(baseDir, personUrl, personCache)
|
||||
if not personJson:
|
||||
return None
|
||||
|
||||
# get from locally stored image
|
||||
actorStr = personJson['id'].replace('/', '-')
|
||||
avatarImagePath = baseDir + '/cache/avatars/' + actorStr
|
||||
|
|
Loading…
Reference in New Issue