diff --git a/class/core/public.py b/class/core/public.py
index f70dc96e7..ecaf10450 100755
--- a/class/core/public.py
+++ b/class/core/public.py
@@ -12,8 +12,6 @@ import subprocess
import re
import hashlib
-
-sys.path.append(os.getcwd() + "/class/")
import db
from random import Random
@@ -110,8 +108,9 @@ def returnJson(status, msg, args=()):
def returnMsg(status, msg, args=()):
# 取通用字曲返回
logMessage = json.loads(
- readFile('static/language/' + get_language() + '/public.json'))
+ readFile('static/language/' + getLanguage() + '/public.json'))
keys = logMessage.keys()
+
if msg in keys:
msg = logMessage[msg]
for i in range(len(args)):
@@ -124,7 +123,7 @@ def getMsg(key, args=()):
# 取提示消息
try:
logMessage = json.loads(
- readFile('static/language/' + get_language() + '/public.json'))
+ readFile('static/language/' + getLanguage() + '/public.json'))
keys = logMessage.keys()
msg = None
if key in keys:
@@ -139,9 +138,8 @@ def getMsg(key, args=()):
def getLan(key):
# 取提示消息
-
logMessage = json.loads(
- readFile('static/language/' + get_language() + '/template.json'))
+ readFile('static/language/' + getLanguage() + '/template.json'))
keys = logMessage.keys()
msg = None
if key in keys:
@@ -166,7 +164,7 @@ def getDate():
return time.strftime('%Y-%m-%d %X', time.localtime())
-def get_language():
+def getLanguage():
path = 'data/language.pl'
if not os.path.exists(path):
return 'Simplified_Chinese'
@@ -180,7 +178,7 @@ def writeLog(type, logMsg, args=()):
import db
import json
logMessage = json.loads(
- readFile('static/language/' + get_language() + '/log.json'))
+ readFile('static/language/' + getLanguage() + '/log.json'))
keys = logMessage.keys()
if logMsg in keys:
logMsg = logMessage[logMsg]
@@ -460,7 +458,7 @@ def hasPwd(password):
return crypt.crypt(password, password)
-def CheckMyCnf():
+def checkMyCnf():
# 处理MySQL配置文件
import os
confFile = '/etc/my.cnf'
@@ -692,10 +690,9 @@ def auth_encode(data):
# 返回
return pdata
-# 检查Token
-
def checkToken(get):
+ # 检查Token
tempFile = 'data/tempToken.json'
if not os.path.exists(tempFile):
return False
@@ -785,7 +782,7 @@ def GetNumLines(path, num, p=1):
return "\n".join(data)
-def CheckCert(certPath='ssl/certificate.pem'):
+def checkCert(certPath='ssl/certificate.pem'):
# 验证证书
openssl = '/usr/local/openssl/bin/openssl'
if not os.path.exists(openssl):
diff --git a/route/dashboard.py b/route/dashboard.py
index 4907391cf..14ca0c09f 100644
--- a/route/dashboard.py
+++ b/route/dashboard.py
@@ -59,4 +59,8 @@ def login():
@dashboard.route("/do_login", methods=['POST'])
def doLogin():
- return public.returnJson(False, 'LOGIN_USER_EMPTY')
+ print request.args
+
+ # return "123"
+ # return public.returnJson(False, 'LOGIN_USER_EMPTY')
+ return public.returnJson(True, 'LOGIN_SUCCESS')
diff --git a/route/files.py b/route/files.py
index e1f7b1fe8..ca060c2b4 100644
--- a/route/files.py
+++ b/route/files.py
@@ -23,13 +23,6 @@ def GetDiskInfo():
return jsonify({'result': 'ok'})
-@files.route('/get_exec_log', 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
diff --git a/route/task.py b/route/task.py
index 2237499d5..ea8000af2 100644
--- a/route/task.py
+++ b/route/task.py
@@ -1,5 +1,6 @@
# coding:utf-8
+import os
import sys
sys.path.append("/class/core")
import public
@@ -36,3 +37,49 @@ def list():
_ret['page'] = public.getPage(_page)
return public.getJson(_ret)
+
+
+@task.route('/get_exec_log', methods=['POST'])
+def getExecLog():
+ file = os.getcwd() + "/tmp/panelExec.log"
+ v = public.getLastLine(file, 100)
+ return v
+
+
+@task.route("/get_task_speed", methods=['GET', 'POST'])
+def getTaskSpeed():
+ tempFile = os.getcwd() + '/tmp/panelExec.log'
+ freshFile = os.getcwd() + '/tmp/panelFresh'
+
+ find = public.M('tasks').where('status=? OR status=?',
+ ('-1', '0')).field('id,type,name,execstr').find()
+ if not len(find):
+ # pass
+ return public.returnJson(False, '当前没有任务队列在执行-2!')
+
+ # isTask = os.getcwd() + '/tmp/panelTask.pl'
+ # public.writeFile(isTask, 'True')
+ print find
+ echoMsg = {}
+ # echoMsg['name'] = find['name']
+ # echoMsg['execstr'] = find['execstr']
+ # if find['type'] == 'download':
+ # import json
+ # try:
+ # tmp = public.readFile(tempFile)
+ # if len(tmp) < 10:
+ # return public.returnMsg(False, '当前没有任务队列在执行-3!')
+ # echoMsg['msg'] = json.loads(tmp)
+ # echoMsg['isDownload'] = True
+ # except:
+ # db.Sql().table('tasks').where(
+ # "id=?", (find['id'],)).save('status', ('0',))
+ # return public.returnMsg(False, '当前没有任务队列在执行-4!')
+ # else:
+ # echoMsg['msg'] = self.GetLastLine(tempFile, 20)
+ # echoMsg['isDownload'] = False
+
+ # echoMsg['task'] = public.M('tasks').where("status!=?", ('1',)).field(
+ # 'id,status,name,type').order("id asc").select()
+ print echoMsg
+ return public.getJson(echoMsg)
diff --git a/static/js/public.js b/static/js/public.js
index 57306262f..fd168b0b6 100755
--- a/static/js/public.js
+++ b/static/js/public.js
@@ -1386,7 +1386,7 @@ function messagebox() {
//取执行日志
function execLog(){
- $.post('/files/get_exec_log',{},function(logs){
+ $.post('/task/get_exec_log',{},function(logs){
var lbody = '';
$(".taskcon").html(lbody);
var ob = document.getElementById('exec_log');
@@ -1452,7 +1452,7 @@ function GetReloads() {
return
}
a++;
- $.post("/files?action=GetTaskSpeed", "", function(h) {
+ $.post("/task/get_task_speed", "", function(h) {
if(h.task == undefined) {
$(".cmdlist").html(lan.bt.task_not_list);
return
@@ -1488,7 +1488,7 @@ function GetReloads() {
}catch(e){
return;
}
- }).error(function(){});
+ },'json').error(function(){});
}, 1000);
}
diff --git a/templates/default/login.html b/templates/default/login.html
index 81a043d0f..0ac5315f6 100755
--- a/templates/default/login.html
+++ b/templates/default/login.html
@@ -206,7 +206,6 @@
var loadT = layer.msg("正在登录中",{icon:16,time:0,shade: [0.3, '#000']});
$.post('/do_login',data,function(rdata){
console.log(rdata);
- console.log(rdata.status);
layer.close(loadT);
if(!rdata.status){
if(username == 'admin' && rdata.msg.indexOf('用户名') != -1) rdata.msg += ',
获取默认用户和密码命令: bt default';
@@ -227,7 +226,7 @@
layer.msg(rdata.msg,{icon:16,time:0,shade: [0.3, '#000']});
window.location.href = '/';
- });
+ },'json');
});