mirror of https://github.com/morpheus65535/bazarr
Fixed throttled providers badges in UI throwing exception. #1631
This commit is contained in:
parent
2cde2686fc
commit
ca8f3f9fd2
|
@ -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,12 +315,15 @@ def reset_throttled_providers():
|
|||
|
||||
def get_throttled_providers():
|
||||
providers = {}
|
||||
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:
|
||||
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 = ast.literal_eval(handle.read())
|
||||
except (OSError, ValueError):
|
||||
providers = {}
|
||||
return providers
|
||||
finally:
|
||||
return providers
|
||||
|
||||
|
||||
def set_throttled_providers(data):
|
||||
|
@ -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 New Issue