コード例 #1
0
ファイル: listener.py プロジェクト: pombredanne/trachacks
    class NotifyEmailTaskEvent(NotifyEmail):

        template_name = "notify_task_event_template.txt"

        def __init__(self, env):
            NotifyEmail.__init__(self, env)
            self.cronconf = CronConfig(self.env)

        def get_recipients(self, resid):
            """
                Return the recipients as defined in trac.ini.                
                """
            reclist = self.cronconf.get_email_notifier_task_recipient_list()
            return (reclist, [])

        def notifyTaskEvent(self, task_event_list):
            """
                Send task event by mail if recipients is defined in trac.ini
                """
            self.env.log.debug("notifying task event...")
            if self.cronconf.get_email_notifier_task_recipient():
                # prepare the data for the email content generation
                mess = ""
                start = True
                for event in task_event_list:
                    if start:
                        mess = mess + "task[%s]" % (event.task.getId(), )
                        mess = mess + "\nstarted at %d h %d" % (
                            event.time.tm_hour, event.time.tm_min)
                        mess = mess + "\n"
                    else:
                        mess = mess + "ended at %d h %d" % (event.time.tm_hour,
                                                            event.time.tm_min)
                        if (event.success):
                            mess = mess + "\nsuccess"
                        else:
                            mess = mess + "\nFAILURE"
                        mess = mess + "\n\n"
                    start = not start

                self.data.update({
                    "notify_body": mess,
                })
                NotifyEmail.notify(self, None, "task event notification")
            else:
                self.env.log.debug("no recipient for task event, aborting")

        def send(self, torcpts, ccrcpts):
            return NotifyEmail.send(self, torcpts, ccrcpts)
コード例 #2
0
ファイル: listener.py プロジェクト: nyuhuhuu/trachacks
    class NotifyEmailTaskEvent(NotifyEmail):
            
            template_name  = "notify_task_event_template.txt"
            
            def __init__(self, env):
                NotifyEmail.__init__(self, env)
                self.cronconf = CronConfig(self.env)

            def get_recipients(self, resid):
                """
                Return the recipients as defined in trac.ini.                
                """
                reclist = self.cronconf.get_email_notifier_task_recipient_list()     
                return (reclist, [])
                
            
            def notifyTaskEvent(self, task_event_list):
                """
                Send task event by mail if recipients is defined in trac.ini
                """
                self.env.log.debug("notifying task event...")             
                if self.cronconf.get_email_notifier_task_recipient() :                                    
                    # prepare the data for the email content generation
                    mess = ""      
                    start = True
                    for event in task_event_list:
                        if start:                        
                            mess = mess + "task[%s]" % (event.task.getId(),)                       
                            mess = mess + "\nstarted at %d h %d" % (event.time.tm_hour, event.time.tm_min)
                            mess = mess + "\n"
                        else:
                            mess = mess + "ended at %d h %d" % (event.time.tm_hour, event.time.tm_min)
                            if (event.success):
                                mess = mess + "\nsuccess"
                            else:
                                mess = mess + "\nFAILURE"
                            mess = mess + "\n\n"
                        start = not start                            

                    self.data.update({
                                     "notify_body": mess,                                        
                                      })                                          
                    NotifyEmail.notify(self, None, "task event notification")
                else:
                    self.env.log.debug("no recipient for task event, aborting")

            def send(self, torcpts, ccrcpts):
                return NotifyEmail.send(self, torcpts, ccrcpts)