pushover_notifier.py 文件源码

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

项目:oversight 作者: hebenon 项目源码 文件源码
def handle_trigger_event(self, sender, **data):
        # Pushover doesn't support images, so just send the event.
        notification_data = {
            "user": self.pushover_user,
            "token": self.pushover_token,
            "message": "Camera %s, event: %s" % (data['source'], data['prediction']),
            "timestamp": calendar.timegm(data['timestamp'].timetuple())
        }

        # Optionally, set the device.
        if self.pushover_device:
            notification_data['device'] = self.pushover_device

        try:
            r = requests.post("https://api.pushover.net/1/messages.json", data=notification_data)

            if r.status_code != 200:
                logger.error("Failed to send notification, (%d): %s" % (r.status_code, r.text))
        except requests.ConnectionError, e:
            logger.error("Connection Error:", e)
        except requests.HTTPError, e:
            logger.error("HTTP Error:", e)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号