mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-28 10:38:26 +00:00
Fixed throttled providers badges in UI throwing exception. #1631
This commit is contained in:
parent
2cde2686fc
commit
ca8f3f9fd2
2 changed files with 11 additions and 8 deletions
|
@ -34,7 +34,7 @@ class Badges(Resource):
|
|||
.where(reduce(operator.and_, movies_conditions))\
|
||||
.count()
|
||||
|
||||
throttled_providers = len(eval(str(get_throttled_providers())))
|
||||
throttled_providers = len(get_throttled_providers())
|
||||
|
||||
health_issues = len(get_health_issues())
|
||||
|
||||
|
|
|
@ -315,11 +315,14 @@ def reset_throttled_providers():
|
|||
|
||||
def get_throttled_providers():
|
||||
providers = {}
|
||||
try:
|
||||
if os.path.exists(os.path.join(args.config_dir, 'config', 'throttled_providers.dat')):
|
||||
with open(os.path.normpath(os.path.join(args.config_dir, 'config', 'throttled_providers.dat')), 'r') as handle:
|
||||
providers = handle.read()
|
||||
if not providers:
|
||||
with open(os.path.normpath(os.path.join(args.config_dir, 'config', 'throttled_providers.dat')), 'r') as \
|
||||
handle:
|
||||
providers = ast.literal_eval(handle.read())
|
||||
except (OSError, ValueError):
|
||||
providers = {}
|
||||
finally:
|
||||
return providers
|
||||
|
||||
|
||||
|
@ -329,11 +332,11 @@ def set_throttled_providers(data):
|
|||
|
||||
|
||||
try:
|
||||
tp = eval(str(get_throttled_providers()))
|
||||
tp = get_throttled_providers()
|
||||
if not isinstance(tp, dict):
|
||||
raise ValueError('tp should be a dict')
|
||||
except Exception:
|
||||
logging.error("Invalid content in throttled_providers.dat. Resetting")
|
||||
# set empty content in throttled_providers.dat
|
||||
set_throttled_providers('')
|
||||
tp = eval(str(get_throttled_providers()))
|
||||
tp = get_throttled_providers()
|
||||
|
|
Loading…
Reference in a new issue