def run_review(*args): ''' Get the difference of recents modification, and send the Email. For: wiki, page, and post. ''' email_cnt = '''<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style type="text/css"> table.diff {font-family:Courier; border:medium;} .diff_header {background-color:#e0e0e0} td.diff_header {text-align:right} .diff_next {background-color:#c0c0c0} .diff_add {background-color:#aaffaa} .diff_chg {background-color:#ffff77} .diff_sub {background-color:#ffaaaa} </style></head><body>''' idx = 1 email_cnt = email_cnt + '<table border=1>' email_cnt, idx = __get_post_review(email_cnt, idx) # post email_cnt, idx = __get_page_review(email_cnt, idx) # page. email_cnt, idx = __get_wiki_review(email_cnt, idx) # wiki ########################################################### diff_str = __get_diff_recent() if len(diff_str) < 20000: email_cnt = email_cnt + diff_str email_cnt = email_cnt + '''</body></html>''' if idx > 1: send_mail(post_emails, "{0}|{1}|{2}".format(SMTP_CFG['name'], '文档更新情况', DATE_STR), email_cnt)
def run_send_all(): muser = MUser() user_recs = muser.query_all() for user_rec in user_recs: email_add = user_rec.user_email print(email_add) send_mail([email_add], "{0}|{1}".format(smtp_cfg['name'], email_cfg['title']), email_cfg['content'])
def run_send_all(*args): ''' Send email to all user. ''' for user_rec in MUser.query_all(): email_add = user_rec.user_email send_mail([email_add], f"{SMTP_CFG['name']}|{email_cfg['title']}", email_cfg['content'])
def run_send_all(*args): ''' Send email to all user. ''' for user_rec in MUser.query_all(): email_add = user_rec.user_email send_mail([email_add], "{0}|{1}".format(SMTP_CFG['name'], email_cfg['title']), email_cfg['content'])
def run_send_nologin(*args): ''' Send email to who not logged in recently. ''' for user_rec in MUser.query_nologin(): email_add = user_rec.user_email print(email_add) send_mail([email_add], f"{SMTP_CFG['name']}|{email_cfg['title']}", email_cfg['content']) MUser.set_sendemail_time(user_rec.uid)
def run_send_nologin(*args): ''' Send email to who not logged in recently. :return: ''' for user_rec in MUser.query_nologin(): email_add = user_rec.user_email print(email_add) send_mail([email_add], "{0}|{1}".format(SMTP_CFG['name'], email_cfg['title']), email_cfg['content']) MUser.set_sendemail_time(user_rec.uid)
def reset_password(self): ''' Do reset password :return: ''' post_data = self.get_post_data() if 'email' in post_data: userinfo = MUser.get_by_email(post_data['email']) if tools.timestamp() - userinfo.time_reset_passwd < 70: self.set_status(400) kwd = { 'info': '两次重置密码时间应该大于1分钟', 'link': '/user/reset-password', } self.render('misc/html/404.html', kwd=kwd, userinfo=self.userinfo) return False if userinfo: timestamp = tools.timestamp() passwd = userinfo.user_pass username = userinfo.user_name hash_str = tools.md5(username + str(timestamp) + passwd) url_reset = '{0}/user/reset-passwd?u={1}&t={2}&p={3}'.format( config.SITE_CFG['site_url'], username, timestamp, hash_str) email_cnt = '''<div>请查看下面的信息,并<span style="color:red">谨慎操作</span>:</div> <div>您在"{0}"网站({1})申请了密码重置,如果确定要进行密码重置,请打开下面链接:</div> <div><a href={2}>{2}</a></div> <div>如果无法确定本信息的有效性,请忽略本邮件。</div>'''.format(config.SMTP_CFG['name'], config.SITE_CFG['site_url'], url_reset) if send_mail([userinfo.user_email], "{0}|密码重置".format(config.SMTP_CFG['name']), email_cnt): MUser.update_time_reset_passwd(username, timestamp) self.set_status(200) logger.info('password has been reset.') return True else: self.set_status(400) return False else: self.set_status(400) return False else: self.set_status(400) return False
def reset_password(self): post_data = {} for key in self.request.arguments: post_data[key] = self.get_arguments(key) if 'email' in post_data: userinfo = self.muser.get_by_email(post_data['email'][0]) if tools.timestamp() - userinfo.time_reset_passwd < 70: self.set_status(400) kwd = { 'info': '两次重置密码时间应该大于1分钟', } self.render('html/404.html', kwd=kwd, userinfo=self.userinfo) return False if userinfo: timestamp = tools.timestamp() passwd = userinfo.user_pass username = userinfo.user_name hash_str = tools.md5(username + str(timestamp) + passwd) url_reset = '{0}/user/reset-passwd?u={1}&t={2}&p={3}'.format( config.site_url, username, timestamp, hash_str) email_cnt = ''' <div>请查看下面的信息,并<span style="color:red">谨慎操作</span>:</div> <div>您在"{0}"网站({1})申请了密码重置,如果确定要进行密码重置,请打开下面链接:</div> <div><a href={2}>{2}</a></div> <div>如果无法确定本信息的有效性,请忽略本邮件。</div> '''.format(config.smtp_cfg['name'], config.site_url, url_reset) if send_mail([userinfo.user_email], "{0}|密码重置".format(config.smtp_cfg['name']), email_cnt): self.muser.update_time_reset_passwd(username, timestamp) self.set_status(200) return True else: self.set_status(400) return False else: self.set_status(400) return False else: self.set_status(400) return False
def reset_password(self): post_data = {} for key in self.request.arguments: post_data[key] = self.get_arguments(key) if 'email' in post_data: userinfo = self.muser.get_by_email(post_data['email'][0]) if tools.timestamp() - userinfo.reset_passwd_timestamp < 70: self.set_status(400) kwd = { 'info': '两次重置密码时间应该大于1分钟', } self.render('html/404.html', kwd=kwd, userinfo = self.userinfo) return False if userinfo: timestamp = tools.timestamp() passwd = userinfo.user_pass username = userinfo.user_name hash_str = tools.md5(username + str(timestamp) + passwd) url_reset = '{0}/user/reset-passwd?u={1}&t={2}&p={3}'.format(config.site_url, username, timestamp, hash_str) email_cnt = ''' <div>请查看下面的信息,并<span style="color:red">谨慎操作</span>:</div> <div>您在"{0}"网站({1})申请了密码重置,如果确定要进行密码重置,请打开下面链接:</div> <div><a href={2}>{2}</a></div> <div>如果无法确定本信息的有效性,请忽略本邮件。</div> '''.format(config.site_name, config.site_url, url_reset) if send_mail([userinfo.user_email], "{0}|密码重置".format(config.site_name), email_cnt): self.muser.update_reset_passwd_timestamp(username, timestamp) self.set_status(200) return True else: self.set_status(400) return False else: self.set_status(400) return False else: self.set_status(400) return False
def run_edit_diff(): email_cnt = '''<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style type="text/css"> table.diff {font-family:Courier; border:medium;} .diff_header {background-color:#e0e0e0} td.diff_header {text-align:right} .diff_next {background-color:#c0c0c0} .diff_add {background-color:#aaffaa} .diff_chg {background-color:#ffff77} .diff_sub {background-color:#ffaaaa} </style></head><body>''' idx = 1 email_cnt = email_cnt + '<table border=1>' mpost = MPost() mposthist = MPostHist() recent_posts = mpost.query_recent_edited(tools.timestamp() - 24 * 60 * 60) for recent_post in recent_posts: hist_rec = mposthist.get_last(recent_post.uid) if hist_rec: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_chg">Edit</td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(site_url, 'post', recent_post.uid + '.html')) email_cnt = email_cnt + foo_str else: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_add">New </td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(site_url, 'post', recent_post.uid + '.html')) email_cnt = email_cnt + foo_str idx = idx + 1 recent_posts = mpost.query_recent_edited(tools.timestamp() - 24 * 60 * 60, kind='2') for recent_post in recent_posts: hist_rec = mposthist.get_last(recent_post.uid) if hist_rec: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_chg">Edit</td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(site_url, router_post['2'], recent_post.uid)) email_cnt = email_cnt + foo_str else: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_add">New </td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(site_url, router_post['2'], recent_post.uid)) email_cnt = email_cnt + foo_str idx = idx + 1 mpost = MWiki() mposthist = MWikiHist() recent_posts = mpost.query_recent_edited(tools.timestamp() - 24 * 60 * 60) for recent_post in recent_posts: hist_rec = mposthist.get_last(recent_post.uid) if hist_rec: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_chg">Edit</td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(site_url, 'wiki', recent_post.title)) email_cnt = email_cnt + foo_str else: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_add">New </td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(site_url, 'wiki', recent_post.title)) email_cnt = email_cnt + foo_str idx = idx + 1 recent_posts = mpost.query_recent_edited(tools.timestamp() - 24 * 60 * 60, kind='2') for recent_post in recent_posts: hist_rec = mposthist.get_last(recent_post.uid) if hist_rec: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_chg">Edit</td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(site_url, 'page', recent_post.uid + '.html')) email_cnt = email_cnt + foo_str else: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_add">New </td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(site_url, 'page', recent_post.uid + '.html')) email_cnt = email_cnt + foo_str idx = idx + 1 email_cnt = email_cnt + '</table>' mpost = MPost() mposthist = MPostHist() diff_str = '' ###################################################### recent_posts = mpost.query_recent_edited(tools.timestamp() - 24 * 60 * 60) for recent_post in recent_posts: hist_rec = mposthist.get_last(recent_post.uid) if hist_rec: print('=' * 10) print(recent_post.title) raw_title = hist_rec.title new_title = recent_post.title infobox = diff_table(raw_title, new_title) # if len(test) > 1: # start = test.find('<table class="diff"') # 起点记录查询位置 # end = test.find('</table>') # infobox = test[start:end] + '</table>' # if ('diff_add' in infobox) or ('diff_chg' in infobox) or ('diff_sub' in infobox): diff_str = diff_str + '<h2 style="color:red; font-size:larger; font-weight:70;">TITLE: {0}</h2>'.format( recent_post.title) + infobox test = diff_table(hist_rec.cnt_md, recent_post.cnt_md) print(test) # if len(test) >1 : # start = test.find('<table class="diff"') # 起点记录查询位置 # end = test.find('</table>') # infobox = test[start:end] + '</table>' # if ('diff_add' in infobox) or ('diff_chg' in infobox) or ('diff_sub' in infobox): diff_str = diff_str + '<h3>CONTENT</h3>'.format( recent_post.title) + test + '</hr>' else: continue ###################################################### recent_posts = mpost.query_recent_edited(tools.timestamp() - 24 * 60 * 60, kind='2') for recent_post in recent_posts: hist_rec = mposthist.get_last(recent_post.uid) if hist_rec: print('=' * 10) print(recent_post.title) raw_title = hist_rec.title new_title = recent_post.title infobox = diff_table(raw_title, new_title) # infobox = test[start:end] + '</table>' # if ('diff_add' in infobox) or ('diff_chg' in infobox) or ('diff_sub' in infobox): diff_str = diff_str + '<h2 style="color:red; font-size:larger; font-weight:70;">TITLE: {0}</h2>'.format( recent_post.title) + infobox infobox = diff_table(hist_rec.cnt_md, recent_post.cnt_md) diff_str = diff_str + '<h3>CONTENT</h3>'.format( recent_post.title) + infobox + '</hr>' else: continue ########################################################### if len(diff_str) < 20000: email_cnt = email_cnt + diff_str email_cnt = email_cnt + '''<table class="diff" summary="Legends"> <tr> <th colspan="2"> Legends </th> </tr> <tr> <td> <table border="" summary="Colors"> <tr><th> Colors </th> </tr> <tr><td class="diff_add"> Added </td></tr> <tr><td class="diff_chg">Changed</td> </tr> <tr><td class="diff_sub">Deleted</td> </tr> </table></td> <td> <table border="" summary="Links"> <tr><th colspan="2"> Links </th> </tr> <tr><td>(f)irst change</td> </tr> <tr><td>(n)ext change</td> </tr> <tr><td>(t)op</td> </tr> </table></td> </tr> </table></body>''' # print (email_cnt) print('edit diff count:', idx) if idx > 1: send_mail(post_emails, "{0}|{1}|{2}".format(smtp_cfg['name'], '文档更新情况', datestr), email_cnt)
def run_edit_diff(*args): email_cnt = '''<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style type="text/css"> table.diff {font-family:Courier; border:medium;} .diff_header {background-color:#e0e0e0} td.diff_header {text-align:right} .diff_next {background-color:#c0c0c0} .diff_add {background-color:#aaffaa} .diff_chg {background-color:#ffff77} .diff_sub {background-color:#ffaaaa} </style></head><body>''' idx = 1 email_cnt = email_cnt + '<table border=1>' mpost = MPost() mposthist = MPostHist() for key in router_post.keys(): recent_posts = mpost.query_recent_edited(tools.timestamp() - time_limit, kind=key) for recent_post in recent_posts: hist_rec = mposthist.get_last(recent_post.uid) if hist_rec: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_chg">Edit</td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(SITE_CFG['site_url'], router_post[key], recent_post.uid)) email_cnt = email_cnt + foo_str else: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_add">New </td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(SITE_CFG['site_url'], router_post[key], recent_post.uid)) email_cnt = email_cnt + foo_str idx = idx + 1 ## wiki mpost = MWiki() mposthist = MWikiHist() recent_posts = mpost.query_recent_edited(tools.timestamp() - time_limit) for recent_post in recent_posts: hist_rec = mposthist.get_last(recent_post.uid) if hist_rec: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_chg">Edit</td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(SITE_CFG['site_url'], 'wiki', recent_post.title)) email_cnt = email_cnt + foo_str else: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_add">New </td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(SITE_CFG['site_url'], 'wiki', recent_post.title)) email_cnt = email_cnt + foo_str idx = idx + 1 ## page. recent_posts = mpost.query_recent_edited(tools.timestamp() - time_limit, kind='2') for recent_post in recent_posts: hist_rec = mposthist.get_last(recent_post.uid) if hist_rec: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_chg">Edit</td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(SITE_CFG['site_url'], 'page', recent_post.uid)) email_cnt = email_cnt + foo_str else: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_add">New </td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(SITE_CFG['site_url'], 'page', recent_post.uid)) email_cnt = email_cnt + foo_str idx = idx + 1 email_cnt = email_cnt + '</table>' ########################################################### diff_str = get_diff_str() if len(diff_str) < 20000: email_cnt = email_cnt + diff_str email_cnt = email_cnt + '''</body></html>''' if idx > 1: send_mail(post_emails, "{0}|{1}|{2}".format(SMTP_CFG['name'], '文档更新情况', datestr), email_cnt)
def run_edit_diff(): email_cnt = '''<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style type="text/css"> table.diff {font-family:Courier; border:medium;} .diff_header {background-color:#e0e0e0} td.diff_header {text-align:right} .diff_next {background-color:#c0c0c0} .diff_add {background-color:#aaffaa} .diff_chg {background-color:#ffff77} .diff_sub {background-color:#ffaaaa} </style></head><body>''' idx = 1 email_cnt = email_cnt + '<table border=1>' mpost = MPost() mposthist = MPostHist() for key in router_post.keys(): recent_posts = mpost.query_recent_edited(tools.timestamp() - time_limit, kind=key) for recent_post in recent_posts: hist_rec = mposthist.get_last(recent_post.uid) if hist_rec: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_chg">Edit</td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(site_url, router_post[key], recent_post.uid)) email_cnt = email_cnt + foo_str else: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_add">New </td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(site_url, router_post[key], recent_post.uid)) email_cnt = email_cnt + foo_str idx = idx + 1 ## wiki mpost = MWiki() mposthist = MWikiHist() recent_posts = mpost.query_recent_edited(tools.timestamp() - time_limit) for recent_post in recent_posts: hist_rec = mposthist.get_last(recent_post.uid) if hist_rec: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_chg">Edit</td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(site_url, 'wiki', recent_post.title)) email_cnt = email_cnt + foo_str else: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_add">New </td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format( idx, recent_post.user_name, recent_post.title, os.path.join(site_url, 'wiki', recent_post.title)) email_cnt = email_cnt + foo_str idx = idx + 1 ## page. recent_posts = mpost.query_recent_edited(tools.timestamp() - time_limit, kind='2') for recent_post in recent_posts: hist_rec = mposthist.get_last(recent_post.uid) if hist_rec: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_chg">Edit</td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format(idx, recent_post.user_name, recent_post.title, os.path.join(site_url, 'page', recent_post.uid)) email_cnt = email_cnt + foo_str else: foo_str = ''' <tr><td>{0}</td><td>{1}</td><td class="diff_add">New </td><td>{2}</td> <td><a href="{3}">{3}</a></td></tr> '''.format(idx, recent_post.user_name, recent_post.title, os.path.join(site_url, 'page', recent_post.uid)) email_cnt = email_cnt + foo_str idx = idx + 1 email_cnt = email_cnt + '</table>' mpost = MPost() mposthist = MPostHist() diff_str = '' ###################################################### ###################################################### for key in router_post.keys(): recent_posts = mpost.query_recent_edited(tools.timestamp() - time_limit, kind=key) for recent_post in recent_posts: hist_rec = mposthist.get_last(recent_post.uid) if hist_rec: print('=' * 10) print(recent_post.title) raw_title = hist_rec.title new_title = recent_post.title infobox = diff_table(raw_title, new_title) # infobox = test[start:end] + '</table>' # if ('diff_add' in infobox) or ('diff_chg' in infobox) or ('diff_sub' in infobox): diff_str = diff_str + '<h2 style="color:red; font-size:larger; font-weight:70;">TITLE: {0}</h2>'.format( recent_post.title) + infobox infobox = diff_table(hist_rec.cnt_md, recent_post.cnt_md) diff_str = diff_str + '<h3>CONTENT</h3>'.format( recent_post.title) + infobox + '</hr>' else: continue ########################################################### if len(diff_str) < 20000: email_cnt = email_cnt + diff_str email_cnt = email_cnt + '''</body></html>''' # print (email_cnt) print('edit diff count:', idx) if idx > 1: send_mail(post_emails, "{0}|{1}|{2}".format(smtp_cfg['name'], '文档更新情况', datestr), email_cnt)
def run_edit_diff(): email_cnt = '''<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <style type="text/css"> table.diff {font-family:Courier; border:medium;} .diff_header {background-color:#e0e0e0} td.diff_header {text-align:right} .diff_next {background-color:#c0c0c0} .diff_add {background-color:#aaffaa} .diff_chg {background-color:#ffff77} .diff_sub {background-color:#ffaaaa} </style></head><body>''' mpost = MPost() mposthist = MPostHist() recent_posts = mpost.query_recent_edited(tools.timestamp() - 24 * 60 * 60) email_cnt = email_cnt + '<table border=1>' idx = 1 for recent_post in recent_posts: hist_rec = mposthist.get_last(recent_post.uid) if hist_rec: foo_str = ''' <tr><td>{0}</td><td class="diff_chg">Edit</td><td>{1}</td> <td><a href="{2}">{2}</a></td></tr> '''.format( idx, recent_post.title, os.path.join(site_url, 'post', recent_post.uid + '.html')) email_cnt = email_cnt + foo_str else: foo_str = ''' <tr><td>{0}</td><td class="diff_add">New </td><td>{1}</td> <td><a href="{2}">{2}</a></td></tr> '''.format( idx, recent_post.title, os.path.join(site_url, 'post', recent_post.uid + '.html')) email_cnt = email_cnt + foo_str idx = idx + 1 email_cnt = email_cnt + '</table>' recent_posts = mpost.query_recent_edited(tools.timestamp() - 24 * 60 * 60) diff_str = '' for recent_post in recent_posts: hist_rec = mposthist.get_last(recent_post.uid) if hist_rec: print('=' * 10) print(recent_post.title) raw_title = hist_rec.title new_title = recent_post.title test = HtmlDiff.make_file(HtmlDiff(), [raw_title], [new_title]) # if len(test) > 1: start = test.find('<table class="diff"') # 起点记录查询位置 end = test.find('</table>') infobox = test[start:end] + '</table>' if ('diff_add' in infobox) or ('diff_chg' in infobox) or ('diff_sub' in infobox): diff_str = diff_str + '<h2 style="color:red; font-size:larger; font-weight:70;">TITLE: {0}</h2> TITLE'.format( recent_post.title) + infobox raw_md = hist_rec.cnt_md.split('\n') new_md = recent_post.cnt_md.split('\n') test = HtmlDiff.make_file(HtmlDiff(), raw_md, new_md) # if len(test) >1 : start = test.find('<table class="diff"') # 起点记录查询位置 end = test.find('</table>') infobox = test[start:end] + '</table>' if ('diff_add' in infobox) or ('diff_chg' in infobox) or ('diff_sub' in infobox): diff_str = diff_str + '<h2 style="color:red; font-size:larger; font-weight:70;">TITLE: {0}</h2> CONTENT'.format( recent_post.title) + infobox + '</hr>' else: continue if len(diff_str) < 8000: email_cnt = email_cnt + diff_str email_cnt = email_cnt + '''<table class="diff" summary="Legends"> <tr> <th colspan="2"> Legends </th> </tr> <tr> <td> <table border="" summary="Colors"> <tr><th> Colors </th> </tr> <tr><td class="diff_add"> Added </td></tr> <tr><td class="diff_chg">Changed</td> </tr> <tr><td class="diff_sub">Deleted</td> </tr> </table></td> <td> <table border="" summary="Links"> <tr><th colspan="2"> Links </th> </tr> <tr><td>(f)irst change</td> </tr> <tr><td>(n)ext change</td> </tr> <tr><td>(t)op</td> </tr> </table></td> </tr> </table></body>''' print(email_cnt) send_mail(post_emails, "{0}|{1}|{2}".format(smtp_cfg['name'], '文档更新情况', datestr), email_cnt)