From b23938986e7ea638f4d41200e8da69ebdb25589f Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Wed, 26 Dec 2018 15:10:29 +0800 Subject: [PATCH] update --- plugins/gae/index.py | 60 +++++++++++++++++++++++++++++++++++++++++-- plugins/gae/js/gae.js | 23 ++++++++++++++--- 2 files changed, 78 insertions(+), 5 deletions(-) diff --git a/plugins/gae/index.py b/plugins/gae/index.py index 95240474d..d992aa390 100755 --- a/plugins/gae/index.py +++ b/plugins/gae/index.py @@ -73,15 +73,65 @@ def getAllProjectList(search): def checkProjectListIsSet(data): dlen = len(data) for x in range(dlen): - path = getServerDir() + data[x]['name'] + '.json' + path = getServerDir() + '/' + data[x]['name'] + '.json' if os.path.exists(path): - data[x]['isset'] = True + if os.path.getsize(path) == 0: + data[x]['isset'] = False + else: + data[x]['isset'] = True else: data[x]['isset'] = False return data +def projectListEdit(): + args = getArgs() + if not 'name' in args: + return 'missing name!' + + file = getServerDir() + '/' + args['name'] + '.json' + if not os.path.exists(file): + public.execShell('touch ' + file) + return file + + +def projectListDel(): + args = getArgs() + if not 'name' in args: + return 'missing name!' + + file = getServerDir() + '/' + args['name'] + '.json' + if os.path.exists(file): + public.execShell('rm -rf ' + file) + return 'ok' + + +def projectListAsync(): + import subprocess + args = getArgs() + if not 'name' in args: + return 'missing name!' + + file = getServerDir() + '/' + args['name'] + '.json' + if not os.path.exists(file): + return 'file not exists!' + + content = public.readFile(file) + contentObj = json.loads(content) + asyncUser = contentObj['client_email'] + cmd = getServerDir() + '/google-cloud-sdk/bin/' + projectDir = public.getWwwDir() + '/' + args['name'] + + public.execShell(cmd + 'gcloud config set account ' + asyncUser) + asyncCmd = 'cd ' + projectDir + ' && ' + cmd + 'gcloud app deploy << y &' + public.execShell(asyncCmd) + + # subprocess.Popen(asyncCmd, + # stdout=subprocess.PIPE, shell=True) + return 'ok' + + def projectList(): args = getArgs() @@ -116,5 +166,11 @@ if __name__ == "__main__": print status() elif func == 'project_list': print projectList() + elif func == 'project_list_edit': + print projectListEdit() + elif func == 'project_list_del': + print projectListDel() + elif func == 'project_list_async': + print projectListAsync() else: print 'error' diff --git a/plugins/gae/js/gae.js b/plugins/gae/js/gae.js index 230e5601f..bf1a3d1e3 100755 --- a/plugins/gae/js/gae.js +++ b/plugins/gae/js/gae.js @@ -81,9 +81,7 @@ function projectListFind(){ } function gaeSetProject(pname,isset){ - var html = ''; - if (isset){ html += ''; } @@ -98,7 +96,26 @@ function gaeSetProject(pname,isset){ } function gaeProjectEdit(pname){ - + gaePost('project_list_edit', {'name':pname}, function(data){ + onlineEditFile(0,data.data); + }); +} + + +function gaeProjectDel(pname){ + gaePost('project_list_del', {'name':pname}, function(data){ + layer.msg('删除成功!',{icon:0,time:2000,shade: [0.3, '#000']}); + projectList(); + }); +} + + +function gaeAsyncProject(pname){ + console.log(pname); + gaePost('project_list_async', {'name':pname}, function(data){ + console.log(data); + // layer.msg('同步成功!',{icon:0,time:2000,shade: [0.3, '#000']}); + }); }