Commit 58270bdc by zhangying

Initial commit

parents
# @File : send_file_dingding.py
# @Author : ZY
# @Software: PyCharm
# @Time : 2020/4/29 17:34
import json
import requests
import time
import os
def find_new_file(dir):
# 查找目录下最新的文件
file_lists = os.listdir(dir)
file_lists.sort(key=lambda fn: os.path.getmtime(dir + "/" + fn)
if not os.path.isdir(dir + "/" + fn) else 0)
file = os.path.join(dir, file_lists[-1])
#print('最新的文件为: ' + file_lists[-1])
#print(file)
nowTime = time.strftime('-%Y%m%d-%H:%M:%S', time.localtime(time.time()))
# 技术部群webhook
# url = 'https://oapi.dingtalk.com/robot/send?access_token=384b5298d49ee60e63a90b282b635b354b9d5464a4b312c4a42c13d0f3de9a4a'
# 自己的群webhook
url = 'https://oapi.dingtalk.com/robot/send?access_token=5ab56cfdd624ca57b31eadc94abe041008b3ced874712e00cdf444adcacb3805'
# 技术部消息通知群webhook
# url = 'https://oapi.dingtalk.com/robot/send?access_token=1aa832980ed7ef71de3964f08ae1fe49f97e60f31bf700f500833ab50bbf2fa5'
HEADERS = {
"Content-Type": "application/json ;charset=utf-8 "
}
data = {
"msgtype": "markdown",
"markdown": {
"title":"线上 小麦云课堂列表接口回归测试",
"text": "# 线上 小麦云课堂列表接口回归测试"+nowTime+"\n"
"> ![screenshot](https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1588585057059&di=2f02a34969450a1f547cde7c706ec74c&imgtype=0&src=http%3A%2F%2Fn.sinaimg.cn%2Ffront%2F444%2Fw800h444%2F20180424%2FZ13J-fzqvvsa7695404.jpg)\n"
"> ## 线上小麦云课堂接口 [点击查看详情](http://qa-results.ixm5.cn/automation_script_results/zhangying_reports/"+file_lists[-1]+")\n"
},
}
String_textMsg = json.dumps(data)
res = requests.post(url, data=String_textMsg, headers=HEADERS, verify=False)
print(res.text)
os.system("hrun 小麦云课堂接口测试.yml --report-dir /home/wwwroot/automation_script_results/zhangying_reports/");
dir ="/home/wwwroot/automation_script_results/zhangying_reports/"
find_new_file(dir)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment