diff options
Diffstat (limited to 'Lib/uuid.py')
-rw-r--r-- | Lib/uuid.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/uuid.py b/Lib/uuid.py index 3cd67fc..32a48ea 100644 --- a/Lib/uuid.py +++ b/Lib/uuid.py @@ -419,7 +419,7 @@ def _netstat_getnode(): def _ipconfig_getnode(): """Get the hardware address on Windows by running ipconfig.exe.""" - import os, re + import os, re, subprocess dirs = ['', r'c:\windows\system32', r'c:\winnt\system32'] try: import ctypes @@ -430,11 +430,13 @@ def _ipconfig_getnode(): pass for dir in dirs: try: - pipe = os.popen(os.path.join(dir, 'ipconfig') + ' /all') + proc = subprocess.Popen([os.path.join(dir, 'ipconfig'), '/all'], + stdout=subprocess.PIPE, + encoding="oem") except OSError: continue - with pipe: - for line in pipe: + with proc: + for line in proc.stdout: value = line.split(':')[-1].strip().lower() if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value): return int(value.replace('-', ''), 16) |