Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gethostbyname #7

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions contrib/List_Services.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/python
# coding: utf-8

import ujson, urllib
from urlgrabber import urlopen
from termcolor import colored

URL="http://api.freifunk.net/data/ffSummarizedDir.json"
file="ffSummarizedDir.json"

try:
url=urlopen(URL)
Nation = ujson.loads(url.read())
except:
print URL , "nicht gefunden - öffne locale Datei..."
Nation = ujson.loads(open(file,'r').read())


for Ort in Nation:
if not "evernet" in Ort:
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",Nation[Ort]
else:
print "Ort: ",Ort#,"\tLink",Nation[Ort]
print "____________________________________________________________________________________"
for k in Nation[Ort][Service]:
print "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
for l in k:
print "-----------------------------------------------------------------"
print l , ":\t" , k[l]


10 changes: 9 additions & 1 deletion contrib/ffapi-update-nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,15 @@ def getServices():
with open(olsrServices, 'r') as services:
servicesText = services.read().splitlines()
services.closed
return servicesText
ServiceList=[]
for service in servicesText:
URL=""
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():
Expand Down