pull/632/head
Mr Chen 6 months ago
parent d57b0d0922
commit b0392b7cf1
  1. 9
      plugins/rsyncd/index.py
  2. 29
      plugins/rsyncd/tool_task.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():

@ -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

Loading…
Cancel
Save