Commit 69cd87b5 authored by Brian Curtin's avatar Brian Curtin

Shift the pipe-using code into an else block, then close the pipe

in finally. Removes two ResourceWarnings.
parent a277ec4a
...@@ -373,10 +373,13 @@ def _ipconfig_getnode(): ...@@ -373,10 +373,13 @@ def _ipconfig_getnode():
pipe = os.popen(os.path.join(dir, 'ipconfig') + ' /all') pipe = os.popen(os.path.join(dir, 'ipconfig') + ' /all')
except IOError: except IOError:
continue continue
for line in pipe: else:
value = line.split(':')[-1].strip().lower() for line in pipe:
if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value): value = line.split(':')[-1].strip().lower()
return int(value.replace('-', ''), 16) if re.match('([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]', value):
return int(value.replace('-', ''), 16)
finally:
pipe.close()
def _netbios_getnode(): def _netbios_getnode():
"""Get the hardware address on Windows using NetBIOS calls. """Get the hardware address on Windows using NetBIOS calls.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment