From 582bf39731434315d43190e844a24d0d61189d01 Mon Sep 17 00:00:00 2001
From: Mr Chen
* 注意:本插件通过Google JSON 格式赋权免交互式
'; - html += '* 注意:添加:gcloud auth activate-service-account --key-file [KEY_FILE] << y
'; + html += '* 注意:添加:gcloud auth activate-service-account --key-file [KEY_FILE]
'; html += '* 注意:设置后,一般同步项目命令:gcloud app deploy << y
'; html += '* 注意:可以查看命令,把命令加入到脚本中...自动更新。
'; $('.bt-w-main .soft-man-con').html(html); diff --git a/plugins/gae/index.py b/plugins/gae/index.py index 3fd9be603..e0b4c2017 100755 --- a/plugins/gae/index.py +++ b/plugins/gae/index.py @@ -107,6 +107,13 @@ def projectListDel(): return 'ok' +def checkUserExist(cmd, user): + data = public.execShell(cmd + 'gcloud auth list | grep ' + user) + if data[0] == '': + return False + return True + + def projectListAsync(): import subprocess args = getArgs() @@ -123,12 +130,19 @@ def projectListAsync(): 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) + if not checkUserExist(cmd, asyncUser): + public.execShell( + cmd + 'gcloud auth activate-service-account --key-file ' + file) + + pName = contentObj['project_id'] + setUserCmd = cmd + 'gcloud config set account ' + asyncUser + setUserCmd += ' && ' + cmd + 'gcloud config set project ' + pName + asyncCmd = setUserCmd + ' && cd ' + projectDir + \ + ' && ' + cmd + 'gcloud app deploy << y' - # subprocess.Popen(asyncCmd, - # stdout=subprocess.PIPE, shell=True) + taskAdd = (None, 'gae[async]', + 'execshell', '0', time.strftime('%Y-%m-%d %H:%M:%S'), asyncCmd) + public.M('tasks').add('id,name,type,status,addtime, execstr', taskAdd) return 'ok' diff --git a/plugins/gae/js/gae.js b/plugins/gae/js/gae.js index 859a945e6..480c86faf 100755 --- a/plugins/gae/js/gae.js +++ b/plugins/gae/js/gae.js @@ -43,7 +43,7 @@ function projectList(page, search){ content += '