def __ping(self, title):
hostname = "www.google.com"
was_down = False
setproctitle.setproctitle(title)
while not self.exit.is_set():
# ping hostname ...
response = os.system("ping -c 1 -w2 " + hostname + " > /dev/null 2>&1")
# then check the response
if response != 0:
self._log.error(hostname + ' is unreachable!')
was_down = False
elif was_down:
self._log.error(hostname + ' is up again!')
if self._gpio != None:
self._gpio.led(1, True) # LED 1 on
time.sleep(0.2)
self._gpio.led(1, False) # LED 1 off
time.sleep(15)
评论列表
文章目录