This commit is contained in:
Mr Chen
2024-11-24 05:48:35 +08:00
parent 141c56fbc2
commit 941285d168
2 changed files with 17 additions and 11 deletions
+6 -2
View File
@@ -5,8 +5,12 @@ import io
import os
import time
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():
+11 -9
View File
@@ -6,8 +6,13 @@ 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 +38,9 @@ def getTaskConf():
def getConfigData():
try:
conf = getTaskConf()
if os.path.exists(conf):
return json.loads(mw.readFile(getTaskConf()))
except:
pass
return {
"task_id": -1,
"period": "day-n",
@@ -97,7 +101,7 @@ logs_file=$plugin_path/${rname}.log
'urladdress': '',
}
task_id = api.add(params)
task_id = MwCrontab.instance().add(params)
if task_id > 0:
args["task_id"] = task_id
args["name"] = name
@@ -110,9 +114,7 @@ def removeBgTask():
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
mw.writeFile(getTaskConf(), json.dumps(cfg))