summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/webiopi/devices/sensor/icmp.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/python/webiopi/devices/sensor/icmp.py b/python/webiopi/devices/sensor/icmp.py
index 8a4065d..37028fa 100644
--- a/python/webiopi/devices/sensor/icmp.py
+++ b/python/webiopi/devices/sensor/icmp.py
@@ -36,7 +36,8 @@ class ICMP(Duration):
36 return Duration.__family__(self) 36 return Duration.__family__(self)
37 37
38 def __getMilliseconds__(self): 38 def __getMilliseconds__(self):
39 return self.echo(self.ip, 1) * 1000 39 sec = self.echo(self.ip, 1)
40 return sec * 1000 if sec > 0 else -1
40 41
41 def close(self): 42 def close(self):
42 pass 43 pass
@@ -79,7 +80,7 @@ class ICMP(Duration):
79 while True: 80 while True:
80 ready = select.select([sock], [], [], timeout) 81 ready = select.select([sock], [], [], timeout)
81 if ready[0] == []: # Timeout 82 if ready[0] == []: # Timeout
82 return 83 return -1
83 84
84 time_received = time() 85 time_received = time()
85 rec_packet, addr = sock.recvfrom(1024) 86 rec_packet, addr = sock.recvfrom(1024)
@@ -91,7 +92,7 @@ class ICMP(Duration):
91 92
92 timeout -= time_received - time_sent 93 timeout -= time_received - time_sent
93 if timeout <= 0: 94 if timeout <= 0:
94 return 95 return -1
95 96
96 def echo(self, dest_addr, timeout=1): 97 def echo(self, dest_addr, timeout=1):
97 """ 98 """