#19855: uuid.get_node now looks on the PATH for executables on unix.
Patch by Serhiy Storchaka.
This commit is contained in:
parent
320b39158e
commit
4be1e24933
19
Lib/uuid.py
19
Lib/uuid.py
|
@ -312,16 +312,18 @@ class UUID(object):
|
|||
return int((self.int >> 76) & 0xf)
|
||||
|
||||
def _find_mac(command, args, hw_identifiers, get_index):
|
||||
import os
|
||||
for dir in ['', '/sbin/', '/usr/sbin']:
|
||||
executable = os.path.join(dir, command)
|
||||
if not os.path.exists(executable):
|
||||
continue
|
||||
import os, shutil
|
||||
executable = shutil.which(command)
|
||||
if executable is None:
|
||||
path = os.pathsep.join(('/sbin', '/usr/sbin'))
|
||||
executable = shutil.which(command, path=path)
|
||||
if executable is None:
|
||||
return None
|
||||
|
||||
try:
|
||||
# LC_ALL to get English output, 2>/dev/null to
|
||||
# LC_MESSAGES to get English output, 2>/dev/null to
|
||||
# prevent output on stderr
|
||||
cmd = 'LC_ALL=C %s %s 2>/dev/null' % (executable, args)
|
||||
cmd = 'LC_MESSAGES=C %s %s 2>/dev/null' % (executable, args)
|
||||
with os.popen(cmd) as pipe:
|
||||
for line in pipe:
|
||||
words = line.lower().split()
|
||||
|
@ -338,8 +340,7 @@ def _find_mac(command, args, hw_identifiers, get_index):
|
|||
# real MAC address
|
||||
pass
|
||||
except IOError:
|
||||
continue
|
||||
return None
|
||||
pass
|
||||
|
||||
def _ifconfig_getnode():
|
||||
"""Get the hardware address on Unix by running ifconfig."""
|
||||
|
|
|
@ -29,6 +29,10 @@ Core and Builtins
|
|||
Library
|
||||
-------
|
||||
|
||||
- Issue #19855: uuid.getnode() on Unix now looks on the PATH for the
|
||||
executables used to find the mac address, with /sbin and /usr/sbin as
|
||||
fallbacks.
|
||||
|
||||
- Issue #20007: HTTPResponse.read(0) no more prematurely closes connection.
|
||||
Original patch by Simon Sapin.
|
||||
|
||||
|
|
Loading…
Reference in New Issue