以编程方式从appengine获取版本列表 [英] Programmatically get the list of versions from appengine

查看:61
本文介绍了以编程方式从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网络应用中.
  3. 通过在本地计算机上执行appcfg.py list_versions . --oauth2来获取刷新令牌.这将打开浏览器,以便您可以登录自己的Google帐户.然后,您可以在〜/.appcfg_oauth2_tokens
  4. 中找到refresh_token
  5. 在网络处理程序中修改并运行以下代码:
  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:

享受.

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

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

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