code vereinfacht

This commit is contained in:
4ndr3 2017-06-16 23:41:11 +02:00 committed by GitHub
parent 0c0fa78200
commit b343748fe8

View file

@ -9,14 +9,10 @@ import urllib2
Datei = urllib2.urlopen('https://map.hamburg.freifunk.net/nodes.json')
Datei_Sued = urllib2.urlopen('https://map.hamburg.freifunk.net/hhsued/mv1/nodes.json')
#Zaehler mit Wert 0 anlegen
num_nodes = 0
Text = Datei.read()
n = Text.count('"online": true')
Knotenzahl = Text.count('"online": true')
Text = Datei_Sued.read()
n_Sued = Text.count('"online":true')
num_nodes = n + n_Sued
Knotenzahl = Knotenzahl + Text.count('"online":true')
#Zeit holen
thetime = datetime.datetime.now().isoformat()
@ -29,7 +25,7 @@ with open('/var/www/meta/ffhh.json', 'r') as fp:
#Attribute Zeitstempel und Knotenanzahl setzen
ffhh['state']['lastchange'] = thetime
ffhh['state']['nodes'] = num_nodes
ffhh['state']['nodes'] = Knotenzahl
#Freifunk API-Datein mit geaenderten werten schreiben
with open('/var/www/meta/ffhh.json', 'w') as fp: