From ecabada8aab155f53d6bda63947502f92c9b687a Mon Sep 17 00:00:00 2001 From: Andrei Mitrofanow Date: Sun, 10 Apr 2016 21:30:44 +0200 Subject: [PATCH 1/5] =?UTF-8?q?=09ge=C3=A4ndert:=20=20=20=20=20=20=20contr?= =?UTF-8?q?ib/ffapi-update-nodes.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Es geht um ie Namensauflösung von Services-URLs für andere Städte. Eingefügt werden die URLs während der Daten-Aufbereitung von: https://github.com/freifunk/directory.api.freifunk.net/blob/master/directory.json mittels gethostbname(URL). Damit würde es möglich Servises über Städte hinaus zu teilen. --- contrib/ffapi-update-nodes.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/contrib/ffapi-update-nodes.py b/contrib/ffapi-update-nodes.py index 81b84ab..7600d24 100644 --- a/contrib/ffapi-update-nodes.py +++ b/contrib/ffapi-update-nodes.py @@ -74,7 +74,15 @@ def getServices(): with open(olsrServices, 'r') as services: servicesText = services.read().splitlines() services.closed - return servicesText + New=[] + for i in servicesText: + URL="" + j="" + if i[0]!="#": + URL=i.split("|")[0].slit("//")[1].split(":")[0] + j=socket.gethostbyname(URL) + New.append(i.replace(URL,j)) + return New def loadApiFile(): From 2f293991c9486835d7b3e7796511ac07b9995536 Mon Sep 17 00:00:00 2001 From: Andrei Mitrofanow Date: Sun, 10 Apr 2016 21:30:44 +0200 Subject: [PATCH 2/5] =?UTF-8?q?=09ge=C3=A4ndert:=20=20=20=20=20=20=20contr?= =?UTF-8?q?ib/ffapi-update-nodes.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Es geht um ie Namensauflösung von Services-URLs für andere Städte. Eingefügt werden die URLs während der Daten-Aufbereitung von: https://github.com/freifunk/directory.api.freifunk.net/blob/master/directory.json mittels gethostbname(URL). Damit würde die Möglichkeit, Servises über fremde Communities hinaus zu teilen, verbessert. From 2039926787b7bbf1fa0d89a281e7003a3f442391 Mon Sep 17 00:00:00 2001 From: Andrei Mitrofanow Date: Wed, 13 Apr 2016 23:00:01 +0200 Subject: [PATCH 3/5] =?UTF-8?q?=09ge=C3=A4ndert:=20=20=20=20=20=20=20contr?= =?UTF-8?q?ib/ffapi-update-nodes.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some names changed, for a bether understanding. --- contrib/ffapi-update-nodes.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/contrib/ffapi-update-nodes.py b/contrib/ffapi-update-nodes.py index 7600d24..2e126df 100644 --- a/contrib/ffapi-update-nodes.py +++ b/contrib/ffapi-update-nodes.py @@ -74,15 +74,15 @@ def getServices(): with open(olsrServices, 'r') as services: servicesText = services.read().splitlines() services.closed - New=[] - for i in servicesText: + ServiceList=[] + for service in servicesText: URL="" - j="" - if i[0]!="#": - URL=i.split("|")[0].slit("//")[1].split(":")[0] - j=socket.gethostbyname(URL) - New.append(i.replace(URL,j)) - return New + IPAddr="" + if service[0]!="#": + URL=service.split("|")[0].slit("//")[1].split(":")[0] + IPAddr=socket.gethostbyname(URL) + ServiceList.append(i.replace(URL,IPAddr)) + return ServiceList def loadApiFile(): From 6609005b1d21dfd225cbc05988e44370ac8db553 Mon Sep 17 00:00:00 2001 From: Andrei Mitrofanow Date: Sun, 17 Apr 2016 19:12:58 +0200 Subject: [PATCH 4/5] neue Datei: contrib/List_Services.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Datei Listet Services auf. Achtung das Skript läuft teilweise noch nicht fehlerfrei durch. Es werden teilweise Dateien nicht gefunden oder Zeichen nicht erkannt! Vielleicht kann das Skript genutzt werden, um externe Services einzubinden. lg --- contrib/List_Services.py | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 contrib/List_Services.py diff --git a/contrib/List_Services.py b/contrib/List_Services.py new file mode 100755 index 0000000..691424d --- /dev/null +++ b/contrib/List_Services.py @@ -0,0 +1,44 @@ +#!/usr/bin/python +# coding: utf-8 + +import ujson, urllib +from urlgrabber import urlopen +from termcolor import colored + +URL="https://raw.githubusercontent.com/freifunk/directory.api.freifunk.net/master/directory.json" +file="directory.json" + +try: + url=urlopen(URL) + Staat = ujson.loads(url.read()) +except: + print URL , "nicht gefunden - öffne locale Datei..." + Staat = ujson.loads(open(file,'r').read()) + +for Ort in Staat: + if not "evernet" in Ort: + try: + Inhalt=urllib.urlopen(Staat[Ort]) + JSON=ujson.loads(Inhalt.read().replace('\r','')) + Fehler=0 + except: + print colored("Error in "+Ort+": ","red") + print Inhalt.read() + ujson.dumps(Inhalt.read()) + print colored("Error while ujson.loads(Inhalt.read().replace('\r',''))","red") + Fehler=1 + for Service in JSON: + if "services" in Service: + print "____________________________________________________________________________________" + if Fehler: + print colored("Ort: "+str(Ort),"red") #,"\tLink",Staat[Ort] + else: + print "Ort: ",Ort#,"\tLink",Staat[Ort] + print "____________________________________________________________________________________" + for k in JSON[Service]: + print "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" + for l in k: + print "-----------------------------------------------------------------" + print l , ":\t" , k[l] + + From ef758d7644e11155782f7795f623bdecbf24f565 Mon Sep 17 00:00:00 2001 From: Andrei Mitrofanow Date: Thu, 21 Apr 2016 10:50:19 +0200 Subject: [PATCH 5/5] =?UTF-8?q?=09ge=C3=A4ndert:=20=20=20=20=20=20=20contr?= =?UTF-8?q?ib/List=5FServices.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Die Datei List_Services wurde an die Summarized-URL: http://api.freifunk.net/data/ffSummarizedDir.json angepasst. --- contrib/List_Services.py | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/contrib/List_Services.py b/contrib/List_Services.py index 691424d..ed75845 100755 --- a/contrib/List_Services.py +++ b/contrib/List_Services.py @@ -5,37 +5,39 @@ from urlgrabber import urlopen from termcolor import colored -URL="https://raw.githubusercontent.com/freifunk/directory.api.freifunk.net/master/directory.json" -file="directory.json" +URL="http://api.freifunk.net/data/ffSummarizedDir.json" +file="ffSummarizedDir.json" try: url=urlopen(URL) - Staat = ujson.loads(url.read()) + Nation = ujson.loads(url.read()) except: print URL , "nicht gefunden - öffne locale Datei..." - Staat = ujson.loads(open(file,'r').read()) + Nation = ujson.loads(open(file,'r').read()) -for Ort in Staat: + +for Ort in Nation: if not "evernet" in Ort: - try: - Inhalt=urllib.urlopen(Staat[Ort]) - JSON=ujson.loads(Inhalt.read().replace('\r','')) - Fehler=0 - except: - print colored("Error in "+Ort+": ","red") - print Inhalt.read() - ujson.dumps(Inhalt.read()) - print colored("Error while ujson.loads(Inhalt.read().replace('\r',''))","red") - Fehler=1 - for Service in JSON: + Fehler=0 + #try: + # Inhalt=urllib.urlopen(Staat[Ort]) + # JSON=ujson.loads(Inhalt.read().replace('\r','')) + # Fehler=0 + #except: + # print colored("Error in "+Ort+": ","red") + # print Inhalt.read() + # ujson.dumps(Inhalt.read()) + # print colored("Error while ujson.loads(Inhalt.read().replace('\r',''))","red") + # Fehler=1 + for Service in Nation[Ort]: if "services" in Service: print "____________________________________________________________________________________" if Fehler: - print colored("Ort: "+str(Ort),"red") #,"\tLink",Staat[Ort] + print colored("Ort: "+str(Ort),"red") #,"\tLink",Nation[Ort] else: - print "Ort: ",Ort#,"\tLink",Staat[Ort] + print "Ort: ",Ort#,"\tLink",Nation[Ort] print "____________________________________________________________________________________" - for k in JSON[Service]: + for k in Nation[Ort][Service]: print "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" for l in k: print "-----------------------------------------------------------------"