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)
评论列表
文章目录