From 14947cd10cd502e21f21a5b144d9a185f8ba9f3a Mon Sep 17 00:00:00 2001 From: journeyman88 <36702557+journeyman88@users.noreply.github.com> Date: Mon, 26 Apr 2021 12:24:57 +0200 Subject: [PATCH] Update obok.py Changed MAC address fetching code to address possibile regression --- Obok_plugin/obok/obok.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Obok_plugin/obok/obok.py b/Obok_plugin/obok/obok.py index ba480ec..00f2207 100644 --- a/Obok_plugin/obok/obok.py +++ b/Obok_plugin/obok/obok.py @@ -471,11 +471,18 @@ class KoboLibrary(object): macaddrs = [] if sys.platform.startswith('win'): c = re.compile('\s?(' + '[0-9a-f]{2}[:\-]' * 5 + '[0-9a-f]{2})(\s|$)', re.IGNORECASE) - output = subprocess.Popen('wmic nic where PhysicalAdapter=True get MACAddress', shell=True, stdout=subprocess.PIPE, text=True).stdout - for line in output: - m = c.search(line) - if m: - macaddrs.append(re.sub("-", ":", m.group(1)).upper()) + try: + output = subprocess.Popen('ipconfig /all', shell=True, stdout=subprocess.PIPE, text=True).stdout + for line in output: + m = c.search(line) + if m: + macaddrs.append(re.sub("-", ":", m.group(1)).upper()) + except: + output = subprocess.Popen('wmic nic where PhysicalAdapter=True get MACAddress', shell=True, stdout=subprocess.PIPE, text=True).stdout + for line in output: + m = c.search(line) + if m: + macaddrs.append(re.sub("-", ":", m.group(1)).upper()) elif sys.platform.startswith('darwin'): c = re.compile('\s(' + '[0-9a-f]{2}:' * 5 + '[0-9a-f]{2})(\s|$)', re.IGNORECASE) output = subprocess.check_output('/sbin/ifconfig -a', shell=True, encoding='utf-8')