pull/109/head
Mr Chen 7 years ago
parent d81a069d94
commit d66f208b53
  1. 64
      class/core/plugin_api.py
  2. 6
      plugins/php/versions/72/install.sh
  3. 7
      route/plugins.py
  4. 12
      static/js/soft.js

@ -10,13 +10,14 @@ import json
class plugin_api: class plugin_api:
__tasks = None __tasks = None
__plugin_dir = "plugins" __plugin_dir = 'plugins'
__type = "data/json/type.json" __type = 'data/json/type.json'
__index = 'data/json/index.json' __index = 'data/json/index.json'
setupPath = None setupPath = None
def __init__(self): def __init__(self):
self.setupPath = 'server' self.setupPath = 'server'
# self.__plugin_dir = public.getRunDir() + '/plugins'
# 进程是否存在 # 进程是否存在
def processExists(self, pname, exe=None): def processExists(self, pname, exe=None):
@ -69,13 +70,11 @@ class plugin_api:
# 构造本地插件信息 # 构造本地插件信息
def getPluginInfo(self, info): def getPluginInfo(self, info):
# print info["checks"] checks = ''
if info["checks"][0:1] == '/':
checks = ""
if info["checks"][0:1] == "/":
checks = info["checks"] checks = info["checks"]
else: else:
checks = public.getRootDir() + "/" + info['checks'] checks = public.getRootDir() + '/' + info['checks']
pluginInfo = { pluginInfo = {
"id": 10000, "id": 10000,
@ -95,44 +94,59 @@ class plugin_api:
} }
pluginInfo['task'] = self.checkSetupTask(pluginInfo['name']) pluginInfo['task'] = self.checkSetupTask(pluginInfo['name'])
if checks.find('VERSION') > -1:
pluginInfo['install_checks'] = checks.replace(
'VERSION', info['versions'])
pluginInfo['setup'] = os.path.exists(pluginInfo['install_checks']) pluginInfo['setup'] = os.path.exists(pluginInfo['install_checks'])
pluginInfo['status'] = os.path.exists(pluginInfo['install_checks']) pluginInfo['status'] = os.path.exists(pluginInfo['install_checks'])
return pluginInfo return pluginInfo
def getPluginList(self, sType, sPage=1, sPageSize=15): def getAllList(self, sType='0'):
ret = {} ret = {}
ret['type'] = json.loads(public.readFile(self.__type)) ret['type'] = json.loads(public.readFile(self.__type))
plugins_info = [] plugins_info = []
for dirinfo in os.listdir(self.__plugin_dir): for dirinfo in os.listdir(self.__plugin_dir):
if dirinfo[0:1] == '.':
continue
path = self.__plugin_dir + '/' + dirinfo path = self.__plugin_dir + '/' + dirinfo
if os.path.isdir(path): if os.path.isdir(path):
jsonFile = path + '/info.json' json_file = path + '/info.json'
if os.path.exists(jsonFile): if os.path.exists(json_file):
try: try:
tmp = json.loads(public.readFile(jsonFile)) data = json.loads(public.readFile(json_file))
if tmp['name'] == 'php': if type(data['versions']) == list and data['name'] == 'php':
for index in range(len(tmp['versions'])): for index in range(len(data['versions'])):
tmp = data.copy()
tmp['versions'] = data['versions'][index]
pg = self.getPluginInfo(tmp) pg = self.getPluginInfo(tmp)
pg['versions'] = tmp['versions'][index] if sType == '0':
# print "sss:", i, v
# pg['updates'] = tmp["updates"][v]
if sType == "0":
plugins_info.append(pg) plugins_info.append(pg)
else: else:
if pg['pid'] == sType: if pg['pid'] == sType:
plugins_info.append(pg) plugins_info.append(pg)
else: else:
pg = self.getPluginInfo(tmp) pg = self.getPluginInfo(data)
if sType == "0": if sType == '0':
plugins_info.append(pg) plugins_info.append(pg)
else: else:
if pg['pid'] == sType: if pg['pid'] == sType:
plugins_info.append(pg) plugins_info.append(pg)
except Exception, e: except Exception, e:
print e print e
# pass
return plugins_info
def getPluginList(self, sType, sPage=1, sPageSize=15):
ret = {}
ret['type'] = json.loads(public.readFile(self.__type))
plugins_info = self.getAllList(sType)
args = {} args = {}
args['count'] = len(plugins_info) args['count'] = len(plugins_info)
args['p1'] = sPage args['p1'] = sPage
@ -140,3 +154,9 @@ class plugin_api:
ret['data'] = plugins_info ret['data'] = plugins_info
ret['list'] = public.getPage(args) ret['list'] = public.getPage(args)
return ret return ret
def addIndex(self, name, version):
pass
def run(self):
pass

@ -33,9 +33,9 @@ fi
cd $sourcePath/php/php-7.2.5 && ./configure \ cd $sourcePath/php/php-7.2.5 && ./configure \
--prefix=$serverPath/php/php72 \ --prefix=$serverPath/php/72 \
--exec-prefix=$serverPath/php/php72 \ --exec-prefix=$serverPath/php/72 \
--with-config-file-path=$serverPath/php/php72/etc \ --with-config-file-path=$serverPath/php/72/etc \
--with-zlib-dir=$serverPath/lib/zlib \ --with-zlib-dir=$serverPath/lib/zlib \
--without-iconv \ --without-iconv \
--enable-zip \ --enable-zip \

@ -141,6 +141,13 @@ def checkInstalled():
return "False" return "False"
@plugins.route('/add_index', methods=['GET'])
def addIndex():
name = request.args.get('name', '')
html = __plugin_name + '/' + name + '/index.html'
return public.readFile(html)
@plugins.route('/setting', methods=['GET']) @plugins.route('/setting', methods=['GET'])
def setting(): def setting():
name = request.args.get('name', '') name = request.args.get('name', '')

@ -156,8 +156,6 @@ function GetSList(isdisplay) {
handle = mupdate + '<a class="btlink" onclick="PluginMan(\'' + plugin.name + '\',\'' + plugin.title + '\')">' + lan.soft.setup + '</a> | <a class="btlink" onclick="UninstallVersion(\'' + plugin.name + '\',\'' + plugin.versions + '\',\'' + plugin.title + '\')">卸载</a>'; handle = mupdate + '<a class="btlink" onclick="PluginMan(\'' + plugin.name + '\',\'' + plugin.title + '\')">' + lan.soft.setup + '</a> | <a class="btlink" onclick="UninstallVersion(\'' + plugin.name + '\',\'' + plugin.versions + '\',\'' + plugin.title + '\')">卸载</a>';
titleClick = 'onclick="PluginMan(\'' + plugin.name + '\',\'' + plugin.title + '\')" style="cursor:pointer"'; titleClick = 'onclick="PluginMan(\'' + plugin.name + '\',\'' + plugin.title + '\')" style="cursor:pointer"';
} else { } else {
console.log(plugin, n);
var mupdate = '';//(plugin.versions[n] == plugin.updates[n]) '' : '<a class="btlink" onclick="SoftUpdate(\'' + plugin.name + '\',\'' + plugin.versions[n].version + '\',\'' + plugin.updates[n] + '\')">更新</a> | '; var mupdate = '';//(plugin.versions[n] == plugin.updates[n]) '' : '<a class="btlink" onclick="SoftUpdate(\'' + plugin.name + '\',\'' + plugin.versions[n].version + '\',\'' + plugin.updates[n] + '\')">更新</a> | ';
if (plugin.versions[n] == '') mupdate = ''; if (plugin.versions[n] == '') mupdate = '';
@ -175,20 +173,18 @@ function GetSList(isdisplay) {
} }
} }
var isTask = plugin.task; var isTask = plugin.task;
if (isTask == '-1') { if (plugin.task == '-1') {
handle = '<a style="color:green;" href="javascript:task();">正在安装...</a>'; handle = '<a style="color:green;" href="javascript:task();">正在安装...</a>';
} else if (isTask == '0') { } else if (isTask == '0') {
handle = '<a style="color:#C0C0C0;" href="javascript:task();">等待安装...</a>'; handle = '<a style="color:#C0C0C0;" href="javascript:task();">等待安装...</a>';
} }
} }
// console.log(plugin);
sBody += '<tr>' + sBody += '<tr>' +
'<td><span ' + titleClick + '<td><span ' + titleClick +
'><img src="/plugins/file?name=' + rdata.data[i].name + '><img src="/plugins/file?name=' + plugin.name +
'&f=ico.png' + '">' + rdata.data[i].title + ' ' + version_info + '</span></td>' + '&f=ico.png' + '">' + plugin.title + ' ' + version_info + '</span></td>' +
'<td>' + rdata.data[i].ps + '</td>' + '<td>' + plugin.ps + '</td>' +
'<td>' + softPath + '</td>' + '<td>' + softPath + '</td>' +
'<td>' + state + '</td>' + '<td>' + state + '</td>' +
'<td>' + indexshow + '</td>' + '<td>' + indexshow + '</td>' +

Loading…
Cancel
Save