From e66731154b841dc84b14e1a391820c5956eb70d6 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Tue, 24 Mar 2015 17:41:02 +0100 Subject: [PATCH] pep8: some line length fixes --- GlobalRRD.py | 5 +++-- alfred.py | 8 +++++--- backend.py | 13 +++++++++---- batman.py | 24 ++++++++++++++++-------- 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/GlobalRRD.py b/GlobalRRD.py index b3cf31a..9c09549 100644 --- a/GlobalRRD.py +++ b/GlobalRRD.py @@ -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, diff --git a/alfred.py b/alfred.py index 720b946..2ab0117 100644 --- a/alfred.py +++ b/alfred.py @@ -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,8 +27,9 @@ def aliases(): try: # TODO: better pass lat, lng as a tuple? - node_alias['gps'] = "{lat}\x20{lng}".format(lat=node['location']['latitude'], - lng=node['location']['longitude']) + node_alias['gps'] = "{lat}\x20{lng}".\ + format(lat=node['location']['latitude'], + lng=node['location']['longitude']) except KeyError: pass diff --git a/backend.py b/backend.py index ff943ec..7b7d0e5 100755 --- a/backend.py +++ b/backend.py @@ -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() diff --git a/batman.py b/batman.py index 86ad4fe..ddd0bd5 100644 --- a/batman.py +++ b/batman.py @@ -30,30 +30,37 @@ class Batman(object): def vis_data_batctl_legacy(self): """ - Parse "batctl -m vd json -n" into an array of dictionaries. + Parse "batctl -m 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 -f json" into an array of dictionaries. + Parse "batadv-vis -i -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 gwl -n" into an array of dictionaries. + Parse "batctl -m 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 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':