From b0392b7cf106a24fdaf83b47f7d135abae6a8738 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Sun, 24 Nov 2024 05:40:30 +0800 Subject: [PATCH] update --- plugins/rsyncd/index.py | 9 +++++++-- plugins/rsyncd/tool_task.py | 29 +++++++++++++++-------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/plugins/rsyncd/index.py b/plugins/rsyncd/index.py index 708031edb..778e4da14 100755 --- a/plugins/rsyncd/index.py +++ b/plugins/rsyncd/index.py @@ -7,8 +7,13 @@ import json import re import sys -sys.path.append(os.getcwd() + "/class/core") -import mw +web_dir = os.getcwd() + "/web" +if os.path.exists(web_dir): + sys.path.append(web_dir) + os.chdir(web_dir) + +import core.mw as mw + app_debug = False if mw.isAppleSystem(): diff --git a/plugins/rsyncd/tool_task.py b/plugins/rsyncd/tool_task.py index 0d332ea9b..e57f9eb9e 100644 --- a/plugins/rsyncd/tool_task.py +++ b/plugins/rsyncd/tool_task.py @@ -6,8 +6,15 @@ import os import time import json -sys.path.append(os.getcwd() + "/class/core") -import mw + +web_dir = os.getcwd() + "/web" +if os.path.exists(web_dir): + sys.path.append(web_dir) + os.chdir(web_dir) + +import core.mw as mw +from utils.crontab import crontab as MwCrontab + app_debug = False @@ -33,10 +40,9 @@ def getTaskConf(): def getConfigData(): - try: + conf = getTaskConf() + if os.path.exists(conf): return json.loads(mw.readFile(getTaskConf())) - except: - pass return [] @@ -68,8 +74,6 @@ def createBgTaskByName(name, args): if res and res["id"] == cfg["task_id"]: print("计划任务已经存在!") return True - import crontab_api - api = crontab_api.crontab_api() period = args['period'] _hour = '' @@ -108,10 +112,10 @@ logs_file=$plugin_path/send/${rname}/run.log 'stype': "toShell", 'sname': '', 'sbody': cmd, - 'urladdress': '', + 'url_address': '', } - task_id = api.add(params) + task_id = MwCrontab.instance().add(params) if task_id > 0: cfg["task_id"] = task_id cfg["name"] = name @@ -126,12 +130,9 @@ def removeBgTask(): for x in range(len(cfg_list)): cfg = cfg_list[x] if "task_id" in cfg.keys() and cfg["task_id"] > 0: - res = mw.M("crontab").field("id, name").where( - "id=?", (cfg["task_id"],)).find() + res = mw.M("crontab").field("id, name").where("id=?", (cfg["task_id"],)).find() if res and res["id"] == cfg["task_id"]: - import crontab_api - api = crontab_api.crontab_api() - data = api.delete(cfg["task_id"]) + data = MwCrontab.instance().delete(cfg["task_id"]) if data[0]: cfg["task_id"] = -1 cfg_list[x] = cfg