Ejemplo n.º 1
0
 def send_email(self, log_lines):
     post_result = requests.post(
         "https://api.mailgun.net/v3/" + self.mailgun_domain_name + "/messages",
         auth=("api", self.mailgun_api_key),
         data={"from": "Marvin <mailgun@" + self.mailgun_domain_name + ">",
               "to": [self.email_address],
               "subject": "Marvin log",
               "text": log_lines})
     if post_result.status_code == 200:
         return NotificationEvent(NotificationEventType.EMAIL_SENT, super().NOTIFICATION_LOG_MESSAGE + self.NOTIFICATION_TYPE)
     else:
         return NotificationEvent(NotificationEventType.EMAIL_FAILURE, super().NOTIFICATION_FAILED_LOG_MESSAGE + self.NOTIFICATION_TYPE)
Ejemplo n.º 2
0
 def send_pushover(self, log_lines):
     conn = http.client.HTTPSConnection("api.pushover.net:443")
     conn.request(
         "POST", "/1/messages.json",
         urllib.parse.urlencode({
             "token": self.pushover_app_token,
             "user": self.pushover_user_key,
             "message": log_lines,
         }), {"Content-type": "application/x-www-form-urlencoded"})
     if conn.getresponse().status == 200:
         return NotificationEvent(
             NotificationEventType.PUSHOVER_SENT,
             super().NOTIFICATION_LOG_MESSAGE + self.NOTIFICATION_TYPE)
     else:
         return NotificationEvent(
             NotificationEventType.PUSHOVER_FAILURE,
             super().NOTIFICATION_FAILED_LOG_MESSAGE +
             self.NOTIFICATION_TYPE)