From 31084becd5c2ff05014cc9d942a4d1acf7b50b3c Mon Sep 17 00:00:00 2001 From: Peter Peterson Date: Fri, 2 Sep 2011 15:52:01 -0400 Subject: [PATCH] Moved nagios mode to move to new email message. Refs #5. --- CodeNotifier.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CodeNotifier.py b/CodeNotifier.py index 3daf5a3..dd21caa 100755 --- a/CodeNotifier.py +++ b/CodeNotifier.py @@ -218,9 +218,10 @@ def __getTicket(self, url): # give up return None -class NagiosMsg(EmailMsg): +class NagiosMsg(StatusMsg): def __init__(self, config, email_msg, **kwargs): - EmailMsg.__init__(self, config, email_msg, **kwargs) + StatusMsg.__init__(self, config, **kwargs) + self.__email = EmailMsg(email_msg) self.__initSubject() self.__initBody() status = [self.__subject__] @@ -231,7 +232,7 @@ def __init__(self, config, email_msg, **kwargs): self.setMsg(" - ".join(status)) def __initSubject(self): - subject = self.getSubject().strip() + subject = self.__email.subject subject = re.sub(r'\s*\*+\s*', '', subject) subject = re.sub(r'\s+alert\s+-', ':', subject) subject = re.sub('/', ' ', subject) @@ -247,7 +248,7 @@ def __sanitize(self, text): return text.strip() def __initBody(self): - body = self.getEmailBody() + body = self.__email.body # get all of the keys self.__note_type__ = getProperty(body, r'^Notification Type:\s+(\w+)$') @@ -290,7 +291,7 @@ def setHost(self, host = ""): self.__host = host def __parseSubject(self): - subject = self.getSubject().strip() + subject = self.subject if len(subject.strip()) <= 0: return ""