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:
parent
2dd4e07013
commit
617ce230b4
@ -23,6 +23,7 @@ import sys
|
|||||||
import fritzbox_helper as fh
|
import fritzbox_helper as fh
|
||||||
|
|
||||||
locale = os.environ.get('locale', 'de')
|
locale = os.environ.get('locale', 'de')
|
||||||
|
activeLoc = {"de": "aktiv", "en": "active"}
|
||||||
patternLoc = {"de": r"(\d+)\s(Tag|Stunden|Minuten)",
|
patternLoc = {"de": r"(\d+)\s(Tag|Stunden|Minuten)",
|
||||||
"en": r"(\d+)\s(days|hours|minutes)"}
|
"en": r"(\d+)\s(days|hours|minutes)"}
|
||||||
dayLoc = {"de": "Tag", "en": "days"}
|
dayLoc = {"de": "Tag", "en": "days"}
|
||||||
@ -43,7 +44,10 @@ def get_uptime():
|
|||||||
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
xhr_data = fh.get_xhr_content(server, session_id, PAGE)
|
||||||
data = json.loads(xhr_data)
|
data = json.loads(xhr_data)
|
||||||
for d in data['data']['drain']:
|
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'])
|
matches = re.finditer(pattern, d['statuses'])
|
||||||
if matches:
|
if matches:
|
||||||
hours = 0.0
|
hours = 0.0
|
||||||
|
Loading…
Reference in New Issue
Block a user