From b343748fe8bc02632caded4039b79030f5f7909a Mon Sep 17 00:00:00 2001 From: 4ndr3 <4ndr3@users.noreply.github.com> Date: Fri, 16 Jun 2017 23:41:11 +0200 Subject: [PATCH] code vereinfacht --- node_number.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/node_number.py b/node_number.py index 765dc0f..20cd00e 100644 --- a/node_number.py +++ b/node_number.py @@ -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: