从prongine获得appengine的版本列表 [英] Progammatically get the list of versions from appengine

查看:109
本文介绍了从prongine获得appengine的版本列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望从远程API或通过appcfg.py获取appengine的部署版本列表。我似乎无法找到任何方式来做到这一点,当然不是一种文件化的方式。有谁知道有什么办法做到这一点(甚至无证)?

I'd like to get a list of deployed versions from appengine, either from the remote API or via appcfg.py. I can't seem to find any way to do it, certainly not a documented way. Does anyone know of any way to do this (even undocumented)?

推荐答案

我能够通过复制一些从appcfg.py到我的应用程序的RPC代码。我发布了这个要点,详细介绍了如何做到这一点,但我会在这里重复它们为后人。

I was able to do this by copying some of the RPC code from appcfg.py into my application. I posted up this gist that goes into detail on how to do this, but I will repeat them here for posterity.


  1. 安装python API客户端。这将为您提供您需要与应用程序内的Google RPC服务器交互的OAuth2和httplib2库。
  2. 从开发机器上安装的GAE SDK复制此文件: google / appengine / tools / appengine_rpc_httplib2.py 到您的GAE webapp。

  3. 执行 appcfg.py list_versions获取刷新标记。 --oauth2 从您的本地机器。这将打开浏览器,以便您可以登录到您的Google帐户。然后,您可以在〜/ .appcfg_oauth2_tokens中找到 refresh_token
  4. 在Web处理程序中修改并运行以下代码:
  5. li>
  1. Install the python API client. This will give you the OAuth2 and httplib2 libraries you need to interact with Google's RPC servers from within your application.
  2. Copy this file from the GAE SDK installed on your development machine: google/appengine/tools/appengine_rpc_httplib2.py into your GAE webapp.
  3. Obtain a refresh token by executing appcfg.py list_versions . --oauth2 from your local machine. This will open a browser so you can login to your Google Account. Then, you can find the refresh_token in ~/.appcfg_oauth2_tokens
  4. Modify and run the following code inside of a web handler:

Enjoy。

from third_party.google_api_python_client import appengine_rpc_httplib2

# Not-so-secret IDs cribbed from appcfg.py
# https://code.google.com/p/googleappengine/source/browse/trunk/python/google/appengine/tools/appcfg.py#144
APPCFG_CLIENT_ID = '550516889912.apps.googleusercontent.com'
APPCFG_CLIENT_NOTSOSECRET = 'ykPq-0UYfKNprLRjVx1hBBar'
APPCFG_SCOPES = ['https://www.googleapis.com/auth/appengine.admin']

source = (APPCFG_CLIENT_ID,
            APPCFG_CLIENT_NOTSOSECRET,
            APPCFG_SCOPES,
            None)

rpc_server = appengine_rpc_httplib2.HttpRpcServerOauth2(
    'appengine.google.com',
    # NOTE: Here's there the refresh token is used
    "your OAuth2 refresh token goes here",
    "appcfg_py/1.8.3 Darwin/12.5.0 Python/2.7.2.final.0",
    source,
    host_override=None,
    save_cookies=False,
    auth_tries=1,
    account_type='HOSTED_OR_GOOGLE',
    secure=True,
    ignore_certs=False)

# NOTE: You must insert the correct app_id here, too
response = rpc_server.Send('/api/versions/list', app_id="khan-academy")

# The response is in YAML format
parsed_response = yaml.safe_load(response)
if not parsed_response:
    return None
else:
    return parsed_response

这篇关于从prongine获得appengine的版本列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆