我知道我可以在这样的项目之间复制文件...
gcloud auth activate-service-account --key-file project1.json
gsutil cp gs://bucket1/file .
gcloud auth activate-service-account --key-file project2.json
gsutil cp file gs://bucket2/file
但是当我要编写脚本以复制大量文件时,这不是很好。 activate-service-account
命令将适用于当前的Linux用户,因此它不是线程安全的。可以使用gsutil
中的参数在单个命令中运行以上命令吗?
答案 0 :(得分:1)
我不知道def duck_duck_goose(lst: List[str]) -> List[str]:
"""Given an list of names (strings), play 'duck duck goose' with it,
knocking out every third name (wrapping around) until only two names are
left. In other words, when you hit the end of the list, wrap around and keep
counting from where you were.
For example, if given this list ['Nathan', 'Sasha', 'Sara', 'Jennie'], you'd
first knock out Sara. Then first 'duck' on Jennie, wrap around to 'duck' on
Nathan and 'goose' on Sasha - knocking him out and leaving only Nathan and
Jennie.
You may assume the list has 3+ names to start
Args:
lst - a list of names (strings)
Returns:
the resulting list after playing duck duck goose
"""
raise NotImplementedError("duck_duck_goose")
names = ["sasha", "nathan", "jennie", "shane", "will", "sara"]
assert duck_duck_goose(names) == ["sasha", "will"]
有任何公共支持的方法。 gsutil
支持允许您通过gcloud
在命令行上使用不同凭据的配置,但是--configuration=CONFIGURATION_NAME
不支持。
gsutil
仅使用gsutil
default
配置。执行gcloud
时,您正在更改默认配置以使用新的凭据。
有未记录的环境变量activate-service-account
,但我不知道CLOUDSDK_ACTIVE_CONFIG_NAME=CONFIGURATION_NAME
是否检查了此环境变量。
另一个未记录的项目是,默认配置存储在Windows的gsutil
和Linux的C:\Users\username\AppData\Roaming\gcloud\active_config
中。您可以测试~/.config/gcloud/active_config
是否遵循此约定。该文件仅存储当前默认配置的配置gsutil
。这意味着您将需要设置name
。我写了一篇有关如何设置配置的文章: