diff --git a/Scripts/py/disableDuplicateTasksImplement.py b/Scripts/py/disableDuplicateTasksImplement.py new file mode 100644 index 0000000..43c6a71 --- /dev/null +++ b/Scripts/py/disableDuplicateTasksImplement.py @@ -0,0 +1,108 @@ +# -*- coding:utf-8 -*- +import json +import os,sys +import requests +import time + +ip="localhost" + +def loadSend(): + print("加载推送功能") + global send + cur_path = os.path.abspath(os.path.dirname(__file__)) + sys.path.append(cur_path) + if os.path.exists(cur_path + "/deleteDuplicateTasksNotify.py"): + try: + from deleteDuplicateTasksNotify import send + except: + print("加载通知服务失败~") + +headers={ + "Accept": "application/json", + "Authorization": "Basic YWRtaW46YWRtaW4=", + "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36", +} + +def getTaskList(): + t = round(time.time() * 1000) + url = "http://%s:5700/api/crons?searchValue=&t=%d" % (ip, t) + response = requests.get(url=url, headers=headers) + responseContent=json.loads(response.content.decode('utf-8')) + if responseContent['code']==200: + taskList= responseContent['data'] + return taskList + else: + # 没有获取到taskList,返回空 + return [] + + +def getDuplicate(taskList): + wholeNames={} + duplicateID=[] + for task in taskList: + if task['name'] in wholeNames.keys(): + duplicateID.append(task['_id']) + else: + wholeNames[task['name']] = 1 + return duplicateID + + +def getData(duplicateID): + rawData = "[" + count=0 + for id in duplicateID: + rawData += "\"%s\""%id + if count