ajack       2004/07/21 07:54:34

  Modified:    python/gump/model project.py module.py
               .        gumpy.py
               python/gump/notify notification.py logic.py notifier.py
               python/gump/document/xdocs documenter.py
  Log:
  More than a few notification fixes...
  
  Revision  Changes    Path
  1.91      +15 -1     gump/python/gump/model/project.py
  
  Index: project.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/model/project.py,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- project.py        19 Jul 2004 20:34:00 -0000      1.90
  +++ project.py        21 Jul 2004 14:54:34 -0000      1.91
  @@ -77,7 +77,7 @@
           self.url=None
           self.desc=''
           
  -        self.distributable=False
  +        self.redistributable=False
           self.packageMarker=None
           self.jvmargs=gump.process.command.Parameters()
           self.packageNames=None
  @@ -101,10 +101,24 @@
           Positioned.__del__(self)
           
       def hasNotifys(self):
  +        """
  +        Does this project have any notification addresses, and if not
  +        does the module?
  +        
  +        boolean true if some
  +        """
           if self.notifys: return True
  +        if self.module: return self.module.hasNotifys()
           return False
           
       def getNotifys(self):
  +        """
  +             Return the list of notification addresses for this project
  +             but if none, see if the module has any.
  +        """
  +        if not self.notifys: 
  +            if self.module:
  +                return self.module.getNotifys()
           return self.notifys
           
       def hasAnt(self):
  
  
  
  1.49      +14 -4     gump/python/gump/model/module.py
  
  Index: module.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/model/module.py,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- module.py 14 Jul 2004 23:36:28 -0000      1.48
  +++ module.py 21 Jul 2004 14:54:34 -0000      1.49
  @@ -15,7 +15,9 @@
   # limitations under the License.
   
   """
  -    This module contains information on
  +
  +    This module contains information on <module and it's repository references.
  +    
   """
   
   from time import localtime, strftime, tzname
  @@ -175,7 +177,8 @@
        self.svn=None
        self.artifacts=None
        
  -        self.packaged                =       False
  +        self.packaged                =       False 
  +        self.redistributable=   False
           
           # Changes were found (when updating)
        self.modified           =       False
  @@ -221,6 +224,10 @@
           return object                                          
         
       def resolve(self):
  +     """
  +     Resolving requires creating objects (in the correct lists/maps) for
  +     certain high level XML elements, e.g. <project.
  +     """
           
           if self.isResolved(): return
           
  @@ -406,6 +413,9 @@
               
           if self.hasDomChild('description'):
               self.desc=self.getDomChildValue('description')           
  +        
  +        # Existence means 'true'
  +        self.redistributable=self.hasDomChild('redistributable')    
   
           # For prettiness
           self.sortedProjects=createOrderedList(self.getProjects())
  @@ -469,8 +479,8 @@
           
       def isRedistributable(self):
           # Existence means 'true'
  -        return self.hasDomChild('redistributable') \
  -            or (self.repository and self.repository.isRedistributable())
  +        return self.redistributable or \
  +            (self.repository and self.repository.isRedistributable())
           
       #
       # Get a full list of all the projects that depend
  
  
  
  1.40      +3 -3      gump/gumpy.py
  
  Index: gumpy.py
  ===================================================================
  RCS file: /home/cvs/gump/gumpy.py,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- gumpy.py  19 Jul 2004 16:07:53 -0000      1.39
  +++ gumpy.py  21 Jul 2004 14:54:34 -0000      1.40
  @@ -264,7 +264,7 @@
       pass

   

   # Enable a log

  -logFileName='gumpy_log.txt'

  +logFileName='gumpy_log_' + time.strftime('%d%m%Y_%H%M%S') + '.txt'

   logFile=os.path.abspath(logFileName)

   log=open(logFile,'w',0) # Unbuffered...

   

  @@ -458,7 +458,7 @@
       # Publish logfile

       published=0

       if logdir:

  -        publishedLogFile=os.path.abspath(os.path.join(logdir,logFileName))

  +        publishedLogFile=os.path.abspath(os.path.join(logdir,'gumpy_log.txt'))

           if '--xdocs' in args:

               publishedLogFile=os.path.abspath(

                                   os.path.join(

  @@ -479,7 +479,7 @@
            

       if result:     

           # Cat to screen (if running to screen)

  -        tty=0

  +        tty=False

           try:

               tty=sys.stdout.isatty()  

           except:

  
  
  
  1.6       +8 -4      gump/python/gump/notify/notification.py
  
  Index: notification.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/notify/notification.py,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- notification.py   19 Jul 2004 16:07:54 -0000      1.5
  +++ notification.py   21 Jul 2004 14:54:34 -0000      1.6
  @@ -51,7 +51,11 @@
       FAILURE_TYPE=2
       WARNING_TYPE=3    
       
  -    def __init__(self,run,entity,type=SUCCESS_TYPE,intro=''):      
  +    def __init__(self,run,entity,type=SUCCESS_TYPE,intro=''):   
  +        """
  +             Create a notification (of success/failure/etc.)
  +        """
  +        
           RunSpecific.__init__(self,run)
           
           self.entity=entity
  @@ -78,13 +82,13 @@
           return False
           
       def isSuccess(self):
  -        return SUCCESS_TYPE == self.type
  +        return Notification.SUCCESS_TYPE == self.type
           
       def isFailure(self):
  -        return FAILURE_TYPE == self.type
  +        return Notification.FAILURE_TYPE == self.type
           
       def isWarning(self):
  -        return WARNING_TYPE == self.type
  +        return Notification.WARNING_TYPE == self.type
           
       def resolveContent(self,resolver,id=None,stream=None):
           
  
  
  
  1.7       +17 -4     gump/python/gump/notify/logic.py
  
  Index: logic.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/notify/logic.py,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- logic.py  19 Jul 2004 16:07:54 -0000      1.6
  +++ logic.py  21 Jul 2004 14:54:34 -0000      1.7
  @@ -43,30 +43,43 @@
           RunSpecific.__init__(self,run)
               
               # :TODO: First Ever?
  -            # :TODO What is M$ (i.e. not dbm) and/or no stats db
  +            # :TODO What if M$ (i.e. not dbm) and/or no stats db
               
       def notification(self,entity):
  +        """
  +        Determine if a notification is appropriate, and
  +        generate it (the content)
  +        """
           
           notification=None
           
           # Stats had better have been set
           stats=entity.getStats()            
  -            
  -        #
  -        # Determine if we want to notify
  +         
  +        #   
  +        # Determine if we want to notify, and if so
  +        # with what (Failure/Warning/Success)
           #
           if entity.isFailed():
  +            #
               # Notify on first failure, or each official
               # run.
  +            #
               if self.run.getOptions().isOfficial() \
                   or (1 == stats.sequenceInState):                           
                   
notification=gump.notify.notification.FailureNotification(self.run,entity)            
           elif entity.isSuccess():
  +            #
  +            # Notify on first success, after a failure.
  +            #
               if (stats.sequenceInState == 1):            
                   if not STATE_PREREQ_FAILED == stats.previousState:
                       if stats.getTotalRuns() > 1:    
                           
notification=gump.notify.notification.SuccessNotification(self.run,entity)
               else:
  +                #
  +                # Notify on official if contains 'errors'.
  +                #
                   if self.run.getOptions().isOfficial() and 
entity.containsRealNasties():
                       
notification=gump.notify.notification.WarningNotification(self.run,entity,' contains 
errors')   
                           
  
  
  
  1.11      +68 -26    gump/python/gump/notify/notifier.py
  
  Index: notifier.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/notify/notifier.py,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- notifier.py       19 Jul 2004 16:07:54 -0000      1.10
  +++ notifier.py       21 Jul 2004 14:54:34 -0000      1.11
  @@ -50,10 +50,15 @@
           
           AbstractRunActor.__init__(self,run)
           
  +        # Successful notifications
  +        self.sents=0
  +        
  +        # Unsuccesful
           self.unsent=''
           self.unsentSubjects=''
           self.unsents=0
           
  +        # Unwanted
           self.unwanted=''
           self.unwantedSubjects=''
           self.unwanteds=0
  @@ -62,25 +67,39 @@
           self.logic=NotificationLogic(self.run)
           
           self.id=0
  -                                        
  +                                  
  +    def processOtherEvent(self,event):    
  +        """
  +        
  +        At the end of the run...
  +        
  +        """
  +        if isinstance(event,FinalizeRunEvent):          
  +            self.processWorkspace()              
  +            
       def processWorkspace(self):
           """
  +        
                Notify about the workspace (if it needs it)
  +             
                """
           notification = self.logic.notification(self.workspace)
           if notification:
               self.notifyWorkspace(notification)   
            
  +        log.info('Notifications: Sent:%s Unsent:%s  Unwanted: %s' % \
  +                    (self.sents, self.unsents, self.unwanteds) )
  +         
           # Workspace can override...
           (wsTo, wsFrom) = self.workspace.getNotifyOverrides()        
                   
           # Belt and braces (notify to us if not notify to them)
  -        if self.hasUnwanted():
  +        if self._hasUnwanted():
               log.info('We have some unwanted\'s to send to list...')
               
  -            self.sendEmail(wsTo or self.workspace.mailinglist,wsFrom or 
self.workspace.email,    \
  -                        'BATCH: All dressed up, with nowhere to go...',\
  -                        self.getUnwantedContent())
  +            self.sendEmail(wsTo or self.workspace.mailinglist,wsFrom or 
self.workspace.email,
  +                        'BATCH: All dressed up, with nowhere to go...',
  +                        self._getUnwantedContent())
                           
               # A bit paranoid, ought just rely upon object being
               # destroyed,
  @@ -91,11 +110,11 @@
               log.debug('No unwanted notifys.')
                   
           # Belt and braces (notify to us if not notify to them)
  -        if self.hasUnsent():
  +        if self._hasUnsent():
               log.info('We have some unsented\'s to send to list...')    
  -            self.sendEmail(wsTo or self.workspace.mailinglist,wsFrom or 
self.workspace.email,    \
  -                        'BATCH: Unable to send...',\
  -                         self.getUnsentContent())
  +            self.sendEmail(wsTo or self.workspace.mailinglist,wsFrom or 
self.workspace.email,
  +                        'BATCH: Unable to send...',
  +                         self._getUnsentContent())
                           
               # A bit paranoid, ought just rely upon object being
               # destroyed,
  @@ -136,7 +155,7 @@
                   log.error("Failed to send notify e-mails for project " + 
project.getName()\
                                       + " : " + str(details), exc_info=1)
    
  -    def addUnwanted(self,subject,content):
  +    def _addUnwanted(self,subject,content):
           """
                Add this notification to the 'unwanted' list, since
                no addresses were found for it.
  @@ -152,7 +171,7 @@
           self.unwantedSubjects += subject + '\n'
           self.unwanteds += 1
       
  -    def addUnsent(self,subject,content):
  +    def _addUnsent(self,subject,content):
           """
               Add this notification to the 'unsent' list, since
               it failed to be sent.
  @@ -169,16 +188,30 @@
           self.unsents += 1
           
       def getNextIdentifier(self):
  +        """
  +        Get's the next identifier.
  +        
  +        Note: Side effect, increments the identifier
  +        """
           self.id += 1 
           return self.id
           
  -    def getUnwantedContent(self):
  -        return 
self.getBatchContent(self.unwanteds,self.unwantedSubjects,self.unwanted)
  +    def _getUnwantedContent(self):
  +        """        
  +        Generate content for the batch of unwanted notifications.        
  +        """
  +        return 
self._getBatchContent(self.unwanteds,self.unwantedSubjects,self.unwanted)
                
  -    def getUnsentContent(self):
  -        return self.getBatchContent(self.unsents,self.unsentSubjects,self.unsent)
  +    def _getUnsentContent(self):
  +        """        
  +        Generate content for the batch of unsent notifications.        
  +        """
  +        return self._getBatchContent(self.unsents,self.unsentSubjects,self.unsent)
                
  -    def getBatchContent(self,count,subjects,batch):
  +    def _getBatchContent(self,count,subjects,batch):
  +        """
  +        Generate batch content
  +        """
           content = ''
           
           if count:
  @@ -204,13 +237,19 @@
               
           return content
               
  -    def hasUnwanted(self):
  -        if self.unwanted: return 1
  -        return 0
  +    def _hasUnwanted(self):
  +        """
  +        Do we have any mails that should have been sent, but had nowhere to go?
  +        """
  +        if self.unwanted: return True
  +        return False
       
  -    def hasUnsent(self):
  -        if self.unsent: return 1
  -        return 0
  +    def _hasUnsent(self):
  +        """
  +        Do we have any mails that failed to be sent?
  +        """
  +        if self.unsent: return True
  +        return False
       
       def notifyWorkspace(self,notification):
           """ Notify for the workspace """
  @@ -273,7 +312,9 @@
           
       def sendEmails(self, addressPairs, subject, content):
           """
  -             Try to send them (if any to send, or store)
  +             Try to send them to interested parties
  +             
  +             Note: if nowhere to send, store them as 'unwanted'
           """
           if addressPairs:
               for pair in addressPairs:
  @@ -286,11 +327,12 @@
               # This is a catch-all, for all project that
               # don't have <notify's assigned.
               #
  -            self.addUnwanted(subject,content)
  +            self._addUnwanted(subject,content)
                       
       def sendEmail(self, toaddr, fromaddr, subject, content):
           """
  -             Perform the SMTP send.
  +             Perform the SMTP send.  
  +             If it fails, add the mail to the list of unsent
           """
           
           #
  @@ -331,7 +373,7 @@
           if not sent:
               content = 'Failed with to: ['+str(toaddr)+'] from: 
['+str(fromaddr)+']\n' + content
               
  -            self.addUnsent(subject,content)                                        
  +            self._addUnsent(subject,content)                                        
               log.error('Failed with to: ['+str(toaddr)+'] from: ['+str(fromaddr)+']' 
)
               
           return sent
  
  
  
  1.21      +1 -1      gump/python/gump/document/xdocs/documenter.py
  
  Index: documenter.py
  ===================================================================
  RCS file: /home/cvs/gump/python/gump/document/xdocs/documenter.py,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- documenter.py     19 Jul 2004 16:07:55 -0000      1.20
  +++ documenter.py     21 Jul 2004 14:54:34 -0000      1.21
  @@ -256,7 +256,7 @@
           xdocWorkDir=self.getXDocWorkDirectory()
           logDirectory=self.getXDocLogDirectory()
           
  -        log.info('Syncronize work->log, and clean-up...')
  +        log.info('Synchronize work->log, and clean-up...')
               
           success=True
           try:
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to