From 494afb5300b1df952af62c8bbcf14c758cc04921 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Thu, 7 Mar 2019 18:54:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=B8=E8=BD=BD=E8=BD=AF=E4=BB=B6=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/core/plugins_api.py | 39 +++++++++++++++++++++++++--------- plugins/qbittorrent/install.sh | 2 +- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/class/core/plugins_api.py b/class/core/plugins_api.py index 97bef1e4a..229c9a562 100755 --- a/class/core/plugins_api.py +++ b/class/core/plugins_api.py @@ -115,7 +115,7 @@ class plugins_api: public.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd) return public.returnJson(True, '已将安装任务添加到队列!') - def uninstallApi(self): + def uninstallOldApi(self): rundir = public.getRunDir() name = request.form.get('name', '') version = request.form.get('version', '') @@ -142,6 +142,34 @@ class plugins_api: public.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd) return public.returnJson(True, '已将卸载任务添加到队列!') + # 卸载时间短,不加入任务中... + def uninstallApi(self): + rundir = public.getRunDir() + name = request.form.get('name', '') + version = request.form.get('version', '') + if name.strip() == '': + return public.returnJson(False, "缺少插件名称!", ()) + + if version.strip() == '': + return public.returnJson(False, "缺少版本信息!", ()) + + infoJsonPos = self.__plugin_dir + '/' + name + '/' + 'info.json' + + if not os.path.exists(infoJsonPos): + return public.retJson(False, "配置文件不存在!", ()) + + pluginInfo = json.loads(public.readFile(infoJsonPos)) + + execstr = "cd " + os.getcwd() + "/plugins/" + \ + name + " && /bin/bash " + pluginInfo["shell"] \ + + " uninstall " + version + + data = public.execShell(execstr) + if data[1] == '': + return public.returnJson(True, '已将卸载成功!') + else: + return public.returnJson(False, '卸载出现错误信息!' + data[1]) + def checkApi(self): name = request.form.get('name', '') if name.strip() == '': @@ -786,12 +814,3 @@ class plugins_api: print 'callback', eval_str return (True, newRet) - - # 由于内容太大无法shell输出,暂时移动的插件模块中 - def phpinfoApi(self): - v = request.form.get('v', '') - sys.path.append("plugins/php") - - import index - content = index.getPhpinfo(v) - return content diff --git a/plugins/qbittorrent/install.sh b/plugins/qbittorrent/install.sh index 79ecd261a..20462f45d 100755 --- a/plugins/qbittorrent/install.sh +++ b/plugins/qbittorrent/install.sh @@ -38,7 +38,7 @@ Install_qbittorrent() Uninstall_qbittorrent() { rm -rf $serverPath/qbittorrent - yum -y remove qbittorrent-nox + which yum && yum -y remove qbittorrent-nox echo "Uninstall_qbittorrent" > $install_tmp }