This commit is contained in:
parent
c02e38106e
commit
c3cf5deda5
|
|
@ -240,6 +240,38 @@ def getSpeed():
|
|||
return json.loads(data)
|
||||
|
||||
|
||||
def GetLastLine(inputfile, lineNum):
|
||||
# 读文件指定倒数行数
|
||||
try:
|
||||
fp = open(inputfile, 'r')
|
||||
lastLine = ""
|
||||
|
||||
lines = fp.readlines()
|
||||
count = len(lines)
|
||||
if count > lineNum:
|
||||
num = lineNum
|
||||
else:
|
||||
num = count
|
||||
i = 1
|
||||
lastre = []
|
||||
for i in range(1, (num + 1)):
|
||||
if lines:
|
||||
n = -i
|
||||
lastLine = lines[n].strip()
|
||||
fp.close()
|
||||
lastre.append(lastLine)
|
||||
|
||||
result = ''
|
||||
lineNum -= 1
|
||||
while lineNum > 0:
|
||||
result += lastre[lineNum] + "\n"
|
||||
lineNum -= 1
|
||||
|
||||
return result
|
||||
except:
|
||||
return getMsg('TASK_SLEEP')
|
||||
|
||||
|
||||
def ExecShell(cmdstring, cwd=None, timeout=None, shell=True):
|
||||
|
||||
if shell:
|
||||
|
|
@ -346,10 +378,9 @@ def checkWebConfig():
|
|||
return result[1]
|
||||
return True
|
||||
|
||||
# 检查是否为IPv4地址
|
||||
|
||||
|
||||
def checkIp(ip):
|
||||
# 检查是否为IPv4地址
|
||||
import re
|
||||
p = re.compile(
|
||||
'^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$')
|
||||
|
|
@ -358,10 +389,9 @@ def checkIp(ip):
|
|||
else:
|
||||
return False
|
||||
|
||||
# 检查端口是否合法
|
||||
|
||||
|
||||
def checkPort(port):
|
||||
# 检查端口是否合法
|
||||
ports = ['21', '25', '443', '8080', '888', '8888', '8443']
|
||||
if port in ports:
|
||||
return False
|
||||
|
|
@ -370,10 +400,9 @@ def checkPort(port):
|
|||
return False
|
||||
return True
|
||||
|
||||
# 字符串取中间
|
||||
|
||||
|
||||
def getStrBetween(startStr, endStr, srcStr):
|
||||
# 字符串取中间
|
||||
start = srcStr.find(startStr)
|
||||
if start == -1:
|
||||
return None
|
||||
|
|
@ -394,23 +423,22 @@ def getCpuType():
|
|||
return cpuType
|
||||
|
||||
|
||||
# 检查是否允许重启
|
||||
def IsRestart():
|
||||
# 检查是否允许重启
|
||||
num = M('tasks').where('status!=?', ('1',)).count()
|
||||
if num > 0:
|
||||
return False
|
||||
return True
|
||||
|
||||
# 加密密码字符
|
||||
|
||||
|
||||
def hasPwd(password):
|
||||
# 加密密码字符
|
||||
import crypt
|
||||
return crypt.crypt(password, password)
|
||||
|
||||
|
||||
# 处理MySQL配置文件
|
||||
def CheckMyCnf():
|
||||
# 处理MySQL配置文件
|
||||
import os
|
||||
confFile = '/etc/my.cnf'
|
||||
if os.path.exists(confFile):
|
||||
|
|
@ -657,19 +685,17 @@ def checkToken(get):
|
|||
return False
|
||||
return True
|
||||
|
||||
# 获取Web服务器
|
||||
|
||||
|
||||
def get_webserver():
|
||||
# 获取Web服务器
|
||||
webserver = 'nginx'
|
||||
if not os.path.exists('/www/server/nginx/sbin/nginx'):
|
||||
webserver = 'apache'
|
||||
return webserver
|
||||
|
||||
# 过滤输入
|
||||
|
||||
|
||||
def checkInput(data):
|
||||
# 过滤输入
|
||||
if not data:
|
||||
return data
|
||||
if type(data) != str:
|
||||
|
|
@ -687,10 +713,9 @@ def checkInput(data):
|
|||
data = data.replace(v['d'], v['r'])
|
||||
return data
|
||||
|
||||
# 取文件指定尾行数
|
||||
|
||||
|
||||
def GetNumLines(path, num, p=1):
|
||||
# 取文件指定尾行数
|
||||
try:
|
||||
import cgi
|
||||
if not os.path.exists(path):
|
||||
|
|
@ -736,10 +761,9 @@ def GetNumLines(path, num, p=1):
|
|||
data = []
|
||||
return "\n".join(data)
|
||||
|
||||
# 验证证书
|
||||
|
||||
|
||||
def CheckCert(certPath='ssl/certificate.pem'):
|
||||
# 验证证书
|
||||
openssl = '/usr/local/openssl/bin/openssl'
|
||||
if not os.path.exists(openssl):
|
||||
openssl = 'openssl'
|
||||
|
|
@ -774,8 +798,8 @@ def CheckCert(certPath='ssl/certificate.pem'):
|
|||
# return result
|
||||
|
||||
|
||||
# 字节单位转换
|
||||
def to_size(size):
|
||||
# 字节单位转换
|
||||
d = ('b', 'KB', 'MB', 'GB', 'TB')
|
||||
s = d[0]
|
||||
for b in d:
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ export PATH
|
|||
install_tmp='/tmp/bt_install.pl'
|
||||
|
||||
echo "Install_csvn"
|
||||
#wget -O csvn.tar.xz https://github.com/midoks/mdserver-web/releases/download/init/CollabNetSubversionEdge-5.1.4_linux-x86_64.tar.xz
|
||||
|
||||
#sleep 100
|
||||
wget -O csvn.tar.xz https://github.com/midoks/mdserver-web/releases/download/init/CollabNetSubversionEdge-5.1.4_linux-x86_64.tar.xz
|
||||
#useradd csvn
|
||||
|
||||
Install_csvn()
|
||||
|
|
|
|||
|
|
@ -1,16 +1,35 @@
|
|||
# coding:utf-8
|
||||
|
||||
from flask import Flask
|
||||
from flask import Blueprint,render_template
|
||||
from flask import Blueprint, render_template
|
||||
from flask import jsonify
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.append("class/")
|
||||
import public
|
||||
|
||||
|
||||
files = Blueprint('files', __name__, template_folder='templates')
|
||||
|
||||
|
||||
@files.route("/")
|
||||
def index():
|
||||
return render_template('default/files.html')
|
||||
|
||||
|
||||
@files.route("/GetDiskInfo")
|
||||
def GetDiskInfo():
|
||||
return jsonify({'result':'ok'})
|
||||
return jsonify({'result': 'ok'})
|
||||
|
||||
|
||||
@files.route('/GetExecLog', methods=['POST'])
|
||||
def GetExecLog():
|
||||
file = os.getcwd() + "/tmp/panelExec.log"
|
||||
v = public.GetLastLine(file, 100)
|
||||
return v
|
||||
|
||||
|
||||
@files.route('/GetExecLogs', methods=['POST'])
|
||||
def GetExecLogs():
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1385,7 +1385,7 @@ function messagebox() {
|
|||
|
||||
//取执行日志
|
||||
function execLog(){
|
||||
$.post('/files?action=GetExecLog',{},function(logs){
|
||||
$.post('/files/GetExecLog',{},function(logs){
|
||||
var lbody = '<textarea readonly="" style="margin: 0px;width: 500px;height: 520px;background-color: #333;color:#fff; padding:0 5px" id="exec_log">'+logs+'</textarea>';
|
||||
$(".taskcon").html(lbody);
|
||||
var ob = document.getElementById('exec_log');
|
||||
|
|
|
|||
Loading…
Reference in New Issue