From c5dcd097126cb73f3d699fbed2408cd161000381 Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 3 Nov 2018 18:19:47 +0800 Subject: [PATCH] u --- class/public.py | 23 ++++++++++++++++------- plugins/score/info.json | 13 +++++++------ plugins/score/install.sh | 7 +------ plugins/score/ping.pl | 4 ++++ route/files.py | 2 ++ route/plugins.py | 2 +- 6 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 plugins/score/ping.pl diff --git a/class/public.py b/class/public.py index e518486b6..706fe3169 100755 --- a/class/public.py +++ b/class/public.py @@ -17,7 +17,7 @@ sys.path.append(os.getcwd() + "/class/") import db from random import Random -from flask import jsonify +# from flask import jsonify def getRunDir(): @@ -76,6 +76,11 @@ def retJson(status, msg, data=()): return jsonify({'status': status, 'msg': msg, 'data': data}) +def getJson(data): + import json + return json.dumps(data) + + def returnJson(status, msg, args=()): # 取通用Json返回 return getJson(returnMsg(status, msg, args)) @@ -244,9 +249,11 @@ def GetLastLine(inputfile, lineNum): # 读文件指定倒数行数 try: fp = open(inputfile, 'r') + print fp lastLine = "" lines = fp.readlines() + print lines count = len(lines) if count > lineNum: num = lineNum @@ -263,12 +270,16 @@ def GetLastLine(inputfile, lineNum): result = '' lineNum -= 1 + print lastre while lineNum > 0: - result += lastre[lineNum] + "\n" + print lineNum + # lastre[lineNum] + # result += lastre[lineNum] + "\n" lineNum -= 1 return result - except: + except (IOError, ZeroDivisionError), e: + # print e.message return getMsg('TASK_SLEEP') @@ -350,20 +361,18 @@ def GetLocalIp(): # except: # return web.ctx.host.split(':')[0] -# 搜索数据中是否存在 - def inArray(arrays, searchStr): + # 搜索数据中是否存在 for key in arrays: if key == searchStr: return True return False -# 检查Web服务器配置文件是否有错误 - def checkWebConfig(): + # 检查Web服务器配置文件是否有错误 if get_webserver() == 'nginx': result = ExecShell( "ulimit -n 10240 && /www/server/nginx/sbin/nginx -t -c /www/server/nginx/conf/nginx.conf") diff --git a/plugins/score/info.json b/plugins/score/info.json index 68b610495..b1b59df08 100755 --- a/plugins/score/info.json +++ b/plugins/score/info.json @@ -1,16 +1,17 @@ { - "title":"宝塔跑分", + "title":"MW跑分", "tip":"lib", "name":"score", "type":"扩展", "ps":"测试服务器基础性能!", "versions":"1.3", - "shell":"score.sh", + "install":"install.sh", + "uninstall":"uninstall.sh", "checks":"/www/server/panel/plugin/score", - "author":"宝塔", - "home":"http://www.bt.cn/bbs", - "date":"2017-10-16", + "author":"mdserver-web", + "home":"github.com/midoks/mdserver-web", + "date":"2018-11-02", "default":false, "display":0, - "pid":"2" + "pid":"4" } \ No newline at end of file diff --git a/plugins/score/install.sh b/plugins/score/install.sh index ed1e22f65..eed5c3314 100755 --- a/plugins/score/install.sh +++ b/plugins/score/install.sh @@ -53,9 +53,4 @@ Uninstall_score() } -action=$1 -if [ "${1}" == 'install' ];then - Install_score -else - Uninstall_score -fi +Install_score diff --git a/plugins/score/ping.pl b/plugins/score/ping.pl new file mode 100644 index 000000000..2b7d10846 --- /dev/null +++ b/plugins/score/ping.pl @@ -0,0 +1,4 @@ + download.bt.cn + 103.224.251.67 + 128.1.164.196 + 125.88.182.172 diff --git a/route/files.py b/route/files.py index 1df9bdac2..56452a0f8 100644 --- a/route/files.py +++ b/route/files.py @@ -25,7 +25,9 @@ def GetDiskInfo(): @files.route('/GetExecLog', methods=['POST']) def GetExecLog(): + file = os.getcwd() + "/tmp/panelExec.log" + print file v = public.GetLastLine(file, 100) return v diff --git a/route/plugins.py b/route/plugins.py index c1205cb7e..5ae212217 100644 --- a/route/plugins.py +++ b/route/plugins.py @@ -101,7 +101,7 @@ def install(): public.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd) - return public.retJson(True, '已将安装任务添加到队列!') + return public.returnJson(True, '已将安装任务添加到队列!') @plugins.route('/uninstall', methods=['POST'])