summaryrefslogtreecommitdiff
diff options
authorJeff Lane <jeffrey.lane@canonical.com>2014-12-05 11:16:16 -0500
committerJeff Lane <jeffrey.lane@canonical.com>2014-12-05 11:16:16 -0500
commite9f03619e99b0a6f88eb40fe4d87624651599ac4 (patch)
tree841ef944984aab4de5be1f079630c828a6beef3b
parentf83401e28ac22397ea7b743a2ee7a24d643043e1 (diff)
Fixed devnull redirects to work on all python3 versions. subprocess.DEVNULL was not defined in Python 3.2, causing script failure on Precise
-rwxr-xr-xbin/network10
1 files changed, 6 insertions, 4 deletions
diff --git a/bin/network b/bin/network
index 73d7584..cf20bd7 100755
--- a/bin/network
+++ b/bin/network
@@ -458,8 +458,9 @@ def can_ping(the_interface, test_target):
working_interface = True
try:
- check_call(["ping", "-I", the_interface, "-c", "1", test_target],
- stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+ with open(os.devnull, 'wb') as DEVNULL:
+ check_call(["ping", "-I", the_interface, "-c", "1", test_target],
+ stdout=DEVNULL, stderr=DEVNULL)
except CalledProcessError as excp:
working_interface = False
logging.warning("Ping failure on %s (%s)", the_interface, excp)
@@ -577,8 +578,9 @@ def interface_test(args):
temp.seek(0)
try:
# Harmless "RTNETLINK answers: File exists" messages on stderr
- check_call(["ip", "route", "restore"], stdin=temp,
- stderr=subprocess.DEVNULL)
+ with open(os.devnull, 'wb') as DEVNULL:
+ check_call(["ip", "route", "restore"], stdin=temp,
+ stderr=DEVNULL)
except CalledProcessError as restore_failure:
logging.warning("Unable to restore routing table: %s", restore_failure)
temp.close()