From 01397b3dadf93938241d8e0e6fa6195bf3051bf1 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 29 Aug 2020 10:09:15 +0100 Subject: [PATCH] More configurability when loading json --- utils.py | 4 ++-- webinterface.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/utils.py b/utils.py index 212e7093e..e74d407d1 100644 --- a/utils.py +++ b/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() diff --git a/webinterface.py b/webinterface.py index 0c5e41201..5508094c1 100644 --- a/webinterface.py +++ b/webinterface.py @@ -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