]> xmof Git - DeDRM.git/commitdiff
Fix in keyfetch for obok on win10
authorjourneyman88 <36702557+journeyman88@users.noreply.github.com>
Mon, 1 Mar 2021 20:15:20 +0000 (21:15 +0100)
committerjourneyman88 <36702557+journeyman88@users.noreply.github.com>
Mon, 1 Mar 2021 20:15:20 +0000 (21:15 +0100)
According to calibre debug the ipconfig command returned some invalid utf-8 characters (I think is maybe an issue due to the Python2 switch-off as the 4.x version worked fine).
To solve this I've changed the external call and modified the regex to match both the output of "ipconfig" and that of "wmic".

Obok_plugin/obok/obok.py

index 6c43089dd713fa57ffe401fea8e2b5e2bec97333..a00003b3bb259f5be795a78bc1630e6869112765 100644 (file)
@@ -470,8 +470,8 @@ class KoboLibrary(object):
         """The list of all MAC addresses on this machine."""
         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('ipconfig /all', shell=True, stdout=subprocess.PIPE, text=True).stdout
+            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: