Send stderr of ping tracker to devnull (#7096)

When pinging an inaccessible device, OS errors like

    ping: sendto: No route to host

can occur. For a ping tracker this is not an error but rather a normal
situation. Thus, it makes sense to hide the error.
This commit is contained in:
Anders Melchiorsen 2017-04-16 04:00:01 +02:00 committed by Paulus Schoutsen
parent f7b6f8e8fb
commit 6cbe28a9cd

View File

@ -45,7 +45,9 @@ class Host(object):
def ping(self):
"""Send an ICMP echo request and return True if success."""
pinger = subprocess.Popen(self._ping_cmd, stdout=subprocess.PIPE)
pinger = subprocess.Popen(self._ping_cmd,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL)
try:
pinger.communicate()
return pinger.returncode == 0