def testlog(self): ''' 测试log函数记录日志功能 ''' res = weather.log('开始日志记录') self.assertEqual(res, True)
#如果网页链接出错,等待5秒钟后重新采集三次 while i < 3: exec cmdstr if os.path.isfile(weafilename): mess = ''.join((mess, u' '*4, u'信息源', order, u'号成功\n')) i = 9 else: time.sleep(5) i += 1 if i < 9: mess = ''.join((mess, u' '*4, u'信息源', order, u'号失败\n')) #取出所有生成的中间xml文件 allwealist = glob.glob('template/wea[0-9].xml') if len(allwealist) == 0: weather.log('严重错误:未能取得任何文件') weather.sendsimplemail(MAILLIST, '天气预报严重错误', '未能取得任何文件,请尽快检查系统') sys.exit() else: #生成采集信息报告 mess = ''.join((mess, u'\n采集报告结果报告:\n', u'='*16)) for order in ORDER: filename = u'template/wea' + order + u'.xml' if filename in allwealist: nowlist = weather.xmlToList(filename) mess = ''.join((mess, u'\n\n系统采集正常,信息来源:', nowlist[0], u'\n')) mess = ''.join((mess, u'\n', u' '*4, nowlist[1])) tempstr = "| ".join(( zhLjust(nowlist[2], 20), zhLjust(nowlist[3], 20), zhLjust(nowlist[5], 20), zhLjust(nowlist[4], 40),