ping.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:ResQ-Pi 作者: oprema 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号