def get_device_not_found_content(self, receivermail, date, subject, browser, device): html = """\ <html> <body> <h2><center> DATE APPNAME Monkey Test exception explanation</center></h2> <table border="1" algin="center"> <caption><em>Jenkins AutoTest Result</em></caption> <tr> <tr><th>Jenkins</th><td><a href='http://10.60.118.93:8080/jenkins/view/Monkey/job/APPNAME_DEVICENAME/'>http://10.60.118.93:8080/jenkins/view/Monkey/job/APPNAME_DEVICENAME/</a></td></tr> <tr><th>DeviceInfo</th><td>DEVICENAME</td></tr> </table> <body> <html> """ html = html.replace("DATE", date) html = html.replace("10.60.118.93", Fun.get_my_ip()) html = html.replace('APPNAME', browser) html = html.replace('DEVICENAME', device) msgRoot = MIMEMultipart('related') msgRoot['Subject'] = subject.replace('_', '') msgRoot['From'] = self.proxysender msgRoot['To'] = ",".join(receivermail) msgText = MIMEText(html, 'html', 'utf-8') msgRoot.attach(msgText) print '>>>>>> MailSender.get_device_not_found_content() finished ' return msgRoot
def get_content(self, receivermail, date, crash_result, subject, logfile, browser, device, androidversion): html = """\ <html> <body> <h2><center> 2014-06-10 APPNAME Monkey Test exception explanation</center></h2> <table border="1" algin="center"> <caption><em>Jenkins AutoTest Result</em></caption> <tr> <tr><th>Jenkins<td><a href='http://10.60.118.93:8080/jenkins/view/Monkey/job/APPNAME_DEVICENAME/'>http://10.60.118.93:8080/jenkins/view/Monkey/job/APPNAME_DEVICENAME/</a> <tr><th>Install APK_PATH<td>test.apk <tr><th>DeviceInfo<td>DEVICENAME <tr><th>System<td>ANDROIDVERSION <tr><th>Result<td>Found crash Log, please check out logfile or download attachments </table> <br>contentsss <br> <body> <html> """ # <img border="0" src="cid:image_win" width="200" length="200" > mFile = open(logfile.replace('.log', '.path')) strfile = mFile.read() mFile.close() html = html.replace("2014-06-10", date) html = html.replace("10.60.118.93", Fun.get_my_ip()) html = html.replace("test.apk", strfile.split('/')[-1]) html = html.replace("contentsss", crash_result) html = html.replace('APPNAME', browser) html = html.replace('DEVICENAME', device) html = html.replace('ANDROIDVERSION', androidversion) msgRoot = MIMEMultipart('related') msgRoot['Subject'] = subject.replace('_', '') msgRoot['From'] = self.proxysender msgRoot['To'] = ",".join(receivermail) msgText = MIMEText(html, 'html', 'utf-8') msgRoot.attach(msgText) txt = MIMEText(open(logfile, 'rb').read(), 'base64', 'gb2312') txt["Content-Type"] = 'application/octet-stream' txt["Content-Disposition"] = 'attachment; filename="CrashLog.txt"' msgRoot.attach(txt) print '>>>>>> MailSender.get_content() finished ' return msgRoot