小编The*_*erk的帖子

如何获取 boto3 ecsexecute_command 的输出?

我有一个在 Fargate 上运行的 ECS 任务,我想在 boto3 中运行命令并获取输出。我可以在 awscli 中很好地做到这一点。

\n
\xe2\x9e\x9c aws ecs execute-command --cluster cluster1 \\                                                                                   \n    --task abc \\\n    --container container1 \\\n    --interactive \\\n    --command \'echo hi\'    \n\nThe Session Manager plugin was installed successfully. Use the AWS CLI to start a session.\n\nStarting session with SessionId: ecs-execute-command-0f913e47ae7801aeb\nhi\n\nExiting session with sessionId: ecs-execute-command-0f913e47ae7801aeb.\n
Run Code Online (Sandbox Code Playgroud)\n

但我无法弄清楚如何在 boto3 中获得相同的输出。

\n
\xe2\x9e\x9c aws ecs execute-command --cluster cluster1 \\                                                                                   \n    --task abc \\\n    --container container1 \\\n    --interactive \\\n    --command \'echo hi\'    \n\nThe Session Manager plugin …
Run Code Online (Sandbox Code Playgroud)

amazon-web-services amazon-ecs boto3 aws-ssm

10
推荐指数
1
解决办法
2673
查看次数

导出没有密码短语的gpg密钥

在gpg 1.4.16我可以gpg --export-secret-keys <key>没有密码,这不是问题.但是,我无法在v2.1.9中找到这样做.它确认我是否没有通过,我确认,它跳过了关键.必须有一些配置选项才能让它按照我的意愿行事.它是什么?

gnupg

8
推荐指数
1
解决办法
1066
查看次数

如何重定向不存在的子域?

我试图以下列方式使用.htaccess重定向.我不是那么熟悉.htaccess,所以我不确定它是否可以完成.另外,我不知道我打算如何遵循SEO的最佳实践.

www.domain.com                > domain.com 301

ks.domain.com                 > kansas.domain.com 301

ia.domain.com                 > iowa.domain.com 301

domain.com/sites              > domain.com 301

domain.com/sites/iowa         > iowa.domain.com 301

nonexistent.domain.com        > domain.com 302

domain.com/sites/nonexistent  > domain.com 302
Run Code Online (Sandbox Code Playgroud)

我最大的问题是如果我能检测到不存在的子域并重定向.我很想知道上述所有内容是如何完成的.

subdomain .htaccess mod-rewrite rewrite url-rewriting

5
推荐指数
1
解决办法
2830
查看次数

ShiningPanda Virtualenv Builder Shell脚本返回错误的错误代码

我有一个詹金斯的工作,与ShiningPanda的Virtualenv Builder一起运行virtualenv.在这个virtualenv中,它使用以下选项执行此shell脚本-xe:

pip install setuptools
python setup.py sdist upload -r http://jenkins:${PYSHOP_PASS}@localhost:8000/simple/
Run Code Online (Sandbox Code Playgroud)

该url是故意错误的,以便在sdist推送失败时验证构建是否失败.它应该回来1.

这将返回状态代码0.为什么?它只在使用Python 3.4时发生.它在Python 2.7中表现正常.它在Python 3.4和Python 3.5中的本地机器上也能正常运行.是什么赋予了?

我试过用sh和bash运行.我试过几个不同的旗帜.是什么赋予了?

python bash shell setuptools jenkins

5
推荐指数
0
解决办法
438
查看次数

在 Python 中导航嵌套 JSON 的最佳方式?

我尝试了不同的 for 循环尝试迭代这个 JSON,但我不知道如何做到这一点。我有一个数字列表,想要将其与每个“数据”对象(例如,Aatrox、Ahri、Akali 等)下的“键”值进行比较,如果数字匹配,则将“名称”值存储在另一个清单。

示例:数字列表 = [266, 166, 123, 283]

266 和 166 将分别匹配 Aatrox 和 Akshan 对象中的“密钥”,因此我想提取该名称并将其存储在列表中。

我知道这个 JSON 主要是通过键值访问而不是索引,所以我不确定如何迭代 for 循环中的所有“数据”对象。

JSON 我引用:

{
  "type": "champion",
  "format": "standAloneComplex",
  "version": "12.2.1",
  "data": {
    "Aatrox": {
      "version": "12.2.1",
      "id": "Aatrox",
      "key": "266",
      "name": "Aatrox",
      "title": "the Darkin Blade",
      "blurb": "Once honored defenders of Shurima against the Void, Aatrox and his brethren would eventually become an even greater threat to Runeterra, and were defeated only by cunning mortal sorcery. But …
Run Code Online (Sandbox Code Playgroud)

python json nested

5
推荐指数
2
解决办法
2万
查看次数

每个AWS Lambda的事件源映射的最大数量是多少?

我无法在AWS文档中的任何地方找到此限制,以获取触发一个Lambda的最大事件源数量。

我有一个Lambda,它将由数量不断增加的S3铲斗触发。显然,这只有在存储桶的最大数量超过触发器的最大数量时才有效。有最大值吗?如果是这样,它是什么,并且可以增加吗?

amazon-web-services aws-lambda

4
推荐指数
2
解决办法
1124
查看次数

在 clap cli 中返回错误并优雅退出

我想实现一个在 git 存储库上运行的简单 clap cli,但这对问题并不重要;我相信这将有助于澄清。我试图确定如果不从存储库的根运行的话,退出时出现错误的最惯用的方法。这里有三个选项;我不确定是否有好的。

执行这些步骤的最佳方法是什么:

  1. 检查我是否从 repo root 运行
  2. 如果是则继续,如果不是则退出
  3. 如果没有给出命令,则生成帮助
  4. 如果给出命令,则运行命令

理想情况下,我能够输出错误和用法。此外,子命令中还会发生其他错误,我不确定在这些情况下优雅退出的最佳方法。

考虑以下 cli 定义:

use clap::ErrorKind::Io;
use clap::{Parser, Subcommand};
use git2::Repository;
use std::process;

#[derive(Debug, Parser)]
#[clap(author, version, about, long_about = None)]
struct Cli {
    #[clap(subcommand)]
    command: Commands,
}

#[derive(Debug, Subcommand)]
enum Commands {
    /// Do a thing.
    Do,
}
Run Code Online (Sandbox Code Playgroud)

我目前看到的三个主要选项是:

选项1

fn main() -> Result<(), String> {
    let repo = match Repository::open(".") {
        Ok(repo) => repo,
        Err(_) => return Err("must be run from root of repository".to_owned()),
    }; …
Run Code Online (Sandbox Code Playgroud)

rust clap

2
推荐指数
1
解决办法
2415
查看次数

如何迭代列表中的每个单词

我是Python新手。我需要从列表中逐个迭代单词。但我只能垂直迭代每个单词中的每个字母。

l = ['abcd efgh ijkl']

for i in l:
    for j in i:
        print(j)
Run Code Online (Sandbox Code Playgroud)

输出:

a
b
c
d
 
e
f
g
h
 
i
j
k
l
Run Code Online (Sandbox Code Playgroud)

预期输出:

abcd
efgh
ijkl
Run Code Online (Sandbox Code Playgroud)

python

0
推荐指数
1
解决办法
62
查看次数