修改引入公共方法方式

pull/632/head
Mr Chen 6 months ago
parent 941285d168
commit c9f03c0f69
  1. 8
      plugins/acme_pandominassl_apply/index.py
  2. 8
      plugins/alist/index.py
  3. 13
      plugins/backup_ftp/index.py
  4. 8
      plugins/cloudreve/index.py
  5. 8
      plugins/data_query/index.py
  6. 11
      plugins/data_query/nosql_memcached.py
  7. 11
      plugins/data_query/nosql_mongodb.py
  8. 10
      plugins/data_query/nosql_redis.py
  9. 11
      plugins/data_query/sql_mysql.py
  10. 8
      plugins/docker/index.py
  11. 9
      plugins/dynamic-tracking/index.py
  12. 8
      plugins/fail2ban/index.py
  13. 10
      plugins/gdrive/index.py
  14. 13
      plugins/gitea/index.py
  15. 14
      plugins/gogs/index.py
  16. 8
      plugins/gorse/index.py
  17. 8
      plugins/haproxy/index.py
  18. 8
      plugins/imail/index.py
  19. 8
      plugins/keepalived/index.py
  20. 8
      plugins/lvs/index.py
  21. 9
      plugins/mariadb/index.py
  22. 8
      plugins/mariadb/index_mariadb.py
  23. 8
      plugins/memcached/index.py
  24. 8
      plugins/migration_api/index.py
  25. 8
      plugins/mongodb/index.py
  26. 8
      plugins/mosquitto/index.py
  27. 10
      plugins/msonedrive/index.py
  28. 9
      plugins/mysql-apt/index.py
  29. 7
      plugins/mysql-apt/index_mysql_apt.py
  30. 10
      plugins/mysql-yum/index.py
  31. 7
      plugins/mysql-yum/index_mysql_yum.py
  32. 9
      plugins/mysql/index.py
  33. 8
      plugins/mysql/index_mysql.py
  34. 8
      plugins/nezha/index.py
  35. 8
      plugins/op_load_balance/index.py
  36. 14
      plugins/phpmyadmin/index.py
  37. 8
      plugins/postgresql/index.py
  38. 8
      plugins/pureftp/index.py
  39. 8
      plugins/redis/index.py
  40. 8
      plugins/simpleping/index.py
  41. 8
      plugins/sphinx/index.py
  42. 47
      plugins/sphinx/tool_cron.py
  43. 8
      plugins/supervisor/index.py
  44. 8
      plugins/swap/index.py
  45. 8
      plugins/sys-opt/index.py
  46. 9
      plugins/system_safe/system_safe.py
  47. 8
      plugins/tamper_proof_py/index.py
  48. 8
      plugins/task_manager/index.py
  49. 11
      plugins/task_manager/task_manager_index.py
  50. 8
      plugins/tgbot/index.py
  51. 8
      plugins/tgclient/index.py
  52. 8
      plugins/varnish/index.py
  53. 8
      plugins/webhook/index.py
  54. 8
      plugins/webhook/webhook_index.py
  55. 8
      plugins/webssh/index.py
  56. 12
      plugins/xhprof/index.py
  57. 8
      plugins/zabbix/index.py
  58. 8
      plugins/zabbix_agent/index.py

@ -8,8 +8,12 @@ import re
import requests import requests
import json import json
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -6,8 +6,12 @@ import os
import time import time
import re import re
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -12,9 +12,13 @@ if sys.platform != "darwin":
os.chdir("/www/server/mdserver-web") os.chdir("/www/server/mdserver-web")
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
import db sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
import core.db as db
_ver = sys.version_info _ver = sys.version_info
is_py2 = (_ver[0] == 2) is_py2 = (_ver[0] == 2)
@ -251,8 +255,7 @@ def backupAllFunc(stype):
_name = 'path_{}'.format(os.path.basename(name)) _name = 'path_{}'.format(os.path.basename(name))
find_path = mw.getBackupDir() + '/path/'+_name find_path = mw.getBackupDir() + '/path/'+_name
find_new_file = "ls " + find_path + \ find_new_file = "ls " + find_path + "_* | grep '.gz' | cut -d \\ -f 1 | awk 'END {print}'"
"_* | grep '.gz' | cut -d \ -f 1 | awk 'END {print}'"
filename = mw.execShell(find_new_file)[0].strip() filename = mw.execShell(find_new_file)[0].strip()
if filename == "": if filename == "":

@ -6,8 +6,12 @@ import os
import time import time
import re import re
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -6,8 +6,12 @@ import os
import time import time
import re import re
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -11,11 +11,12 @@ import re
import json import json
import pymemcache import pymemcache
try: web_dir = os.getcwd() + "/web"
sys.path.append(os.getcwd() + "/class/core") if os.path.exists(web_dir):
import mw sys.path.append(web_dir)
except Exception as e: os.chdir(web_dir)
import core.mw as mw
import core.mw as mw
def singleton(cls): def singleton(cls):

@ -12,11 +12,12 @@ import yaml
from bson.objectid import ObjectId from bson.objectid import ObjectId
from bson.json_util import dumps from bson.json_util import dumps
try: web_dir = os.getcwd() + "/web"
sys.path.append(os.getcwd() + "/class/core") if os.path.exists(web_dir):
import mw sys.path.append(web_dir)
except Exception as e: os.chdir(web_dir)
import core.mw as mw
import core.mw as mw
def singleton(cls): def singleton(cls):
_instance = {} _instance = {}

@ -7,12 +7,12 @@ import time
import re import re
import redis import redis
web_dir = os.getcwd() + "/web"
if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
try: import core.mw as mw
sys.path.append(os.getcwd() + "/class/core")
import mw
except Exception as e:
import core.mw as mw
# def getPluginName(): # def getPluginName():

@ -8,11 +8,12 @@ import re
import pymongo import pymongo
import json import json
try: web_dir = os.getcwd() + "/web"
sys.path.append(os.getcwd() + "/class/core") if os.path.exists(web_dir):
import mw sys.path.append(web_dir)
except Exception as e: os.chdir(web_dir)
import core.mw as mw
import core.mw as mw
def singleton(cls): def singleton(cls):
_instance = {} _instance = {}

@ -7,8 +7,12 @@ import time
import re import re
import json import json
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
try: try:
import docker import docker

@ -6,8 +6,13 @@ import os
import time import time
import re import re
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -7,8 +7,12 @@ import time
import re import re
import json import json
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -13,9 +13,13 @@ if sys.platform != "darwin":
os.chdir("/www/server/mdserver-web") os.chdir("/www/server/mdserver-web")
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
import db sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
import core.db as db
_ver = sys.version_info _ver = sys.version_info
is_py2 = (_ver[0] == 2) is_py2 = (_ver[0] == 2)

@ -7,15 +7,12 @@ import sys
import re import re
import subprocess import subprocess
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
# cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\''
# info = mw.execShell(cmd)
# p = "/usr/local/lib/" + info[0].strip() + "/site-packages"
# sys.path.append(p)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -5,18 +5,16 @@ import time
import os import os
import sys import sys
import re import re
import psutil
web_dir = os.getcwd() + "/web"
if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
sys.path.append(os.getcwd() + "/class/core") import core.mw as mw
import mw
# cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\''
# info = mw.execShell(cmd)
# p = "/usr/local/lib/" + info[0].strip() + "/site-packages"
# sys.path.append(p)
import psutil
app_debug = False app_debug = False

@ -6,8 +6,12 @@ import os
import time import time
import re import re
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -8,8 +8,12 @@ import re
import string import string
import subprocess import subprocess
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -10,8 +10,12 @@ import json
from datetime import datetime from datetime import datetime
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -6,8 +6,12 @@ import os
import time import time
import re import re
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -8,8 +8,12 @@ import re
import string import string
import subprocess import subprocess
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -9,11 +9,12 @@ import re
import json import json
# reload(sys) web_dir = os.getcwd() + "/web"
# sys.setdefaultencoding('utf-8') if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
sys.path.append(os.getcwd() + "/class/core") import core.mw as mw
import mw
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -8,8 +8,12 @@ import subprocess
import re import re
import json import json
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -6,8 +6,12 @@ import os
import time import time
import re import re
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -9,8 +9,12 @@ import hashlib
import json import json
import subprocess import subprocess
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -9,8 +9,12 @@ import json
import datetime import datetime
import yaml import yaml
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -6,8 +6,12 @@ import os
import time import time
import re import re
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -13,9 +13,13 @@ if sys.platform != "darwin":
os.chdir("/www/server/mdserver-web") os.chdir("/www/server/mdserver-web")
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
import db sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
import core.db as db
_ver = sys.version_info _ver = sys.version_info
is_py2 = (_ver[0] == 2) is_py2 = (_ver[0] == 2)

@ -9,11 +9,12 @@ import re
import json import json
# reload(sys) web_dir = os.getcwd() + "/web"
# sys.setdefaultencoding('utf-8') if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
sys.path.append(os.getcwd() + "/class/core") import core.mw as mw
import mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -8,9 +8,12 @@ import subprocess
import re import re
import json import json
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
if mw.isAppleSystem(): if mw.isAppleSystem():
cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\''

@ -9,12 +9,12 @@ import re
import json import json
# reload(sys) web_dir = os.getcwd() + "/web"
# sys.setdefaultencoding('utf-8') if os.path.exists(web_dir):
sys.path.append(web_dir)
sys.path.append(os.getcwd() + "/class/core") os.chdir(web_dir)
import mw
import core.mw as mw
if mw.isAppleSystem(): if mw.isAppleSystem():
cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\''

@ -8,9 +8,12 @@ import subprocess
import re import re
import json import json
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
if mw.isAppleSystem(): if mw.isAppleSystem():
cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\''

@ -10,11 +10,12 @@ import re
import json import json
# reload(sys) web_dir = os.getcwd() + "/web"
# sys.setdefaultencoding('utf-8') if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
sys.path.append(os.getcwd() + "/class/core") import core.mw as mw
import mw
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -8,8 +8,12 @@ import subprocess
import re import re
import json import json
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -10,8 +10,12 @@ import json
from datetime import datetime from datetime import datetime
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -8,8 +8,12 @@ import subprocess
import json import json
import re import re
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False

@ -7,9 +7,13 @@ import time
import re import re
import json import json
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
import site_api sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
from utils.site import sites as MwSites
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():
@ -85,7 +89,7 @@ def getHomePage():
def getPhpVer(expect=55): def getPhpVer(expect=55):
v = site_api.site_api().getPhpVersion() v = MwSites.instance().getPhpVersion()
is_find = False is_find = False
for i in range(len(v)): for i in range(len(v)):
t = str(v[i]['version']) t = str(v[i]['version'])
@ -142,7 +146,7 @@ def contentReplace(content):
content = content.replace('{$PMA_PATH}', cfg['path']) content = content.replace('{$PMA_PATH}', cfg['path'])
port = cfg["port"] port = cfg["port"]
rep = 'listen\s*(.*);' rep = r'listen\s*(.*);'
content = re.sub(rep, "listen " + port + ';', content) content = re.sub(rep, "listen " + port + ';', content)
return content return content

@ -17,8 +17,12 @@ import json
# ps -ef | grep -v grep| grep run_info | awk '{print $2}' | xargs kill -9 # ps -ef | grep -v grep| grep run_info | awk '{print $2}' | xargs kill -9
# vi /etc/sysconfig/network-scripts/ifcfg-eth0 # vi /etc/sysconfig/network-scripts/ifcfg-eth0
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -6,8 +6,12 @@ import os
import time import time
import shutil import shutil
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -6,8 +6,12 @@ import os
import time import time
import re import re
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -6,8 +6,12 @@ import os
import time import time
import re import re
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -8,8 +8,12 @@ import re
import string import string
import subprocess import subprocess
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -6,8 +6,14 @@ import os
import time import time
import json import json
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw 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 app_debug = False
@ -35,12 +41,10 @@ def getTaskDeltaConf():
conf = getServerDir() + "/cron_delta_config.json" conf = getServerDir() + "/cron_delta_config.json"
return conf return conf
def getConfigData(): def getConfigData():
try: conf = getTaskConf()
if os.path.exists(conf):
return json.loads(mw.readFile(getTaskConf())) return json.loads(mw.readFile(getTaskConf()))
except:
pass
return { return {
"task_id": -1, "task_id": -1,
"period": "day-n", "period": "day-n",
@ -50,10 +54,9 @@ def getConfigData():
} }
def getConfigDeltaData(): def getConfigDeltaData():
try: conf = getTaskDeltaConf()
if os.path.exists(conf):
return json.loads(mw.readFile(getTaskDeltaConf())) return json.loads(mw.readFile(getTaskDeltaConf()))
except:
pass
return { return {
"task_id": -1, "task_id": -1,
"period": "minute-n", "period": "minute-n",
@ -80,15 +83,12 @@ def createBgTaskByName(name):
return True return True
if "task_id" in args and args["task_id"] > 0: if "task_id" in args and args["task_id"] > 0:
res = mw.M("crontab").field("id, name").where( res = mw.M("crontab").field("id, name").where("id=?", (args["task_id"],)).find()
"id=?", (args["task_id"],)).find()
if res and res["id"] == args["task_id"]: if res and res["id"] == args["task_id"]:
print("计划任务已经存在!") print("计划任务已经存在!")
return True return True
import crontab_api
api = crontab_api.crontab_api()
mw_dir = mw.getRunDir() mw_dir = mw.getPanelDir()
cmd = ''' cmd = '''
mw_dir=%s mw_dir=%s
rname=%s rname=%s
@ -118,7 +118,7 @@ logs_file=$plugin_path/${rname}.log
'urladdress': '', 'urladdress': '',
} }
task_id = api.add(params) task_id = MwCrontab.instance().add(params)
if task_id > 0: if task_id > 0:
args["task_id"] = task_id args["task_id"] = task_id
args["name"] = name args["name"] = name
@ -132,15 +132,12 @@ def createBgTaskDeltaByName(name):
return True return True
if "task_id" in args and args["task_id"] > 0: if "task_id" in args and args["task_id"] > 0:
res = mw.M("crontab").field("id, name").where( res = mw.M("crontab").field("id, name").where("id=?", (args["task_id"],)).find()
"id=?", (args["task_id"],)).find()
if res and res["id"] == args["task_id"]: if res and res["id"] == args["task_id"]:
print("计划任务已经存在!") print("计划任务已经存在!")
return True return True
import crontab_api
api = crontab_api.crontab_api()
mw_dir = mw.getRunDir() mw_dir = mw.getPanelDir()
cmd = ''' cmd = '''
mw_dir=%s mw_dir=%s
rname=%s rname=%s
@ -170,7 +167,7 @@ logs_file=$plugin_path/${rname}.log
'urladdress': '', 'urladdress': '',
} }
task_id = api.add(params) task_id = MwCrontab.instance().add(params)
if task_id > 0: if task_id > 0:
args["task_id"] = task_id args["task_id"] = task_id
args["name"] = name args["name"] = name
@ -183,9 +180,7 @@ def removeBgTask():
res = mw.M("crontab").field("id, name").where( res = mw.M("crontab").field("id, name").where(
"id=?", (cfg["task_id"],)).find() "id=?", (cfg["task_id"],)).find()
if res and res["id"] == cfg["task_id"]: if res and res["id"] == cfg["task_id"]:
import crontab_api data = MwCrontab.instance().delete(cfg["task_id"])
api = crontab_api.crontab_api()
data = api.delete(cfg["task_id"])
if data[0]: if data[0]:
cfg["task_id"] = -1 cfg["task_id"] = -1
mw.writeFile(getTaskConf(), json.dumps(cfg)) mw.writeFile(getTaskConf(), json.dumps(cfg))
@ -198,9 +193,7 @@ def removeDeltaBgTask():
res = mw.M("crontab").field("id, name").where( res = mw.M("crontab").field("id, name").where(
"id=?", (cfg["task_id"],)).find() "id=?", (cfg["task_id"],)).find()
if res and res["id"] == cfg["task_id"]: if res and res["id"] == cfg["task_id"]:
import crontab_api data = MwCrontab.instance().delete(cfg["task_id"])
api = crontab_api.crontab_api()
data = api.delete(cfg["task_id"])
if data[0]: if data[0]:
cfg["task_id"] = -1 cfg["task_id"] = -1
mw.writeFile(getTaskDeltaConf(), json.dumps(cfg)) mw.writeFile(getTaskDeltaConf(), json.dumps(cfg))

@ -6,8 +6,12 @@ import os
import time import time
import re import re
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -5,8 +5,12 @@ import io
import os import os
import time import time
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -7,8 +7,12 @@ import json
import re import re
import sys import sys
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
def getPluginName(): def getPluginName():

@ -10,8 +10,13 @@ import psutil
from datetime import datetime from datetime import datetime
sys.dont_write_bytecode = True sys.dont_write_bytecode = True
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 app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -10,8 +10,12 @@ import psutil
from datetime import datetime from datetime import datetime
sys.dont_write_bytecode = True sys.dont_write_bytecode = True
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -6,8 +6,12 @@ import os
import time import time
import re import re
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -11,11 +11,12 @@ import json
from typing import List, Dict from typing import List, Dict
try: web_dir = os.getcwd() + "/web"
sys.path.append(os.getcwd() + "/class/core") if os.path.exists(web_dir):
import mw sys.path.append(web_dir)
except Exception as e: os.chdir(web_dir)
import core.mw as mw
import core.mw as mw
app_debug = False app_debug = False

@ -8,8 +8,12 @@ import re
import json import json
import base64 import base64
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -8,8 +8,12 @@ import re
import json import json
import base64 import base64
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -5,8 +5,12 @@ import io
import os import os
import time import time
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -7,8 +7,12 @@ import time
import re import re
import json import json
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -7,8 +7,12 @@ import time
import re import re
import json import json
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -7,8 +7,12 @@ import json
import re import re
import sys import sys
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
class App(): class App():

@ -6,9 +6,13 @@ import os
import time import time
import re import re
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
import site_api sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
from utils.site import sites as MwSites
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():
@ -70,7 +74,7 @@ def getHomePage():
def getPhpVer(expect=56): def getPhpVer(expect=56):
import json import json
v = site_api.site_api().getPhpVersion() v = MwSites.instance().getPhpVersion()
for i in range(len(v)): for i in range(len(v)):
t = int(v[i]['version']) t = int(v[i]['version'])
if (t >= expect): if (t >= expect):

@ -6,8 +6,12 @@ import os
import time import time
import re import re
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

@ -6,8 +6,12 @@ import os
import time import time
import re import re
sys.path.append(os.getcwd() + "/class/core") web_dir = os.getcwd() + "/web"
import mw if os.path.exists(web_dir):
sys.path.append(web_dir)
os.chdir(web_dir)
import core.mw as mw
app_debug = False app_debug = False
if mw.isAppleSystem(): if mw.isAppleSystem():

Loading…
Cancel
Save