mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 06:39:25 +08:00
update
This commit is contained in:
@@ -127,11 +127,11 @@ class files_api:
|
||||
filename = request.form.get('filename', '').encode('utf-8')
|
||||
|
||||
isTask = public.getRootDir() + '/tmp/panelTask.pl'
|
||||
execstr = url + '|bt|' + path + '/' + filename
|
||||
execstr = url + '|mw|' + path + '/' + filename
|
||||
public.M('tasks').add('name,type,status,addtime,execstr',
|
||||
('下载文件[' + filename + ']', 'download', '0', time.strftime('%Y-%m-%d %H:%M:%S'), execstr))
|
||||
public.writeFile(isTask, 'True')
|
||||
self.setFileAccept(path + '/' + filename)
|
||||
# self.setFileAccept(path + '/' + filename)
|
||||
return public.returnJson(True, '已将下载任务添加到队列!')
|
||||
|
||||
def getRecycleBinApi(self):
|
||||
|
||||
@@ -204,6 +204,8 @@ class plugins_api:
|
||||
|
||||
# 检查是否正在安装
|
||||
def checkSetupTask(self, sName):
|
||||
sName = ''
|
||||
version = ''
|
||||
if not self.__tasks:
|
||||
self.__tasks = public.M('tasks').where(
|
||||
"status!=?", ('1',)).field('status,name').select()
|
||||
|
||||
@@ -410,11 +410,12 @@ def writeSpeed(title, used, total, speed=0):
|
||||
|
||||
def getSpeed():
|
||||
# 取进度
|
||||
data = readFile('/tmp/panelSpeed.pl')
|
||||
path = public.getRootDir()
|
||||
data = readFile(path + '/tmp/panelSpeed.pl')
|
||||
if not data:
|
||||
data = json.dumps({'title': None, 'progress': 0,
|
||||
'total': 0, 'used': 0, 'speed': 0})
|
||||
writeFile('/tmp/panelSpeed.pl', data)
|
||||
writeFile(path + '/tmp/panelSpeed.pl', data)
|
||||
return json.loads(data)
|
||||
|
||||
|
||||
|
||||
@@ -70,15 +70,15 @@ class task_api:
|
||||
try:
|
||||
tmp = public.readFile(tempFile)
|
||||
if len(tmp) < 10:
|
||||
return public.returnMsg(False, '当前没有任务队列在执行-3!')
|
||||
return public.returnJson(False, '当前没有任务队列在执行-3!')
|
||||
echoMsg['msg'] = json.loads(tmp)
|
||||
echoMsg['isDownload'] = True
|
||||
except:
|
||||
db.Sql().table('tasks').where(
|
||||
public.M('tasks').where(
|
||||
"id=?", (find['id'],)).save('status', ('0',))
|
||||
return public.returnMsg(False, '当前没有任务队列在执行-4!')
|
||||
return public.returnJson(False, '当前没有任务队列在执行-4!')
|
||||
else:
|
||||
echoMsg['msg'] = public.getLastLine(tempFile, 20)
|
||||
echoMsg['msg'] = public.getLastLine(tempFile, 10)
|
||||
echoMsg['isDownload'] = False
|
||||
|
||||
echoMsg['task'] = public.M('tasks').where("status!=?", ('1',)).field(
|
||||
|
||||
@@ -10,9 +10,8 @@ mw_start(){
|
||||
|
||||
|
||||
mw_start_debug(){
|
||||
# gunicorn -c setting.py app:app
|
||||
|
||||
python task.py &
|
||||
# gunicorn -b :7200 app:app
|
||||
gunicorn -b :7200 -k gevent -w 1 app:app
|
||||
# gunicorn -b :7200 -k eventlet -w 1 app:app
|
||||
# gunicorn -c setting.py app:app
|
||||
|
||||
@@ -1062,15 +1062,15 @@ function getReloads() {
|
||||
c += f[e] + "<br>"
|
||||
}
|
||||
if(h.task[g].name.indexOf("扫描") != -1) {
|
||||
b = "<li><span class='titlename'>" + h.task[g].name + "</span><span class='state'>"+lan.bt.task_scan+" <img src='/static/img/ing.gif'> | <a href=\"javascript:RemoveTask(" + h.task[g].id + ")\">"+lan.public.close+"</a></span><span class='opencmd'></span><div class='cmd'>" + c + "</div></li>"
|
||||
b = "<li><span class='titlename'>" + h.task[g].name + "</span><span class='state'>正在扫描<img src='/static/img/ing.gif'> | <a href=\"javascript:RemoveTask(" + h.task[g].id + ")\">关闭</a></span><span class='opencmd'></span><div class='cmd'>" + c + "</div></li>"
|
||||
} else {
|
||||
b = "<li><span class='titlename'>" + h.task[g].name + "</span><span class='state'>"+lan.bt.task_install+" <img src='/static/img/ing.gif'> | <a href=\"javascript:RemoveTask(" + h.task[g].id + ")\">"+lan.public.close+"</a></span><div class='cmd'>" + c + "</div></li>"
|
||||
b = "<li><span class='titlename'>" + h.task[g].name + "</span><span class='state'>正在安装<img src='/static/img/ing.gif'> | <a href=\"javascript:RemoveTask(" + h.task[g].id + ")\">关闭</a></span><div class='cmd'>" + c + "</div></li>"
|
||||
}
|
||||
} else {
|
||||
b = "<li><div class='line-progress' style='width:" + h.msg.pre + "%'></div><span class='titlename'>" + h.task[g].name + "<a style='margin-left:130px;'>" + (ToSize(h.msg.used) + "/" + ToSize(h.msg.total)) + "</a></span><span class='com-progress'>" + h.msg.pre + "%</span><span class='state'>"+lan.bt.task_downloading+" <img src='/static/img/ing.gif'> | <a href=\"javascript:RemoveTask(" + h.task[g].id + ")\">"+lan.public.close+"</a></span></li>"
|
||||
b = "<li><div class='line-progress' style='width:" + h.msg.pre + "%'></div><span class='titlename'>" + h.task[g].name + "<a style='margin-left:130px;'>" + (toSize(h.msg.used) + "/" + toSize(h.msg.total)) + "</a></span><span class='com-progress'>" + h.msg.pre + "%</span><span class='state'>"+lan.bt.task_downloading+" <img src='/static/img/ing.gif'> | <a href=\"javascript:RemoveTask(" + h.task[g].id + ")\">"+lan.public.close+"</a></span></li>"
|
||||
}
|
||||
} else {
|
||||
d += "<li><span class='titlename'>" + h.task[g].name + "</span><span class='state'>"+lan.bt.task_sleep+" | <a style='color:green' href=\"javascript:RemoveTask(" + h.task[g].id + ')">'+lan.public.del+'</a></span></li>'
|
||||
d += "<li><span class='titlename'>" + h.task[g].name + "</span><span class='state'>等待 | <a style='color:green' href=\"javascript:RemoveTask(" + h.task[g].id + ')">删除</a></span></li>'
|
||||
}
|
||||
}
|
||||
$(".cmdlist").html(b + d);
|
||||
|
||||
@@ -78,9 +78,9 @@ def downloadFile(url, filename):
|
||||
socket.setdefaulttimeout(10)
|
||||
urllib.urlretrieve(url, filename=filename, reporthook=downloadHook)
|
||||
os.system('chown www.www ' + filename)
|
||||
WriteLogs('done')
|
||||
writeLogs('done')
|
||||
except:
|
||||
WriteLogs('done')
|
||||
writeLogs('done')
|
||||
|
||||
|
||||
def downloadHook(count, blockSize, totalSize):
|
||||
@@ -91,12 +91,12 @@ def downloadHook(count, blockSize, totalSize):
|
||||
if pre == pre1:
|
||||
return
|
||||
speed = {'total': totalSize, 'used': used, 'pre': pre}
|
||||
print speed
|
||||
WriteLogs(json.dumps(speed))
|
||||
# print 'task downloadHook', speed
|
||||
writeLogs(json.dumps(speed))
|
||||
pre = pre1
|
||||
|
||||
|
||||
def WriteLogs(logMsg):
|
||||
def writeLogs(logMsg):
|
||||
# 写输出日志
|
||||
try:
|
||||
global logPath
|
||||
@@ -122,13 +122,14 @@ def startTask():
|
||||
'id,type,execstr').order("id asc").select()
|
||||
# print sql
|
||||
for value in taskArr:
|
||||
# print value
|
||||
start = int(time.time())
|
||||
if not sql.table('tasks').where("id=?", (value['id'],)).count():
|
||||
continue
|
||||
sql.table('tasks').where("id=?", (value['id'],)).save(
|
||||
'status,start', ('-1', start))
|
||||
if value['type'] == 'download':
|
||||
argv = value['execstr'].split('|dl|')
|
||||
argv = value['execstr'].split('|mw|')
|
||||
downloadFile(argv[0], argv[1])
|
||||
elif value['type'] == 'execshell':
|
||||
execShell(value['execstr'])
|
||||
|
||||
Reference in New Issue
Block a user