diff --git a/class/core/files_api.py b/class/core/files_api.py index 020f3bc3e..11ae5b62a 100755 --- a/class/core/files_api.py +++ b/class/core/files_api.py @@ -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): diff --git a/class/core/plugins_api.py b/class/core/plugins_api.py index 0484e13f5..5f24b0a2d 100755 --- a/class/core/plugins_api.py +++ b/class/core/plugins_api.py @@ -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() diff --git a/class/core/public.py b/class/core/public.py index 9370c7b4c..230ff71a4 100755 --- a/class/core/public.py +++ b/class/core/public.py @@ -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) diff --git a/class/core/task_api.py b/class/core/task_api.py index e742a8523..0204aa015 100755 --- a/class/core/task_api.py +++ b/class/core/task_api.py @@ -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( diff --git a/cli.sh b/cli.sh index 0632ce220..c51f090bb 100755 --- a/cli.sh +++ b/cli.sh @@ -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 diff --git a/route/static/app/public.js b/route/static/app/public.js index 68ca0ff39..e9b6a4cfe 100755 --- a/route/static/app/public.js +++ b/route/static/app/public.js @@ -1062,15 +1062,15 @@ function getReloads() { c += f[e] + "
" } if(h.task[g].name.indexOf("扫描") != -1) { - b = "
  • " + h.task[g].name + ""+lan.bt.task_scan+" | "+lan.public.close+"
    " + c + "
  • " + b = "
  • " + h.task[g].name + "正在扫描 | 关闭
    " + c + "
  • " } else { - b = "
  • " + h.task[g].name + ""+lan.bt.task_install+" | "+lan.public.close+"
    " + c + "
  • " + b = "
  • " + h.task[g].name + "正在安装 | 关闭
    " + c + "
  • " } } else { - b = "
  • " + h.task[g].name + "" + (ToSize(h.msg.used) + "/" + ToSize(h.msg.total)) + "" + h.msg.pre + "%"+lan.bt.task_downloading+" | "+lan.public.close+"
  • " + b = "
  • " + h.task[g].name + "" + (toSize(h.msg.used) + "/" + toSize(h.msg.total)) + "" + h.msg.pre + "%"+lan.bt.task_downloading+" | "+lan.public.close+"
  • " } } else { - d += "
  • " + h.task[g].name + ""+lan.bt.task_sleep+" | '+lan.public.del+'
  • ' + d += "
  • " + h.task[g].name + "等待 | 删除
  • ' } } $(".cmdlist").html(b + d); diff --git a/task.py b/task.py index 5c3f284fd..cfcd31955 100755 --- a/task.py +++ b/task.py @@ -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'])