From 4b9413ba3732b8c680cfe52960b2bd79abce44ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Aim=C3=A9?= Date: Tue, 15 Jun 2021 18:20:31 +0200 Subject: [PATCH] Update network.py --- server/frontend/app/classes/network.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/server/frontend/app/classes/network.py b/server/frontend/app/classes/network.py index b21ffb4..67440b0 100644 --- a/server/frontend/app/classes/network.py +++ b/server/frontend/app/classes/network.py @@ -344,14 +344,17 @@ class Network(object): Deduce the channel to have for the AP in order to prevent kind of jamming between the two wifi interfaces. """ - if self.iface_out[0] == "w": - # Get the channel of the connected interface - sh = sp.Popen(["iw", self.iface_out, "info"], - stdout=sp.PIPE, stderr=sp.PIPE).communicate() - res = re.search("channel ([0-9]{1,2})", sh[0].decode('utf8')) - chn = res.group(1) + try: + if self.iface_out[0] == "w": + # Get the channel of the connected interface + sh = sp.Popen(["iw", self.iface_out, "info"], + stdout=sp.PIPE, stderr=sp.PIPE).communicate() + res = re.search("channel ([0-9]{1,2})", sh[0].decode('utf8')) + chn = res.group(1) - # Return a good candidate. - return "11" if int(chn) < 7 else "1" - else: + # Return a good candidate. + return "11" if int(chn) < 7 else "1" + else: + return "1" + except: return "1"