[llvm-commits] [zorg] r97247 - /zorg/trunk/zorg/buildbot/util/InformativeMailNotifier.py

Daniel Dunbar daniel at zuster.org
Fri Feb 26 11:18:06 PST 2010


Author: ddunbar
Date: Fri Feb 26 13:18:06 2010
New Revision: 97247

URL: http://llvm.org/viewvc/llvm-project?rev=97247&view=rev
Log:
Update InformativeMailNotifier to use the new messageFormatter interface.


Modified:
    zorg/trunk/zorg/buildbot/util/InformativeMailNotifier.py

Modified: zorg/trunk/zorg/buildbot/util/InformativeMailNotifier.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/zorg/buildbot/util/InformativeMailNotifier.py?rev=97247&r1=97246&r2=97247&view=diff
==============================================================================
--- zorg/trunk/zorg/buildbot/util/InformativeMailNotifier.py (original)
+++ zorg/trunk/zorg/buildbot/util/InformativeMailNotifier.py Fri Feb 26 13:18:06 2010
@@ -10,45 +10,48 @@
     compare_attrs = (mail.MailNotifier.compare_attrs +
                      ["num_lines", "only_failure_logs"])
 
-    # Remove customMesg from the compare_attrs, that would lead to
+    # Remove messageFormatter from the compare_attrs, that would lead to
     # recursion, and is checked by the class test.
-    compare_attrs.remove("customMesg")
-
-    # FIXME: The customMessage interface is fairly inefficient, switch to
-    # something new when it becomes available.
+    compare_attrs.remove("messageFormatter")
 
     def __init__(self, 
                  num_lines = 10, only_failure_logs = True,
                  *attrs, **kwargs):
-        mail.MailNotifier.__init__(self, customMesg=self.customMessage, 
+        mail.MailNotifier.__init__(self,
+                                   messageFormatter=self.informative_formatter, 
                                    *attrs, **kwargs)
         self.num_lines = num_lines
         self.only_failure_logs = only_failure_logs
-
-    def customMessage(self, attrs):
-        # FIXME: It would be nice to find a way to communicate with
-        # the lookup mechanism so that we could note any committers
-        # who we weren't able to send email to.
-
+        
+    def informative_formatter(self, mode, name, build, results, status):
         # Get the standard message.
-        data = mail.message(attrs)[0]
-
+        data = self.defaultMessage(mode, name, build, results, status)['body']
         data += '\n' + '='*80 + '\n\n'
 
-        # Append addition information on the changes.
-        data += 'CHANGES:\n'
-        data += '\n\n'.join([c.asText() for c in attrs['changes']])
-        data += '\n\n'
+        # Append additional information on the changes.
+        ss = build.getSourceStamp()
+        if ss:
+            data += 'CHANGES:\n'
+            data += '\n\n'.join([c.asText() for c in ss.changes])
+            data += '\n\n'
+        else:
+            data += 'NO SOURCE STAMP (CHANGES UNAVAILABLE)'
+            data += '\n\n'
     
         # Append log files.
         if self.num_lines:
             data += 'LOGS:\n'
-            for name, url, lines, logstatus in attrs['logs']:
-                if (self.only_failure_logs and logstatus != builder.FAILURE):
+            for logf in build.getLogs():
+                logStep = logf.getStep()
+                logStatus,_ = logStep.getResults()
+                if (self.only_failure_logs and logStatus != builder.FAILURE):
                     continue
-
-                data += "Last %d lines of '%s':\n" % (self.num_lines, name)
-                data += '\t' + '\n\t'.join(lines[-self.num_lines:])
+                
+                trailingLines = logf.getText().splitlines()[-self.num_lines:]
+                data += "Last %d lines of '%s':\n" % (self.num_lines,
+                                                      logf.getName())
+                data += '\t' + '\n\t'.join(trailingLines)
                 data += '\n\n'
 
-        return (data, 'plain')
+        return { 'body' : data,
+                 'type' : 'plain' }





More information about the llvm-commits mailing list