找不到用于服务的api代理“app_identity_service”运行GAE脚本时 [英] No api proxy found for service "app_identity_service" when running GAE script

查看:155
本文介绍了找不到用于服务的api代理“app_identity_service”运行GAE脚本时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  import os 
我试图运行自定义stript来将静态文件上传到存储桶。 import sys
sys.path.append(/ tools / google_appengine)
from google.appengine.ext从google.appengine.api导入供应商
导入app_identity
vendor.add ('../libraries')

将cloudstorage导入为gcs
$ b STATIC_DIR ='../dashboard/dist'

def main() :
bucket_path =''.join('/'+ app_identity.get_default_gcs_bucket_name())

到目前为止我一直在尝试的是:
- 初始化存根手动地

  def initialize_service_apis():
from google.appengine.tools从google.appengine.tools.dev_appserver_main导入dev_appserver

导入ParseArguments
args,option_dict = ParseArguments(sys.argv)#否则,不填充option_dict。
dev_appserver.SetupStubs('local',** option_dict)

(取自 https: //blairconrad.wordpress.com/2010/02/20/automated-testing-using-app-engine-service-apis-and-a-memcaching-memoizer/

但是,当导入 dev_appserver lib时,会导致导入错误。



有没有办法解决这个问题?
我需要这个脚本进行自动部署过程。

解决方案

找不到api代理对于服务< blah> 错误消息通常表示在独立脚本内部尝试使用GAE标准env基础设施(在 google.appengine 中的包) ,这是不正确的。请参阅 GAE:AssertionError:找不到服务的api代理




I'm trying to run a custom stript to upload static files to a bucket.

import os
import sys
sys.path.append("/tools/google_appengine")
from google.appengine.ext import vendor
from google.appengine.api import app_identity
vendor.add('../libraries')

import cloudstorage as gcs

STATIC_DIR = '../dashboard/dist'

def main():
    bucket_path = ''.join('/' + app_identity.get_default_gcs_bucket_name())

What I've been trying so far: - initialize stubs manuaIlly

def initialize_service_apis():
    from google.appengine.tools import dev_appserver

    from google.appengine.tools.dev_appserver_main import ParseArguments
    args, option_dict = ParseArguments(sys.argv) # Otherwise the option_dict isn't populated.
    dev_appserver.SetupStubs('local', **option_dict)

(taken from https://blairconrad.wordpress.com/2010/02/20/automated-testing-using-app-engine-service-apis-and-a-memcaching-memoizer/)

But this gives me import error when importing dev_appserver lib.

Is there any way to resolve the issue ? I need this script for an automatic deployment process.

解决方案

The No api proxy found for service <blah> error messages typically indicate attempts to use GAE standard env infrastructure (packages under google.appengine in your case) inside standalone scripts, which is not OK. See GAE: AssertionError: No api proxy found for service "datastore_v3".

You have 2 options:

  • keep the code but make it execute inside a GAE app (as a request handler, for example), not as a standalone script
  • drop GAE libraries and switch to libraries designed to be used from standalone scrips. In your case you're looking for Cloud Storage Client Libraries. You may also need to adjust access control to the respective GAE app bucket.

这篇关于找不到用于服务的api代理“app_identity_service”运行GAE脚本时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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