pep8: some line length fixes

influxdb
Martin Weinelt 2015-03-24 17:41:02 +01:00
parent 5b14ed5ad9
commit e66731154b
4 changed files with 33 additions and 17 deletions

View File

@ -23,8 +23,9 @@ class GlobalRRD(RRD):
super().__init__(os.path.join(directory, "nodes.rrd"))
self.ensure_sanity(self.ds_list, self.rra_list, step=60)
def update(self, nodeCount, clientCount):
super().update({'nodes': nodeCount, 'clients': clientCount})
# TODO: fix this, python does not support function overloading
def update(self, node_count, client_count):
super().update({'nodes': node_count, 'clients': client_count})
def graph(self, filename, timeframe):
args = ["rrdtool", 'graph', filename,

View File

@ -3,7 +3,8 @@ import json
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()
@ -26,7 +27,8 @@ def aliases():
try:
# 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}".\
format(lat=node['location']['latitude'],
lng=node['location']['longitude'])
except KeyError:
pass

View File

@ -38,16 +38,20 @@ def main(params):
for node_id, node in nodedb['nodes'].items():
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']:
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.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:
nodes.import_mesh_ifs_vis_data(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)
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_images()

View File

@ -30,30 +30,37 @@ class Batman(object):
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()
vds = self.vis_data_helper(lines)
return vds
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()
return self.vis_data_helper(lines)
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')
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 = []
gw_mode = self.gateway_mode()
@ -71,7 +78,8 @@ class Batman(object):
"""
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()
mode = elements[0]
if mode == 'server':