1
0
mirror of https://github.com/Tafkas/fritzbox-munin.git synced 2023-10-10 13:36:55 +02:00

Added localisation support for uptime active keyword

This commit is contained in:
Bob van de Vijver 2019-12-27 13:36:44 +01:00
parent 2dd4e07013
commit 617ce230b4

View File

@ -23,6 +23,7 @@ import sys
import fritzbox_helper as fh
locale = os.environ.get('locale', 'de')
activeLoc = {"de": "aktiv", "en": "active"}
patternLoc = {"de": r"(\d+)\s(Tag|Stunden|Minuten)",
"en": r"(\d+)\s(days|hours|minutes)"}
dayLoc = {"de": "Tag", "en": "days"}
@ -43,7 +44,10 @@ def get_uptime():
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
data = json.loads(xhr_data)
for d in data['data']['drain']:
if 'aktiv' in d['statuses']:
if type(d['statuses']) != str and type(d['statuses']) != unicode:
continue
if activeLoc[locale] in d['statuses'].lower():
matches = re.finditer(pattern, d['statuses'])
if matches:
hours = 0.0