2011-11-10 34 views
4

我想從遠程API或通過appcfg.py獲取appengine的部署版本列表。我似乎無法找到任何方式來做到這一點,當然不是一種文件化的方式。有誰知道有什麼辦法做到這一點(甚至無證)?從exngine獲得版本列表

+1

出於好奇,爲什麼你要這麼做? –

回答

1

您可以在管理控制檯中的「管理日誌」下列出部署的版本。由於沒有屏幕抓取此頁面,因此無法以編程方式訪問此數據。

您可以將此作爲改進請求提交至issue tracker

1

我能夠通過從appcfg.py複製一些RPC代碼到我的應用程序來做到這一點。我張貼了this gist詳細說明如何做到這一點,但我會在這裏重複他們的後代。

  1. Install the python API client。這將爲您提供您需要在應用程序內與Google RPC服務器交互的OAuth2和httplib2庫。
  2. 將此文件從開發機器上安裝的GAE SDK複製到您的GAE Web應用程序中:google/appengine/tools/appengine_rpc_httplib2.py
  3. 通過從本地機器執行appcfg.py list_versions . --oauth2獲取刷新令牌。這將打開瀏覽器,以便您可以登錄到您的Google帳戶。然後,你可以找到在〜/的refresh_token .appcfg_oauth2_tokens
  4. 修改和運行網絡處理器內部的下面的代碼:

享受。

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 
0

看起來像谷歌已經在google.appengine.api.modules包最近發佈了get_versions()功能。我建議通過我在其他答案中實現的破解來使用它。

更多詳情: https://developers.google.com/appengine/docs/python/modules/functions

+1

對!但是,除非我遺漏了某些東西,否則不可能從GAE基礎設施之外使用它。我正在編寫一個部署腳本來關閉以前版本的手動擴展模塊,並且我無法從本地機器/部署服務器使用這些Python API ... –