summaryrefslogtreecommitdiff
path: root/addons/hw_drivers/tools/helpers.py
diff options
context:
space:
mode:
authorlejeune quentin <qle@odoo.com>2020-02-25 11:16:00 +0000
committerlejeune quentin <qle@odoo.com>2020-02-25 14:08:49 +0000
commit17c181ac74aefa2bf3e43f8e945895e6105feec2 (patch)
tree83d39eee80577917afb0891df0c26dd6ba16894d /addons/hw_drivers/tools/helpers.py
parent965eef99d81f957ed222ad48d4027823c8728e80 (diff)
[FIX] hw_drievrs: Replace SSID on the first boot
We replace the SSID of the IoTBox with a unique SSID closes odoo/odoo#46255 X-original-commit: c847c1cb149e386331ff2e5b19a58862e1b66714 Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
Diffstat (limited to 'addons/hw_drivers/tools/helpers.py')
-rw-r--r--addons/hw_drivers/tools/helpers.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/addons/hw_drivers/tools/helpers.py b/addons/hw_drivers/tools/helpers.py
index f59de214d9d..0be09086e4d 100644
--- a/addons/hw_drivers/tools/helpers.py
+++ b/addons/hw_drivers/tools/helpers.py
@@ -129,6 +129,9 @@ def get_mac_address():
return netifaces.ifaddresses('wlan0')[netifaces.AF_LINK][0]['addr']
def get_ssid():
+ ap = subprocess.call(['systemctl', 'is-active', 'hostapd']) # if service is active return 0 else inactive
+ if not ap:
+ return subprocess.check_output(['grep', '-oP', '(?<=ssid=).*', '/etc/hostapd/hostapd.conf']).decode('utf-8').rstrip()
process_iwconfig = subprocess.Popen(['iwconfig'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
process_grep = subprocess.Popen(['grep', 'ESSID:"'], stdin=process_iwconfig.stdout, stdout=subprocess.PIPE)
return subprocess.check_output(['sed', 's/.*"\\(.*\\)"/\\1/'], stdin=process_grep.stdout).decode('utf-8').rstrip()