diff --git a/plugins/acme_pandominassl_apply/index.py b/plugins/acme_pandominassl_apply/index.py index e7ba431a2..6e31800bc 100755 --- a/plugins/acme_pandominassl_apply/index.py +++ b/plugins/acme_pandominassl_apply/index.py @@ -8,8 +8,12 @@ import re import requests 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 app_debug = False if mw.isAppleSystem(): diff --git a/plugins/alist/index.py b/plugins/alist/index.py index 3f14b33af..7399dcf7e 100755 --- a/plugins/alist/index.py +++ b/plugins/alist/index.py @@ -6,8 +6,12 @@ import os import time import re -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/backup_ftp/index.py b/plugins/backup_ftp/index.py index 34dd3f959..1f1403890 100755 --- a/plugins/backup_ftp/index.py +++ b/plugins/backup_ftp/index.py @@ -12,9 +12,13 @@ if sys.platform != "darwin": os.chdir("/www/server/mdserver-web") -sys.path.append(os.getcwd() + "/class/core") -import mw -import db +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 +import core.db as db _ver = sys.version_info is_py2 = (_ver[0] == 2) @@ -251,8 +255,7 @@ def backupAllFunc(stype): _name = 'path_{}'.format(os.path.basename(name)) find_path = mw.getBackupDir() + '/path/'+_name - find_new_file = "ls " + find_path + \ - "_* | grep '.gz' | cut -d \ -f 1 | awk 'END {print}'" + find_new_file = "ls " + find_path + "_* | grep '.gz' | cut -d \\ -f 1 | awk 'END {print}'" filename = mw.execShell(find_new_file)[0].strip() if filename == "": diff --git a/plugins/cloudreve/index.py b/plugins/cloudreve/index.py index a312a2028..c89d411a4 100755 --- a/plugins/cloudreve/index.py +++ b/plugins/cloudreve/index.py @@ -6,8 +6,12 @@ import os import time import re -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/data_query/index.py b/plugins/data_query/index.py index 9bc0dd431..0d8061b61 100755 --- a/plugins/data_query/index.py +++ b/plugins/data_query/index.py @@ -6,8 +6,12 @@ import os import time import re -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/data_query/nosql_memcached.py b/plugins/data_query/nosql_memcached.py index 4b392aad8..18b844edf 100755 --- a/plugins/data_query/nosql_memcached.py +++ b/plugins/data_query/nosql_memcached.py @@ -11,11 +11,12 @@ import re import json import pymemcache -try: - sys.path.append(os.getcwd() + "/class/core") - import mw -except Exception as e: - import core.mw as 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 def singleton(cls): diff --git a/plugins/data_query/nosql_mongodb.py b/plugins/data_query/nosql_mongodb.py index 286c63e45..9b22b9118 100755 --- a/plugins/data_query/nosql_mongodb.py +++ b/plugins/data_query/nosql_mongodb.py @@ -12,11 +12,12 @@ import yaml from bson.objectid import ObjectId from bson.json_util import dumps -try: - sys.path.append(os.getcwd() + "/class/core") - import mw -except Exception as e: - import core.mw as 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 def singleton(cls): _instance = {} diff --git a/plugins/data_query/nosql_redis.py b/plugins/data_query/nosql_redis.py index 65eb675e5..8a3e10f4a 100755 --- a/plugins/data_query/nosql_redis.py +++ b/plugins/data_query/nosql_redis.py @@ -7,12 +7,12 @@ import time import re import redis +web_dir = os.getcwd() + "/web" +if os.path.exists(web_dir): + sys.path.append(web_dir) + os.chdir(web_dir) -try: - sys.path.append(os.getcwd() + "/class/core") - import mw -except Exception as e: - import core.mw as mw +import core.mw as mw # def getPluginName(): diff --git a/plugins/data_query/sql_mysql.py b/plugins/data_query/sql_mysql.py index ee8c83fbf..6b9dc35e4 100755 --- a/plugins/data_query/sql_mysql.py +++ b/plugins/data_query/sql_mysql.py @@ -8,11 +8,12 @@ import re import pymongo import json -try: - sys.path.append(os.getcwd() + "/class/core") - import mw -except Exception as e: - import core.mw as 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 def singleton(cls): _instance = {} diff --git a/plugins/docker/index.py b/plugins/docker/index.py index 59488cead..128498d9a 100755 --- a/plugins/docker/index.py +++ b/plugins/docker/index.py @@ -7,8 +7,12 @@ import time import re 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 try: import docker diff --git a/plugins/dynamic-tracking/index.py b/plugins/dynamic-tracking/index.py index 12a4d4a93..a54965cdc 100755 --- a/plugins/dynamic-tracking/index.py +++ b/plugins/dynamic-tracking/index.py @@ -6,8 +6,13 @@ import os import time import re -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/fail2ban/index.py b/plugins/fail2ban/index.py index f2917dcdb..a1aa4e003 100755 --- a/plugins/fail2ban/index.py +++ b/plugins/fail2ban/index.py @@ -7,8 +7,12 @@ import time import re 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 app_debug = False if mw.isAppleSystem(): diff --git a/plugins/gdrive/index.py b/plugins/gdrive/index.py index edf1ed57b..bf940d4c6 100644 --- a/plugins/gdrive/index.py +++ b/plugins/gdrive/index.py @@ -13,9 +13,13 @@ if sys.platform != "darwin": os.chdir("/www/server/mdserver-web") -sys.path.append(os.getcwd() + "/class/core") -import mw -import db +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 +import core.db as db _ver = sys.version_info is_py2 = (_ver[0] == 2) diff --git a/plugins/gitea/index.py b/plugins/gitea/index.py index 8aff8694e..40305aa35 100755 --- a/plugins/gitea/index.py +++ b/plugins/gitea/index.py @@ -7,15 +7,12 @@ import sys import re import subprocess -sys.path.append(os.getcwd() + "/class/core") -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) +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/gogs/index.py b/plugins/gogs/index.py index 5311feefc..20c7bc69e 100755 --- a/plugins/gogs/index.py +++ b/plugins/gogs/index.py @@ -5,18 +5,16 @@ import time import os import sys 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 mw - +import core.mw as 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 diff --git a/plugins/gorse/index.py b/plugins/gorse/index.py index 35855b5f8..21465ef60 100755 --- a/plugins/gorse/index.py +++ b/plugins/gorse/index.py @@ -6,8 +6,12 @@ import os import time import re -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/haproxy/index.py b/plugins/haproxy/index.py index 452fa05e9..675ba84d0 100755 --- a/plugins/haproxy/index.py +++ b/plugins/haproxy/index.py @@ -8,8 +8,12 @@ import re import string import subprocess -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/imail/index.py b/plugins/imail/index.py index a79b8d576..a61ac5f3f 100755 --- a/plugins/imail/index.py +++ b/plugins/imail/index.py @@ -10,8 +10,12 @@ import json from datetime import datetime -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/keepalived/index.py b/plugins/keepalived/index.py index 12455677b..ecd5e8a80 100755 --- a/plugins/keepalived/index.py +++ b/plugins/keepalived/index.py @@ -6,8 +6,12 @@ import os import time import re -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/lvs/index.py b/plugins/lvs/index.py index 9b7ca8c40..82a9f21a3 100755 --- a/plugins/lvs/index.py +++ b/plugins/lvs/index.py @@ -8,8 +8,12 @@ import re import string import subprocess -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/mariadb/index.py b/plugins/mariadb/index.py index 8e9c75f7a..ea61704bb 100755 --- a/plugins/mariadb/index.py +++ b/plugins/mariadb/index.py @@ -9,11 +9,12 @@ import re import json -# reload(sys) -# sys.setdefaultencoding('utf-8') +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 mw +import core.mw as mw if mw.isAppleSystem(): diff --git a/plugins/mariadb/index_mariadb.py b/plugins/mariadb/index_mariadb.py index 2eed99a8e..644f32576 100644 --- a/plugins/mariadb/index_mariadb.py +++ b/plugins/mariadb/index_mariadb.py @@ -8,8 +8,12 @@ import subprocess import re 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 if mw.isAppleSystem(): diff --git a/plugins/memcached/index.py b/plugins/memcached/index.py index b6b47d343..617f33a2e 100755 --- a/plugins/memcached/index.py +++ b/plugins/memcached/index.py @@ -6,8 +6,12 @@ import os import time import re -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/migration_api/index.py b/plugins/migration_api/index.py index 2d8fd706e..425806cc5 100755 --- a/plugins/migration_api/index.py +++ b/plugins/migration_api/index.py @@ -9,8 +9,12 @@ import hashlib import json import subprocess -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/mongodb/index.py b/plugins/mongodb/index.py index cfb06584e..c288d66d3 100755 --- a/plugins/mongodb/index.py +++ b/plugins/mongodb/index.py @@ -9,8 +9,12 @@ import json import datetime import yaml -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/mosquitto/index.py b/plugins/mosquitto/index.py index 5ef4472f7..a1ffaf440 100755 --- a/plugins/mosquitto/index.py +++ b/plugins/mosquitto/index.py @@ -6,8 +6,12 @@ import os import time import re -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/msonedrive/index.py b/plugins/msonedrive/index.py index 2a451df2c..854ec3aec 100644 --- a/plugins/msonedrive/index.py +++ b/plugins/msonedrive/index.py @@ -13,9 +13,13 @@ if sys.platform != "darwin": os.chdir("/www/server/mdserver-web") -sys.path.append(os.getcwd() + "/class/core") -import mw -import db +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 +import core.db as db _ver = sys.version_info is_py2 = (_ver[0] == 2) diff --git a/plugins/mysql-apt/index.py b/plugins/mysql-apt/index.py index 456d9aa11..09e79f3fc 100755 --- a/plugins/mysql-apt/index.py +++ b/plugins/mysql-apt/index.py @@ -9,11 +9,12 @@ import re import json -# reload(sys) -# sys.setdefaultencoding('utf-8') +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 mw +import core.mw as mw app_debug = False if mw.isAppleSystem(): diff --git a/plugins/mysql-apt/index_mysql_apt.py b/plugins/mysql-apt/index_mysql_apt.py index a61c2a015..323d051a9 100644 --- a/plugins/mysql-apt/index_mysql_apt.py +++ b/plugins/mysql-apt/index_mysql_apt.py @@ -8,9 +8,12 @@ import subprocess import re 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 if mw.isAppleSystem(): cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' diff --git a/plugins/mysql-yum/index.py b/plugins/mysql-yum/index.py index 2ce17b7b3..aa61fefb5 100755 --- a/plugins/mysql-yum/index.py +++ b/plugins/mysql-yum/index.py @@ -9,12 +9,12 @@ import re import json -# reload(sys) -# sys.setdefaultencoding('utf-8') - -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 if mw.isAppleSystem(): cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' diff --git a/plugins/mysql-yum/index_mysql_yum.py b/plugins/mysql-yum/index_mysql_yum.py index 1f7cc3a71..7252b633e 100644 --- a/plugins/mysql-yum/index_mysql_yum.py +++ b/plugins/mysql-yum/index_mysql_yum.py @@ -8,9 +8,12 @@ import subprocess import re 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 if mw.isAppleSystem(): cmd = 'ls /usr/local/lib/ | grep python | cut -d \\ -f 1 | awk \'END {print}\'' diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 885536eb3..84e12e7cd 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -10,11 +10,12 @@ import re import json -# reload(sys) -# sys.setdefaultencoding('utf-8') +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 mw +import core.mw as mw if mw.isAppleSystem(): diff --git a/plugins/mysql/index_mysql.py b/plugins/mysql/index_mysql.py index 791d9038f..89d987490 100644 --- a/plugins/mysql/index_mysql.py +++ b/plugins/mysql/index_mysql.py @@ -8,8 +8,12 @@ import subprocess import re 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 if mw.isAppleSystem(): diff --git a/plugins/nezha/index.py b/plugins/nezha/index.py index 7f4dc3db4..0fa578c8c 100755 --- a/plugins/nezha/index.py +++ b/plugins/nezha/index.py @@ -10,8 +10,12 @@ import json from datetime import datetime -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/op_load_balance/index.py b/plugins/op_load_balance/index.py index 59a646fb2..622c3025b 100755 --- a/plugins/op_load_balance/index.py +++ b/plugins/op_load_balance/index.py @@ -8,8 +8,12 @@ import subprocess import json import re -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 diff --git a/plugins/phpmyadmin/index.py b/plugins/phpmyadmin/index.py index eac12be55..5e8df07eb 100755 --- a/plugins/phpmyadmin/index.py +++ b/plugins/phpmyadmin/index.py @@ -7,9 +7,13 @@ import time import re import json -sys.path.append(os.getcwd() + "/class/core") -import mw -import site_api +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.site import sites as MwSites app_debug = False if mw.isAppleSystem(): @@ -85,7 +89,7 @@ def getHomePage(): def getPhpVer(expect=55): - v = site_api.site_api().getPhpVersion() + v = MwSites.instance().getPhpVersion() is_find = False for i in range(len(v)): t = str(v[i]['version']) @@ -142,7 +146,7 @@ def contentReplace(content): content = content.replace('{$PMA_PATH}', cfg['path']) port = cfg["port"] - rep = 'listen\s*(.*);' + rep = r'listen\s*(.*);' content = re.sub(rep, "listen " + port + ';', content) return content diff --git a/plugins/postgresql/index.py b/plugins/postgresql/index.py index c7217219d..22dfc7fff 100755 --- a/plugins/postgresql/index.py +++ b/plugins/postgresql/index.py @@ -17,8 +17,12 @@ import json # ps -ef | grep -v grep| grep run_info | awk '{print $2}' | xargs kill -9 # vi /etc/sysconfig/network-scripts/ifcfg-eth0 -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 if mw.isAppleSystem(): diff --git a/plugins/pureftp/index.py b/plugins/pureftp/index.py index 6bb40ff74..909f71ab9 100755 --- a/plugins/pureftp/index.py +++ b/plugins/pureftp/index.py @@ -6,8 +6,12 @@ import os import time import shutil -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/redis/index.py b/plugins/redis/index.py index 74c117897..3d451c02e 100755 --- a/plugins/redis/index.py +++ b/plugins/redis/index.py @@ -6,8 +6,12 @@ import os import time import re -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/simpleping/index.py b/plugins/simpleping/index.py index 6565cf2f4..176536c90 100755 --- a/plugins/simpleping/index.py +++ b/plugins/simpleping/index.py @@ -6,8 +6,12 @@ import os import time import re -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/sphinx/index.py b/plugins/sphinx/index.py index ade4fca3d..9a04a5d22 100755 --- a/plugins/sphinx/index.py +++ b/plugins/sphinx/index.py @@ -8,8 +8,12 @@ import re import string import subprocess -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/sphinx/tool_cron.py b/plugins/sphinx/tool_cron.py index 063573d37..19a1ec6a0 100644 --- a/plugins/sphinx/tool_cron.py +++ b/plugins/sphinx/tool_cron.py @@ -6,8 +6,14 @@ 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 @@ -35,12 +41,10 @@ def getTaskDeltaConf(): conf = getServerDir() + "/cron_delta_config.json" return conf - 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", @@ -50,10 +54,9 @@ def getConfigData(): } def getConfigDeltaData(): - try: + conf = getTaskDeltaConf() + if os.path.exists(conf): return json.loads(mw.readFile(getTaskDeltaConf())) - except: - pass return { "task_id": -1, "period": "minute-n", @@ -80,15 +83,12 @@ def createBgTaskByName(name): return True if "task_id" in args and args["task_id"] > 0: - res = mw.M("crontab").field("id, name").where( - "id=?", (args["task_id"],)).find() + res = mw.M("crontab").field("id, name").where("id=?", (args["task_id"],)).find() if res and res["id"] == args["task_id"]: print("计划任务已经存在!") return True - import crontab_api - api = crontab_api.crontab_api() - mw_dir = mw.getRunDir() + mw_dir = mw.getPanelDir() cmd = ''' mw_dir=%s rname=%s @@ -118,7 +118,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 @@ -132,15 +132,12 @@ def createBgTaskDeltaByName(name): return True if "task_id" in args and args["task_id"] > 0: - res = mw.M("crontab").field("id, name").where( - "id=?", (args["task_id"],)).find() + res = mw.M("crontab").field("id, name").where("id=?", (args["task_id"],)).find() if res and res["id"] == args["task_id"]: print("计划任务已经存在!") return True - import crontab_api - api = crontab_api.crontab_api() - mw_dir = mw.getRunDir() + mw_dir = mw.getPanelDir() cmd = ''' mw_dir=%s rname=%s @@ -170,7 +167,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 @@ -183,9 +180,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)) @@ -198,9 +193,7 @@ def removeDeltaBgTask(): 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(getTaskDeltaConf(), json.dumps(cfg)) diff --git a/plugins/supervisor/index.py b/plugins/supervisor/index.py index efc9c6293..0fe4780b8 100755 --- a/plugins/supervisor/index.py +++ b/plugins/supervisor/index.py @@ -6,8 +6,12 @@ import os import time import re -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/swap/index.py b/plugins/swap/index.py index dddc1aac8..3fb07947c 100755 --- a/plugins/swap/index.py +++ b/plugins/swap/index.py @@ -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(): diff --git a/plugins/sys-opt/index.py b/plugins/sys-opt/index.py index 0b97057be..26a7a7bb0 100755 --- a/plugins/sys-opt/index.py +++ b/plugins/sys-opt/index.py @@ -7,8 +7,12 @@ 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 def getPluginName(): diff --git a/plugins/system_safe/system_safe.py b/plugins/system_safe/system_safe.py index b454a8685..d0f0352d1 100755 --- a/plugins/system_safe/system_safe.py +++ b/plugins/system_safe/system_safe.py @@ -10,8 +10,13 @@ import psutil from datetime import datetime 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 if mw.isAppleSystem(): diff --git a/plugins/tamper_proof_py/index.py b/plugins/tamper_proof_py/index.py index 446dee0c3..82c06070b 100755 --- a/plugins/tamper_proof_py/index.py +++ b/plugins/tamper_proof_py/index.py @@ -10,8 +10,12 @@ import psutil from datetime import datetime 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 if mw.isAppleSystem(): diff --git a/plugins/task_manager/index.py b/plugins/task_manager/index.py index f2f22f90e..90173fb97 100755 --- a/plugins/task_manager/index.py +++ b/plugins/task_manager/index.py @@ -6,8 +6,12 @@ import os import time import re -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/task_manager/task_manager_index.py b/plugins/task_manager/task_manager_index.py index 9790b19b9..22a44fb91 100755 --- a/plugins/task_manager/task_manager_index.py +++ b/plugins/task_manager/task_manager_index.py @@ -11,11 +11,12 @@ import json from typing import List, Dict -try: - sys.path.append(os.getcwd() + "/class/core") - import mw -except Exception as e: - import core.mw as 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 diff --git a/plugins/tgbot/index.py b/plugins/tgbot/index.py index 95c1cbf19..0be333a8e 100755 --- a/plugins/tgbot/index.py +++ b/plugins/tgbot/index.py @@ -8,8 +8,12 @@ import re import json import base64 -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/tgclient/index.py b/plugins/tgclient/index.py index a10030ab9..ec2eb7238 100755 --- a/plugins/tgclient/index.py +++ b/plugins/tgclient/index.py @@ -8,8 +8,12 @@ import re import json import base64 -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/varnish/index.py b/plugins/varnish/index.py index 9b761e997..050e842a0 100755 --- a/plugins/varnish/index.py +++ b/plugins/varnish/index.py @@ -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(): diff --git a/plugins/webhook/index.py b/plugins/webhook/index.py index 4fb14d030..15189f727 100755 --- a/plugins/webhook/index.py +++ b/plugins/webhook/index.py @@ -7,8 +7,12 @@ import time import re 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 app_debug = False if mw.isAppleSystem(): diff --git a/plugins/webhook/webhook_index.py b/plugins/webhook/webhook_index.py index 5b2777da6..dc60912d3 100755 --- a/plugins/webhook/webhook_index.py +++ b/plugins/webhook/webhook_index.py @@ -7,8 +7,12 @@ import time import re 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 app_debug = False if mw.isAppleSystem(): diff --git a/plugins/webssh/index.py b/plugins/webssh/index.py index ad624bc32..4aacad870 100755 --- a/plugins/webssh/index.py +++ b/plugins/webssh/index.py @@ -7,8 +7,12 @@ 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 class App(): diff --git a/plugins/xhprof/index.py b/plugins/xhprof/index.py index cbe06fd73..7bd54ee70 100755 --- a/plugins/xhprof/index.py +++ b/plugins/xhprof/index.py @@ -6,9 +6,13 @@ import os import time import re -sys.path.append(os.getcwd() + "/class/core") -import mw -import site_api +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.site import sites as MwSites app_debug = False if mw.isAppleSystem(): @@ -70,7 +74,7 @@ def getHomePage(): def getPhpVer(expect=56): import json - v = site_api.site_api().getPhpVersion() + v = MwSites.instance().getPhpVersion() for i in range(len(v)): t = int(v[i]['version']) if (t >= expect): diff --git a/plugins/zabbix/index.py b/plugins/zabbix/index.py index e7901729b..06ea20e96 100755 --- a/plugins/zabbix/index.py +++ b/plugins/zabbix/index.py @@ -6,8 +6,12 @@ import os import time import re -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/zabbix_agent/index.py b/plugins/zabbix_agent/index.py index 2b48cd444..797a1f6b2 100755 --- a/plugins/zabbix_agent/index.py +++ b/plugins/zabbix_agent/index.py @@ -6,8 +6,12 @@ import os import time import re -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():