This commit is contained in:
Faker
2022-08-11 10:15:39 +08:00
parent 6fd5e65328
commit 286b4f00ca
6 changed files with 240 additions and 341 deletions

View File

@@ -28,7 +28,7 @@ if not ipport:
ipport = "localhost:5700"
else:
ipport = ipport.lstrip("http://").rstrip("/")
sub_str = os.getenv("RES_SUB", "shufflewzc_faker3")
sub_str = os.getenv("RES_SUB", "shufflewzc_faker2")
sub_list = sub_str.split("&")
res_only = os.getenv("RES_ONLY", True)
headers = {
@@ -83,6 +83,17 @@ def get_index(lst: list, item: str) -> list:
return [index for (index, value) in enumerate(lst) if value == item]
def getversion():
url = f"http://{ipport}/api/system"
response = requests.get(url=url)
data = json.loads(response.content.decode("utf-8"))
version = data.get("data").get("version")
if int(version.split('.')[0]) >= 2:
if int(version.split('.')[1]) >= 12:
return 1
return 0
def get_duplicate_list(tasklist: list) -> tuple:
logger.info("\n=== 第一轮初筛开始 ===")
@@ -90,7 +101,10 @@ def get_duplicate_list(tasklist: list) -> tuple:
names = []
cmds = []
for task in tasklist:
ids.append(task.get("_id"))
if getversion() == 1:
ids.append(task.get("id"))
else:
ids.append(task.get("_id"))
names.append(task.get("name"))
cmds.append(task.get("command"))
@@ -155,8 +169,12 @@ def disable_duplicate_tasks(ids: list) -> None:
def get_token() -> str or None:
try:
with open("/ql/config/auth.json", "r", encoding="utf-8") as f:
data = json.load(f)
if getversion() == 1:
with open("/ql/data/config/auth.json", "r", encoding="utf-8") as f:
data = json.load(f)
else:
with open("/ql/config/auth.json", "r", encoding="utf-8") as f:
data = json.load(f)
except Exception:
logger.info(f"❌无法获取 token!!!\n{traceback.format_exc()}")
send("💔禁用重复任务失败", "无法获取 token!!!")