from runcheck import *
from bin import *
import HTMLTestRunner
start_time = datetime.datetime.now()
stuta, msg = runfile()
end_time = datetime.datetime.now()
print("\n\n----------代码执行结束执行结果为:-----------")
if stuta :
for result,value in msg[0].items():
print(f"----------{result}执行结束执行结果为:-----------")
for v in value:
print(v)
msg_email=""
for result,value in msg[0].items():# 运行结果具体内容
num = 1
msg_email=msg_email+result+"执行结果如下:"
for P in value:
msg_email=msg_email+f"\n\t\t\t{num}、{P};"
num += 1
msg_email+="\n"
seconds=(end_time - start_time).total_seconds()#运行时长
m, s = divmod(seconds, 60)# 格式化秒数转化成分钟
s="%.2f"%s
# 邮件标题
title=f"{end_time.strftime('%Y-%m-%d %H:%M:%S')}USS运维报告"
# 邮件消息
body=f"""
开始时间为:{start_time}
结束时间为{end_time}
共用时:{int(m)}分{s}秒
{msg_email}
"""
send_amin(recipient_email,title,body)
else:
print(msg)
print(f"\n开始时间:{start_time}\n结束时间:{end_time}\n共用时:{end_time - start_time}")