pull/109/head
Mr Chen 6 years ago
parent bd3e47491e
commit 582bf39731
  1. 7
      plugins/gae/app/app.yaml
  2. 3
      plugins/gae/app/helloworld.php
  3. 2
      plugins/gae/index.html
  4. 24
      plugins/gae/index.py
  5. 6
      plugins/gae/js/gae.js

@ -0,0 +1,7 @@
runtime: php55
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: helloworld.php

@ -0,0 +1,3 @@
<?php
echo 'Hello, GAE!';

@ -19,7 +19,7 @@ readme();
function readme(){
var html = '<p>开发文档:https://cloud.google.com/sdk/docs/</p>';
html += '<p>* 注意:本插件通过Google <a class="btlink" target="_blank" href="https://cloud.google.com/sdk/docs/scripting-gcloud">JSON 格式</a>赋权免交互式</p>';
html += '<p>* 注意:添加:gcloud auth activate-service-account --key-file [KEY_FILE] << y</p>';
html += '<p>* 注意:添加:gcloud auth activate-service-account --key-file [KEY_FILE]</p>';
html += '<p>* 注意:设置后,一般同步项目命令:gcloud app deploy << y</p>';
html += '<p>* 注意:可以查看命令,把命令加入到脚本中...自动更新。</p>';
$('.bt-w-main .soft-man-con').html(html);

@ -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'

@ -43,7 +43,7 @@ function projectList(page, search){
content += '<thead><tr>';
content += '<th>项目名</th>';
content += '<th>地址</th>';
content += '<th>操作</th>';
content += '<th>操作(<a class="btlink" target="_blank" href="https://console.cloud.google.com/">官方地址</a>)</th>';
content += '</tr></thead>';
content += '<tbody>';
@ -112,16 +112,14 @@ function gaeProjectDel(pname){
function gaeAsyncProject(pname){
gaePost('project_list_async', {'name':pname}, function(data){
console.log(data);
if (data.data !='ok'){
layer.msg(data.data,{icon:0,time:2000,shade: [0.3, '#000']});
} else {
layer.msg('同步成功!',{icon:0,time:2000,shade: [0.3, '#000']});
layer.msg('加入任务,请自行观察!',{icon:1,time:2000,shade: [0.3, '#000']});
}
});
}
function gaeProjectCmd(pname){
gaePost('project_list_cmd', {'name':pname}, function(data){
var data_str = data.data;

Loading…
Cancel
Save