|
|
@ -53,8 +53,8 @@ class task_api: |
|
|
|
return v |
|
|
|
return v |
|
|
|
|
|
|
|
|
|
|
|
def getTaskSpeedApi(self): |
|
|
|
def getTaskSpeedApi(self): |
|
|
|
tempFile = os.getcwd() + '/tmp/panelExec.log' |
|
|
|
tempFile = mw.getRunDir() + '/tmp/panelExec.log' |
|
|
|
freshFile = os.getcwd() + '/tmp/panelFresh' |
|
|
|
freshFile = mw.getRunDir() + '/tmp/panelFresh' |
|
|
|
|
|
|
|
|
|
|
|
find = mw.M('tasks').where('status=? OR status=?', |
|
|
|
find = mw.M('tasks').where('status=? OR status=?', |
|
|
|
('-1', '0')).field('id,type,name,execstr').find() |
|
|
|
('-1', '0')).field('id,type,name,execstr').find() |
|
|
@ -63,25 +63,28 @@ class task_api: |
|
|
|
|
|
|
|
|
|
|
|
mw.triggerTask() |
|
|
|
mw.triggerTask() |
|
|
|
|
|
|
|
|
|
|
|
echoMsg = {} |
|
|
|
data = {} |
|
|
|
echoMsg['name'] = find['name'] |
|
|
|
data['name'] = find['name'] |
|
|
|
echoMsg['execstr'] = find['execstr'] |
|
|
|
data['execstr'] = find['execstr'] |
|
|
|
if find['type'] == 'download': |
|
|
|
if find['type'] == 'download': |
|
|
|
import json |
|
|
|
readLine = "" |
|
|
|
try: |
|
|
|
for i in range(3): |
|
|
|
tmp = mw.readFile(tempFile) |
|
|
|
try: |
|
|
|
if len(tmp) < 10: |
|
|
|
readLine = mw.readFile(tempFile) |
|
|
|
return mw.returnJson(False, '当前没有任务队列在执行-3!') |
|
|
|
if len(readLine) > 10: |
|
|
|
echoMsg['msg'] = json.loads(tmp) |
|
|
|
data['msg'] = json.loads(readLine) |
|
|
|
echoMsg['isDownload'] = True |
|
|
|
data['isDownload'] = True |
|
|
|
except: |
|
|
|
break |
|
|
|
mw.M('tasks').where( |
|
|
|
except Exception as e: |
|
|
|
"id=?", (find['id'],)).save('status', ('0',)) |
|
|
|
if i == 2: |
|
|
|
return mw.returnJson(False, '当前没有任务队列在执行-4!') |
|
|
|
mw.M('tasks').where("id=?", (find['id'],)).save( |
|
|
|
|
|
|
|
'status', ('0',)) |
|
|
|
|
|
|
|
return mw.returnJson(False, '当前没有任务队列在执行-4:' + str(e)) |
|
|
|
|
|
|
|
time.sleep(0.5) |
|
|
|
else: |
|
|
|
else: |
|
|
|
echoMsg['msg'] = mw.getLastLine(tempFile, 10) |
|
|
|
data['msg'] = mw.getLastLine(tempFile, 10) |
|
|
|
echoMsg['isDownload'] = False |
|
|
|
data['isDownload'] = False |
|
|
|
|
|
|
|
|
|
|
|
echoMsg['task'] = mw.M('tasks').where("status!=?", ('1',)).field( |
|
|
|
data['task'] = mw.M('tasks').where("status!=?", ('1',)).field( |
|
|
|
'id,status,name,type').order("id asc").select() |
|
|
|
'id,status,name,type').order("id asc").select() |
|
|
|
return mw.getJson(echoMsg) |
|
|
|
return mw.getJson(data) |
|
|
|