使用developers.google.com我们创建了api用户并将下载的凭据作为json文件.现在,在我的macbook上gspread身份验证在使用credentials.json时工作正常.当在aws上将相同的配置移动到linux服务器时,它给出403不足的权限错误.
Pip和python版本是一样的.
例外
gspread.v4.exceptions.APIError: {
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}
],
"code": 403,
"message": "Insufficient Permission"
}
}
Run Code Online (Sandbox Code Playgroud)
基本代码
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds']
creds = ServiceAccountCredentials.from_json_keyfile_name('credentials.json', scope)
client = gspread.authorize(creds)
sheet = client.open('MySheetName').sheet1
Run Code Online (Sandbox Code Playgroud) 我正在处理一个对象,其中首先 python 读取 YAML,进行一些更改,然后将它们写回文件。加载和更新值部分工作正常,但是当我编写文件时,它会列出相当独立的文档。
测试.yaml
apiVersion: v1
data:
databag1: try this
databag2: then try this
kind: ConfigMap
metadata:
name: data bag info
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: data-bag-service
name: data-bag-tagging
Run Code Online (Sandbox Code Playgroud)
代码块
import yaml
with open("./testing.yaml", "r") as stream:
deployment_dict= list(yaml.safe_load_all(stream))
print(deployment_dict)
with open("./testing.yaml", "w") as service_config:
yaml.dump(
deployment_dict,
service_config,
default_flow_style=False
)
Run Code Online (Sandbox Code Playgroud)
我得到的转换: testing.yaml
- apiVersion: v1
data:
databag1: try this
databag2: then try this
kind: ConfigMap
metadata:
name: data bag info
- apiVersion: extensions/v1beta1
kind: Deployment
metadata: …
Run Code Online (Sandbox Code Playgroud) 我们在 EKS 中使用服务帐户的 IAM 角色来实现安全的资源访问。最近我们正在尝试采用 MSK 和粘合模式注册表。我们使用的sdk是aws-glue-schema-registry
.
虽然 IRSA 按预期与其他服务一起工作,例如secret manager
当我们尝试连接粘合模式注册表时,我们会收到此错误
software.amazon.awssdk.services.glue.model.AccessDeniedException: User: arn:aws:sts::****************:assumed-role/NODE_ROLE/i-833fu7203a782371 is not authorized to perform: glue:GetSchemaByDefinition on resource: arn:aws:glue:us-east-1:****************:registry/schema-registry because no identity-based policy allows the glue:GetSchemaByDefinition action (Service: Glue, Status Code: 400, Request ID: 74269899-8eaf-48dc-831b-7j271209231j71)
Run Code Online (Sandbox Code Playgroud)
IAM 权限
{
"Statement": [
{
"Action": [
"glue:*",
"kafka:*",
"secretsmanager:ListSecretVersionIds",
"secretsmanager:GetSecretValue",
"secretsmanager:DescribeSecret"
],
"Effect": "Allow",
"Resource": "*",
"Sid": ""
}
],
"Version": "2012-10-17"
}
Run Code Online (Sandbox Code Playgroud)
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId> …
Run Code Online (Sandbox Code Playgroud) 我正在处理创建列表的代码,然后应用"或"和"和"条件来执行进一步操作:
a= ["john", "carlos", "22", "70"]
if (("qjohn" or "carlos") in a) and (("272" or "70") in a):
print "true"
else:
print "not true"
Run Code Online (Sandbox Code Playgroud)
输出:
not true
Run Code Online (Sandbox Code Playgroud)
当我这样做:
a= ["john", "carlos", "22", "70"]
if ("qjohn" or "cdarlos" in a) and ("272" or "d70" in a):
print "true"
else:
print "not true"
Run Code Online (Sandbox Code Playgroud)
输出是 "true"
我没有得到的**carlos and 70**
应该是真实的,但它打印"不真实".这个错误的原因是什么?谢谢
所以我的情况相当复杂,但是在干净清晰的上下文中提问我使用简单的for循环,从0开始,然后上升到10.现在我要做的是当i becomes equal to 2
程序将此视为恐慌时.它将使用延迟恢复状态,然后恢复循环将恢复.
所以期望的输出应该是这样的:
0
1
panic occured: got 2
3
4
.
.
.
.
.
10
Run Code Online (Sandbox Code Playgroud)
我得到的实际输出
0
1
panic occured got: got 2
Run Code Online (Sandbox Code Playgroud)
代码块:
package main
import "fmt"
func main() {
goFrom1To10()
}
func goFrom1To10() {
defer recovery()
for i := 0; i <= 10; i++ {
if i == 2 {
panic("got 2")
}
fmt.Println(i)
}
}
func recovery() {
if r := recover(); r != nil {
fmt.Println("panic occured: ", r) …
Run Code Online (Sandbox Code Playgroud) 我正在尝试查找b / w 2列表的唯一值,但是这种逻辑似乎不起作用
x = [1,2,3,4]
f = [1,11,22,33,44,3,4]
for element in f:
if element in x:
f.remove(element)
print f
Run Code Online (Sandbox Code Playgroud)
期望的输出
[11, 22, 33, 44]
Run Code Online (Sandbox Code Playgroud)
实际产量
[11, 22, 33, 44, 4]
Run Code Online (Sandbox Code Playgroud)
同样在这里问解决方案:
x = [1,2,3,4]
f = [1,11,22,33,44,3,4]
res = list(set(x+f))
print(res)
[1, 2, 3, 4, 33, 11, 44, 22]
Run Code Online (Sandbox Code Playgroud)
如您所见,其添加的1,2,3,4不输出,我需要
我正在提取一个给我这个输出的字典:
mylist= [[u'Ann', u'jOhn', u'Clive'], [u'124street', u'32B', u'16eve', u'beach']]
Run Code Online (Sandbox Code Playgroud)
当我尝试将它分成两部分时,我得到一个ValueError
:
nest1, nest2 = zip(*mylist)
ValueError: too many values to unpack
Run Code Online (Sandbox Code Playgroud)
最终我需要这样的东西:
nest1=['Ann', 'jOhn', 'Clive']
nest2=['124Street', '32B', '16eve', 'beach]
Run Code Online (Sandbox Code Playgroud)
我zip(*mylist)
在这个答案中找到了。
所以从我的本地机器我可以做到这一点:
. env_vars.env
Run Code Online (Sandbox Code Playgroud)
它工作正常:
猫 env_vars.env
#!/bin/bash
export abce=def
Run Code Online (Sandbox Code Playgroud)
但是当我尝试在 makefile 中反映相同时,它不返回任何内容:
SHELL=/bin/bash
print-env-vars:
. env_vars.env
echo ${abce}
Run Code Online (Sandbox Code Playgroud)
我还尝试在 makefile 中使用 source env_vars.env 但输出仍然相同。想知道如何在 makefile 中获取变量。
python ×5
list ×3
amazon-eks ×1
amazon-iam ×1
aws-glue ×1
aws-msk ×1
bash ×1
dictionary ×1
for-loop ×1
go ×1
gspread ×1
jenkins ×1
linux ×1
makefile ×1
nested-if ×1
nested-lists ×1
panic ×1
python-2.7 ×1
python-3.x ×1
pyyaml ×1
spring ×1
unique ×1
yaml ×1