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
|
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()
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue