2012-06-05 17:40:21 +02:00
|
|
|
#!/usr/bin/env python3
|
2012-02-17 02:09:21 +01:00
|
|
|
|
|
|
|
# TODO
|
|
|
|
# Gatewayliste
|
|
|
|
# aliases.json
|
|
|
|
|
2012-04-28 23:06:34 +02:00
|
|
|
import json
|
2012-02-17 02:09:21 +01:00
|
|
|
import fileinput
|
|
|
|
import argparse
|
|
|
|
|
2012-05-11 18:39:26 +02:00
|
|
|
from nodedb import NodeDB
|
|
|
|
from d3mapbuilder import D3MapBuilder
|
2012-05-11 14:12:41 +02:00
|
|
|
|
2012-06-15 18:27:51 +02:00
|
|
|
# Force encoding to UTF-8
|
|
|
|
import locale # Ensures that subsequent open()s
|
|
|
|
locale.getpreferredencoding = lambda: 'UTF-8' # are UTF-8 encoded.
|
|
|
|
|
|
|
|
import sys
|
|
|
|
sys.stdin = open('/dev/stdin', 'r')
|
|
|
|
sys.stdout = open('/dev/stdout', 'w')
|
|
|
|
sys.stderr = open('/dev/stderr', 'w')
|
|
|
|
|
2012-02-17 02:09:21 +01:00
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
|
|
|
|
parser.add_argument('-a', '--aliases',
|
|
|
|
help='read aliases from FILE',
|
|
|
|
metavar='FILE')
|
|
|
|
|
|
|
|
parser.add_argument('-g', '--gateway', action='append',
|
|
|
|
help='MAC of a gateway')
|
|
|
|
|
|
|
|
parser.add_argument('batmanjson', help='output of batman vd json')
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
options = vars(args)
|
|
|
|
|
2012-05-11 18:39:26 +02:00
|
|
|
db = NodeDB()
|
2012-02-17 02:09:21 +01:00
|
|
|
|
2012-05-11 18:39:26 +02:00
|
|
|
db.import_batman(list(fileinput.input(options['batmanjson'])))
|
2012-02-17 02:09:21 +01:00
|
|
|
|
2012-06-12 02:09:44 +02:00
|
|
|
db.import_wikigps("http://freifunk.metameute.de/Knoten")
|
|
|
|
|
2012-02-17 02:09:21 +01:00
|
|
|
if options['aliases']:
|
2012-05-11 18:39:26 +02:00
|
|
|
db.import_aliases(json.load(open(options['aliases'])))
|
2012-02-17 02:09:21 +01:00
|
|
|
|
2012-04-28 23:06:34 +02:00
|
|
|
if options['gateway']:
|
2012-05-11 18:39:26 +02:00
|
|
|
db.mark_gateways(options['gateway'])
|
2012-02-17 02:09:21 +01:00
|
|
|
|
2012-05-11 18:39:26 +02:00
|
|
|
m = D3MapBuilder(db)
|
2012-02-17 02:09:21 +01:00
|
|
|
|
2012-05-11 18:39:26 +02:00
|
|
|
print(m.build())
|