Skip to content

Commit

Permalink
✨ Update & Rename disableDuplicatexxx.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Oreo authored and Oreo committed Nov 28, 2021
1 parent cf65b9c commit c4c5b13
Showing 1 changed file with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,25 @@
import requests

ip = "localhost"
substr = os.getenv("Reserve", "Aaron-lv_sync")


def loadSend():
print("加载推送功能")
global send
send = None
cur_path = os.path.abspath(os.path.dirname(__file__))
sys.path.append(cur_path)
if os.path.exists(cur_path + "/deleteDuplicateTasksNotify.py"):
if os.path.exists(cur_path + "/notify.py"):
try:
from deleteDuplicateTasksNotify import send
except Exception:
print("加载通知服务失败~")
from notify import send
except Exception as e:
send = None
print("加载通知服务失败~", e)


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",
}

Expand All @@ -49,11 +51,28 @@ def getTaskList():
def getDuplicate(taskList):
wholeNames = {}
duplicateID = []
taskListTemp = []
for task in taskList:
if task["name"] in wholeNames.keys():
if task["name"] in wholeNames.keys() and task["command"].find(substr) < 0:
duplicateID.append(task["_id"])
else:
taskListTemp.append(task)
wholeNames[task["name"]] = 1
return getDuplicateForOnlyRes(taskListTemp, duplicateID)


def getDuplicateForOnlyRes(taskListTemp, duplicateID):
if len(duplicateID) == 0:
return duplicateID
duplicateIDTemp = []
for task in taskListTemp:
for taskTemp in taskListTemp:
if (
task["_id"] != taskTemp["_id"]
and task["name"] == taskTemp["name"]
and task["command"].find(substr) < 0
):
duplicateID.append(task["_id"])
return duplicateID


Expand Down Expand Up @@ -89,7 +108,6 @@ def loadToken():
with open("/ql/config/auth.json", "r", encoding="utf-8") as f:
data = json.load(f)
except Exception:
# pass
send("无法获取token", "")
return data["token"]

Expand All @@ -114,5 +132,6 @@ def loadToken():
print("没有重复任务")
else:
disableDuplicateTasks(duplicateID)
send("禁用成功", "\n%s\n%s" % (before, after))
# print("禁用结束!")
if send:
send("禁用成功", "\n%s\n%s" % (before, after))
# print("禁用结束!")

0 comments on commit c4c5b13

Please sign in to comment.