From 1ee17c04404e0bbf42536a1f3906b5576edb0545 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sun, 12 Apr 2015 19:38:21 +0200 Subject: [PATCH 1/2] partially revert 3ec0874b774b29e3bdbc10102b8650f6c97a7d91 --- backend.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend.py b/backend.py index 7cd6630..685c606 100755 --- a/backend.py +++ b/backend.py @@ -147,7 +147,7 @@ if __name__ == '__main__': parser.add_argument('-a', '--aliases', help='Read aliases from FILE', - nargs='+', metavar='FILE') + nargs='+', default=[], metavar='FILE') parser.add_argument('-m', '--mesh', default=['bat0'], nargs='+', help='Use given batman-adv mesh interface(s) (defaults' From dfcb9a39408620ce8cc7648a0b4e359277de2b00 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Sun, 12 Apr 2015 19:50:21 +0200 Subject: [PATCH 2/2] batman: ensure /usr/sbin and /usr/local/sbin are in PATH --- lib/batman.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/batman.py b/lib/batman.py index 17f4db3..ee0a0fe 100644 --- a/lib/batman.py +++ b/lib/batman.py @@ -13,6 +13,14 @@ class Batman(object): self.mesh_interface = mesh_interface self.alfred_sock = alfred_sockpath + # ensure /usr/sbin and /usr/local/sbin are in PATH + env = os.environ + path = set(env['PATH'].split(':')) + path.add('/usr/sbin/') + path.add('/usr/local/sbin') + env['PATH'] = ':'.join(path) + self.environ = env + # compile regular expressions only once on startup self.mac_addr_pattern = re.compile(r'(([a-z0-9]{2}:){5}[a-z0-9]{2})') @@ -38,7 +46,7 @@ class Batman(object): cmd = ['batadv-vis', '-i', self.mesh_interface, '-f', 'json'] if self.alfred_sock: cmd.extend(['-u', self.alfred_sock]) - output = subprocess.check_output(cmd) + output = subprocess.check_output(cmd, env=self.environ) lines = output.splitlines() return self.vis_data_helper(lines) @@ -50,7 +58,7 @@ class Batman(object): cmd = ['batctl', '-m', self.mesh_interface, 'gwl', '-n'] if os.geteuid() > 0: cmd.insert(0, 'sudo') - output = subprocess.check_output(cmd) + output = subprocess.check_output(cmd, env=self.environ) output_utf8 = output.decode('utf-8') rows = output_utf8.splitlines() @@ -79,7 +87,7 @@ class Batman(object): cmd = ['batctl', '-m', self.mesh_interface, 'gw'] if os.geteuid() > 0: cmd.insert(0, 'sudo') - output = subprocess.check_output(cmd) + output = subprocess.check_output(cmd, env=self.environ) chunks = output.decode("utf-8").split() return chunks[0], chunks[3] if 3 in chunks else None