def report(self): today = get_date_with_day_duration(0) yesterday = get_date_with_day_duration(-1) today_str = "%d%02d%02d" % (today.year, today.month, today.day) yesterday_str = "%d%02d%02d" % (yesterday.year, yesterday.month, yesterday.day) msg1 = '' msg2 = '' for folder in self._channels: #被封渠道,不用计算, 加上提示信息 if folder in Config.SEALED_CHANNELS: msg1 += "%s: N/A(%s)\n" % (folder,Config.PROMPT_INFO['sealed_info'].encode('utf-8')) msg2 += "N/A ==> N/A" continue today_rs = self.get_result_with_folder_and_date(folder, today_str) yesterday_rs = self.get_result_with_folder_and_date(folder, yesterday_str) if not today_rs: today_rs = 'N/A' if not yesterday_rs: yesterday_rs = 'N/A' is_normal = self.check_if_normal(today_rs, yesterday_rs) # 没有统计爬全率的渠道,均设置正常 if folder in Config.CHANNELS_NOT_CALCURATE_FULL_RATE: is_normal = True if today_str != 'N/A': percent = today_rs.split(':')[-1] else: percent = 'N/A' msg1 += "%s: %s\n" % (folder, percent) msg2 += "%s ==> %s\n" % (yesterday_rs, today_rs) if not is_normal: msg2 = msg2[:-1] + "\t <数据变化异常>\n" msg = """时间:%s\n\n检查JD结果:\n %s \n\n 数据变化:\n%s""" % (today_str, msg1, msg2) sendmail(self._emails, self._email_title, msg)
def update_six_month_cases(): os.system('python update_cases.py 6m') sendmail(['*****@*****.**'], 'Cv test case update(6m)', 'complete time: %s' % datetime.datetime.now())
def update_one_week_cases(): os.system('python update_cases.py 1w') sendmail(['*****@*****.**'], 'Cv test case update(1w)', 'complete time: %s' % datetime.datetime.now())
def update_cases(): os.system('python update_cases.py') sendmail(['*****@*****.**'], 'Jd test case update', 'complete time: %s' % datetime.datetime.now())