- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试在 Google 应用引擎上使用客户端和 gcloud 存储桶。首先,我安装 gcloud。
pip install gcloud -t my_project_directory
第二,我开始导入gcloud并使用它。这是我的代码:
from gcloud import storage
class printstr(webapp2.RequestHandler):
def get(self):
self.response.out.write("YA")
config = {}
config['webapp2_extras.sessions'] = {
'secret_key': 'my-super-secret-key',
}
app = webapp2.WSGIApplication([('/back/printstr', printstr),
], debug=True, config=config)
当我打开地址(localhost:8080/back/printstr)时,我应该在页面上看到“YA”。但我收到 HTTP ERROR 500。并且我看到了日志:
from google.protobuf import timestamp_pb2
ImportError: No module named protobuf
我确定在google(文件夹)有一个protobuf(文件夹),并且在protobuf(文件夹)有一个timestamp_pb2.py。但是,我不知道为什么会出现此错误?有关如何使用 gcloud 的任何帮助吗?
谢谢!
最佳答案
有一个更好的方法可以做到这一点。您可以使用cloudstorage python 客户端api 将应用程序引擎与云存储桶连接。
使用点:pip install GoogleAppEngineCloudStorageClient -t your_app_directory/lib
使用 git:git 克隆 https://github.com/GoogleCloudPlatform/appengine-gcs-client.git
一旦这个库在你的 python 路径中运行:
import cloudstorage as gcs
path = "/<bucket_name>/<file_path>"
gcs_file = gcs.open(path)
data = gcs_file.read()
gcs_file.close()
确保您的应用引擎有权访问您的云存储桶。
关于python - 如何在 Google 应用引擎上使用 gcloud?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37522493/
我指的是这个 URL https://cloud.google.com/speech/docs/getting-started开始使用谷歌语音 API。正如网站所建议的那样,我遵循了以下步骤 创建或选
只需输入 gcloud寻求帮助需要 5 秒。 $ gcloud ... gcloud 0.30s user 0.13s system 7% cpu 5.508 total $ gcloud vers
要查看所有 gcloud 项目,请使用命令 gcloud projects list .要切换到特定项目,请使用 gcloud config set project PROJECT_ID . 但是当您
如何更新 gcloud components在shell脚本中以编程方式? 调用 gcloud components update需要用户输入,例如: $ gcloud components upda
如果我转到谷歌云控制台中的“IAM & admin”并选择左侧的“IAM”选项卡,我会看到一个用户列表(用户名@mydomain)。 如何使用 gcloud 列出这些用户?我如何查看用户通过 gclo
我想编写一个 shell 脚本,它基本上完成了 gcloud 的所有安装步骤,如以下概述:https://cloud.google.com/sdk/?hl=en 但是,当您运行 install.sh
我正在使用 gcloud beta logging read 来读取一些日志,并使用 --format 选项来格式化为 csv: --format="csv(timestamp,jsonPayload
我们的项目正在使用 dataproc,我已经检查了主和工作计算引擎中指示的服务帐户,它对我的存储桶存储具有所需的权限。尽管如此,在日志查看器中,我看到了以下内容: (gsutil) Failed
Google API 客户端通常会识别 GOOGLE_APPLICATION_CREDENTIALS环境变量。如果找到,它应该指向带有服务帐户或用户凭据的 JSON 文件。 可以从 GCP Web 控
当我运行一个简单的命令时,大约需要 10 秒才能完成, λ time gcloud version Google Cloud SDK 293.0.0 beta 2019.05.17 bq 2.0.57
我正在使用 remote builder 运行云构建,能够将工作区中的所有文件复制到我自己的虚拟机,但无法复制隐藏文件 用于复制文件的命令 gcloud compute scp --compress
我在脚本中使用命令gcloud compute instances list,但担心确切的输出格式不是静态的。我该怎么办? 最佳答案 您应该使用大多数--format命令可用的gcloud标志。 例如
我有谷歌云任务 API 的问题。我需要创建具有很远计划时间的任务。最长计划时间为 30 天。是否有可能增加该限制或绕过某些问题? 最佳答案 如果我们查看云任务的配额,我们会看到任务的默认最长调度时间为
如果我发出 gcloud dataproc Clusters list 则会列出 0 个集群: $ gcloud dataproc clusters list Listed 0 items. 但是,如
我在脚本中使用 gcloud auth activate-service-account 来激活服务帐户。它输出 Activated service account credentials for:
gcloud 中的功能和选项有时会被弃用/删除。如果 CI 依赖它并且重构不是一个选项,同时我们需要使用后续版本中出现的新功能,我们可以在同一台计算机上安装多个版本的 gcloud 并同时使用吗? 最
我在脚本中使用 gcloud auth activate-service-account 来激活服务帐户。它输出 Activated service account credentials for:
通常我对 gcloud 命令没有任何问题。作为一个只在更新我的网站时使用的人,我的曝光是通过一个命令: gcloud app deploy 当出现标题中显示的错误时,建议我运行“gcloud info
在 linux 中,我使用的是 Google gcloud。我注意到,当我使用以下命令时,并非总是将新文件或修改过的文件上传到 Google Cloud Storage: gcloud 应用部署 我得
我们正在使用 Jenkins 构建数据并将数据推送到 Google Cloud Storage。 我们有一台构建机器;和多个不同的 Google 项目(测试;生产) 如果 'jenkins' 用户在
我是一名优秀的程序员,十分优秀!