pep8: some line length fixes
This commit is contained in:
parent
5b14ed5ad9
commit
e66731154b
|
@ -23,8 +23,9 @@ class GlobalRRD(RRD):
|
||||||
super().__init__(os.path.join(directory, "nodes.rrd"))
|
super().__init__(os.path.join(directory, "nodes.rrd"))
|
||||||
self.ensure_sanity(self.ds_list, self.rra_list, step=60)
|
self.ensure_sanity(self.ds_list, self.rra_list, step=60)
|
||||||
|
|
||||||
def update(self, nodeCount, clientCount):
|
# TODO: fix this, python does not support function overloading
|
||||||
super().update({'nodes': nodeCount, 'clients': clientCount})
|
def update(self, node_count, client_count):
|
||||||
|
super().update({'nodes': node_count, 'clients': client_count})
|
||||||
|
|
||||||
def graph(self, filename, timeframe):
|
def graph(self, filename, timeframe):
|
||||||
args = ["rrdtool", 'graph', filename,
|
args = ["rrdtool", 'graph', filename,
|
||||||
|
|
|
@ -3,7 +3,8 @@ import json
|
||||||
|
|
||||||
|
|
||||||
def _fetch(data_type):
|
def _fetch(data_type):
|
||||||
output = subprocess.check_output(["alfred-json", "-z", "-f", "json", "-r", str(data_type)])
|
output = subprocess.check_output(
|
||||||
|
["alfred-json", "-z", "-f", "json", "-r", str(data_type)])
|
||||||
return json.loads(output.decode("utf-8")).values()
|
return json.loads(output.decode("utf-8")).values()
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,8 +27,9 @@ def aliases():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# TODO: better pass lat, lng as a tuple?
|
# TODO: better pass lat, lng as a tuple?
|
||||||
node_alias['gps'] = "{lat}\x20{lng}".format(lat=node['location']['latitude'],
|
node_alias['gps'] = "{lat}\x20{lng}".\
|
||||||
lng=node['location']['longitude'])
|
format(lat=node['location']['latitude'],
|
||||||
|
lng=node['location']['longitude'])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
13
backend.py
13
backend.py
|
@ -38,16 +38,20 @@ def main(params):
|
||||||
for node_id, node in nodedb['nodes'].items():
|
for node_id, node in nodedb['nodes'].items():
|
||||||
node['flags']['online'] = False
|
node['flags']['online'] = False
|
||||||
|
|
||||||
nodes.import_nodeinfo(nodedb['nodes'], alfred.nodeinfo(), now, assume_online=True)
|
nodes.import_nodeinfo(nodedb['nodes'], alfred.nodeinfo(),
|
||||||
|
now, assume_online=True)
|
||||||
|
|
||||||
for aliases in params['aliases']:
|
for aliases in params['aliases']:
|
||||||
with open(aliases, 'r') as f:
|
with open(aliases, 'r') as f:
|
||||||
nodes.import_nodeinfo(nodedb['nodes'], json.load(f), now, assume_online=False)
|
nodes.import_nodeinfo(nodedb['nodes'], json.load(f),
|
||||||
|
now, assume_online=False)
|
||||||
|
|
||||||
nodes.reset_statistics(nodedb['nodes'])
|
nodes.reset_statistics(nodedb['nodes'])
|
||||||
nodes.import_statistics(nodedb['nodes'], alfred.statistics())
|
nodes.import_statistics(nodedb['nodes'], alfred.statistics())
|
||||||
|
|
||||||
bm = list(map(lambda d: (d.vis_data(True), d.gateway_list()), map(Batman, params['mesh'])))
|
bm = list(map(lambda d:
|
||||||
|
(d.vis_data(True), d.gateway_list()),
|
||||||
|
map(Batman, params['mesh'])))
|
||||||
for vis_data, gateway_list in bm:
|
for vis_data, gateway_list in bm:
|
||||||
nodes.import_mesh_ifs_vis_data(nodedb['nodes'], vis_data)
|
nodes.import_mesh_ifs_vis_data(nodedb['nodes'], vis_data)
|
||||||
nodes.import_vis_clientcount(nodedb['nodes'], vis_data)
|
nodes.import_vis_clientcount(nodedb['nodes'], vis_data)
|
||||||
|
@ -74,7 +78,8 @@ def main(params):
|
||||||
json.dump({'batadv': json_graph.node_link_data(batadv_graph)}, f)
|
json.dump({'batadv': json_graph.node_link_data(batadv_graph)}, f)
|
||||||
|
|
||||||
scriptdir = os.path.dirname(os.path.realpath(__file__))
|
scriptdir = os.path.dirname(os.path.realpath(__file__))
|
||||||
rrd = RRD(scriptdir + '/nodedb/', params['destination_directory'] + '/nodes')
|
rrd = RRD("{}/nodedb/".format(scriptdir),
|
||||||
|
"{}/nodes".format(params['destination_directory']))
|
||||||
rrd.update_database(nodedb['nodes'])
|
rrd.update_database(nodedb['nodes'])
|
||||||
rrd.update_images()
|
rrd.update_images()
|
||||||
|
|
||||||
|
|
24
batman.py
24
batman.py
|
@ -30,30 +30,37 @@ class Batman(object):
|
||||||
|
|
||||||
def vis_data_batctl_legacy(self):
|
def vis_data_batctl_legacy(self):
|
||||||
"""
|
"""
|
||||||
Parse "batctl -m <mesh_interface> vd json -n" into an array of dictionaries.
|
Parse "batctl -m <mesh_interface> vd json -n"
|
||||||
|
into an array of dictionaries.
|
||||||
"""
|
"""
|
||||||
output = subprocess.check_output(['batctl', '-m', self.mesh_interface, 'vd', 'json', '-n'])
|
output = subprocess.check_output(
|
||||||
|
['batctl', '-m', self.mesh_interface, 'vd', 'json', '-n'])
|
||||||
lines = output.splitlines()
|
lines = output.splitlines()
|
||||||
vds = self.vis_data_helper(lines)
|
vds = self.vis_data_helper(lines)
|
||||||
return vds
|
return vds
|
||||||
|
|
||||||
def vis_data_batadv_vis(self):
|
def vis_data_batadv_vis(self):
|
||||||
"""
|
"""
|
||||||
Parse "batadv-vis -i <mesh_interface> -f json" into an array of dictionaries.
|
Parse "batadv-vis -i <mesh_interface> -f json"
|
||||||
|
into an array of dictionaries.
|
||||||
"""
|
"""
|
||||||
output = subprocess.check_output(['batadv-vis', '-i', self.mesh_interface, '-f', 'json'])
|
output = subprocess.check_output(
|
||||||
|
['batadv-vis', '-i', self.mesh_interface, '-f', 'json'])
|
||||||
lines = output.splitlines()
|
lines = output.splitlines()
|
||||||
return self.vis_data_helper(lines)
|
return self.vis_data_helper(lines)
|
||||||
|
|
||||||
def gateway_list(self):
|
def gateway_list(self):
|
||||||
"""
|
"""
|
||||||
Parse "batctl -m <mesh_interface> gwl -n" into an array of dictionaries.
|
Parse "batctl -m <mesh_interface> gwl -n"
|
||||||
|
into an array of dictionaries.
|
||||||
"""
|
"""
|
||||||
output = subprocess.check_output(['batctl', '-m', self.mesh_interface, 'gwl', '-n'])
|
output = subprocess.check_output(
|
||||||
|
['batctl', '-m', self.mesh_interface, 'gwl', '-n'])
|
||||||
output_utf8 = output.decode('utf-8')
|
output_utf8 = output.decode('utf-8')
|
||||||
lines = output_utf8.splitlines()
|
lines = output_utf8.splitlines()
|
||||||
|
|
||||||
own_mac = re.match(r"^.*MainIF/MAC: [^/]+/([0-9a-f:]+).*$", lines[0]).group(1)
|
own_mac = re.match(r"^.*MainIF/MAC: [^/]+/([0-9a-f:]+).*$",
|
||||||
|
lines[0]).group(1)
|
||||||
|
|
||||||
gateways = []
|
gateways = []
|
||||||
gw_mode = self.gateway_mode()
|
gw_mode = self.gateway_mode()
|
||||||
|
@ -71,7 +78,8 @@ class Batman(object):
|
||||||
"""
|
"""
|
||||||
Parse "batctl -m <mesh_interface> gw"
|
Parse "batctl -m <mesh_interface> gw"
|
||||||
"""
|
"""
|
||||||
output = subprocess.check_output(['batctl', '-m', self.mesh_interface, 'gw'])
|
output = subprocess.check_output(
|
||||||
|
['batctl', '-m', self.mesh_interface, 'gw'])
|
||||||
elements = output.decode("utf-8").split()
|
elements = output.decode("utf-8").split()
|
||||||
mode = elements[0]
|
mode = elements[0]
|
||||||
if mode == 'server':
|
if mode == 'server':
|
||||||
|
|
Loading…
Reference in a new issue