add: vfs_posix添加fflush适配
[LuatOS.git] / tools / ciNotify.py
blob134f96202514a47d82728e135a96d60571840d8e
1 import sys
2 import paho.mqtt.client as mqtt
3 import paho.mqtt.publish as publish
4 from git import Repo
5 import urllib
6 import requests
7 import http.cookiejar
8 import json
10 #$MQTTADDR $MQTTPORT $MQTTTOPIC "https://xxxx" "air101" DD_APPKEY DD_APPSECRET DD_NOTIFY_LIST DD_API_TOKEN DD_API_SEND
11 # 1 2 3 4 5 6 7 8 9 10
13 repo = Repo("../")
15 #暂时停用
16 ############# MQTT ###############
17 # client = mqtt.Client()
18 # try:
19 # #服务器请自行修改,需要传入参数
20 # client.connect(sys.argv[1], int(sys.argv[2]), 60)
21 # #topic请根据需要自行修改,需要传入参数
22 # info = sys.argv[4]+"\r\n"+str(repo.head.commit.author)+"-"+str(repo.head.commit.message)
23 # if len(sys.argv) >= 6:
24 # repo = Repo("../../"+sys.argv[5])
25 # info = info+"\r\n子仓库"+sys.argv[5]+"最后提交:\r\n"+str(repo.head.commit.author)+"-"+str(repo.head.commit.message)
26 # pub = client.publish(sys.argv[3],info)
27 # pub.wait_for_publish()
28 # client.disconnect()
29 # print("sent")
30 # except Exception as e:
31 # print(e)
34 ###############钉钉提醒######################
36 dd_appkey = sys.argv[6]
37 dd_appsecret = sys.argv[7]
38 dd_list = sys.argv[8].split(",")
39 dd_api_token = sys.argv[9]
40 dd_api_send = sys.argv[10]
41 try:
42 headers = {'user-agent': '114514'}
43 token = requests.post(dd_api_token,json={"appKey":dd_appkey,"appSecret":dd_appsecret},headers=headers).json()["accessToken"]
44 #发消息
45 headers = {'user-agent': '114514', 'x-acs-dingtalk-access-token': token}
46 r = requests.post(dd_api_send,json={
47 "robotCode":dd_appkey,
48 "userIds":dd_list,
49 "msgKey" : "sampleLink",
50 "msgParam" : json.dumps({
51 "title": sys.argv[5]+"的编译炸了",
52 "text": "最后提交:"+str(repo.head.commit.author)+"\r\n"+str(repo.head.commit.message),
53 "messageUrl": sys.argv[4],
54 "picUrl": "https://www.luatos.com/img/footer-logo.png",
56 },headers=headers)
58 print(r.json())
60 except Exception as e:
61 print(e)