From b143e3f2e5b062072d611ef99199c6e627163cd5 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Wed, 25 Mar 2015 13:27:54 +0100 Subject: [PATCH] batman: add batadv-vis socket support, needs at least alfred 2014.4.0 --- backend.py | 2 +- lib/batman.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/backend.py b/backend.py index 3eaeaf1..173b127 100755 --- a/backend.py +++ b/backend.py @@ -50,7 +50,7 @@ def main(params): bm = list(map(lambda d: (d.vis_data(True), d.gateway_list()), - map(Batman, params['mesh']))) + map(Batman, params['mesh'], params['alfred_sock']))) 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) diff --git a/lib/batman.py b/lib/batman.py index ddd0bd5..a4aeca2 100644 --- a/lib/batman.py +++ b/lib/batman.py @@ -8,8 +8,9 @@ class Batman(object): Bindings for B.A.T.M.A.N. Advanced commandline interface "batctl" """ - def __init__(self, mesh_interface='bat0'): + def __init__(self, mesh_interface='bat0', alfred_sockpath=None): self.mesh_interface = mesh_interface + self.alfred_sock = alfred_sockpath def vis_data(self, batadv_vis=False): vds = self.vis_data_batctl_legacy() @@ -44,8 +45,10 @@ class Batman(object): Parse "batadv-vis -i -f json" into an array of dictionaries. """ - output = subprocess.check_output( - ['batadv-vis', '-i', self.mesh_interface, '-f', 'json']) + cmd = ['batadv-vis', '-i', self.mesh_interface, '-f', 'json'] + if self.alfred_sock: + cmd.extend(['-u', self.alfred_sock]) + output = subprocess.check_output(cmd) lines = output.splitlines() return self.vis_data_helper(lines)