我正在尝试从已部署的应用程序中读取CloudStorage中的文件,代码非常简单:
# -*- coding: utf-8 -*-
from google.appengine.ext import deferred
from google.appengine.ext import ndb
import logging
import os
import cloudstorage as gcs
import webapp2
from google.appengine.api import app_identity
class Handler(webapp2.RequestHandler):
def get(self):
bucket_name = os.environ.get('BUCKET_NAME',
app_identity.get_default_gcs_bucket_name())
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Demo GCS Application running from Version: '
+ os.environ['CURRENT_VERSION_ID'] + '\n')
self.response.write('Using bucket name: ' + bucket_name + '\n\n')
gcs_file = gcs.open("/" + bucket_name + "/mylist.csv", mode="r")
line = gcs_file.readline()
self.response.write(line)
app = webapp2.WSGIApplication([('/view', Handler)])
但是当我访问该页面时,我收到“500内部服务器错误”,并且在日志中我可以看到以下内容:
10:24:32.791
suspended generator _make_token_async(rest_api.py:55) raised InternalError(5: )
10:24:32.792
suspended generator get_token_async(rest_api.py:224) raised InternalError(5: )
10:24:32.792
suspended generator urlfetch_async(rest_api.py:259) raised InternalError(5: )
10:24:32.792
Tasklet is <bound method _StorageApi.urlfetch_async of <cloudstorage.storage_api._StorageApi object at 0x10c98f90>>
10:24:32.792
Got exception "InternalError('5: ',)" from tasklet.
10:24:32.792
Retry in 0.1 seconds.
10:24:32.922
suspended generator _make_token_async(rest_api.py:55) raised InternalError(5: )
10:24:32.922
suspended generator get_token_async(rest_api.py:224) raised InternalError(5: )
10:24:32.923
suspended generator urlfetch_async(rest_api.py:259) raised InternalError(5: )
10:24:32.923
Got exception "InternalError('5: ',)" from tasklet.
如果删除文件打开的行,页面加载正常。
更新:我认为这个问题与我的应用中不存在用户{project-id} @appspot.gserviceaccount.com的事实有关,我无法将其添加回我的项目,因为管理页面只允许我添加格式为{username}@{project-id}.iam.gserviceaccount.com的用户。
那么有谁知道如何将这个用户添加回项目?
提前致谢
答案 0 :(得分:0)
所以问题来自于以下事实:帐户{username }@{project-id}.iam.gserviceaccount.com已从项目中移除而我正在处理并且以下线程说没有办法恢复删除后的默认服务帐户。
https://code.google.com/p/googleappengine/issues/detail?id=13085#makechanges