示例#1
0
 def run(self):
     self.logger.info('Start email monitor')
         
     send_from = '*****@*****.**'
     if self.parameter.has_key('From'):
         send_from = self.parameter['From']
     
     user = globalProperty.getUser()
     if user==None:
         defaultTo = '*****@*****.**'
     else:
         defaultTo = '*****@*****.**' % user
         
     """
     if self.parameter.has_key('To'):
         send_to = self.parameter['To'].replace(';', ',').split(',')
     else:
         send_to = defaultTo.split(',')
     """
     send_to = self.parameter['To'] if self.parameter.has_key('To') else defaultTo
     
     if self.exeId==None:
         self.logger.info('No Result could be sent out for monitoring')
         return
     
     reportFile = self.getHtmlReport()
     if reportFile==None or not os.path.exists(reportFile):
         return
     
     #Send Report
     from HtmlEmailUtil import childTask
     htmlEmailUtil = childTask('HtmlEmailUtil', self.priority + 2)
     
     htmlEmailUtil.addPara('From', send_from)
     htmlEmailUtil.addPara('To', send_to)
     
     if globalProperty.isMachineOutOfChina():
         htmlEmailUtil.addPara('SMTPServer', self._dbutil.getAppInfo('email_server_us'))
     else:
         htmlEmailUtil.addPara('SMTPServer', self._dbutil.getAppInfo('email_server_cn'))
     if self.parameter.has_key('Subject'):
         subject = self.parameter['Subject']
     else:
         subject = 'Email Monitor from %s -- %s' % (socket.gethostname(), self._getCurrentTime())
     htmlEmailUtil.addPara('Subject', subject)
     htmlEmailUtil.addPara('ReportFile', reportFile)
     htmlEmailUtil.run()
     """
示例#2
0
            getJobLeft = False
            for job in jobList:
                if int(job[1])>int(executionSequence) and not getJobLeft:
                    getJobLeft = True
                    
                if getJobLeft:
                    self.htmlBody += '''
    <tr>
    '''
                    self.htmlBody += '<td align="center"><strong>%s<strong></td>' % job[0]
                    self.htmlBody += '<td align="center">wait</td>'
                    self.htmlBody += '<td align="center">wait</td>'
                    self.htmlBody += '<td align="center">wait</td>'
                    self.htmlBody += "<td></td>"
                    self.htmlBody += '''
    </tr>
    '''
                
        self.htmlBody += '''
    </table>
    '''
        return self.htmlBody

if __name__ == '__main__':
    task = childTask('xx', 1)
    task.addPara('From', '*****@*****.**')
    task.addPara('To', '*****@*****.**')
    task.exeId = "29110"
    task.jobId = "d662c28f-faeb-11e0-af94-0024e832d01c"
    task.getHtmlReport()