首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将httpie与httpie-aws-authv4绑定到Python zipapp中?

如何将httpie与httpie-aws-authv4绑定到Python zipapp中?
EN

Stack Overflow用户
提问于 2019-11-12 01:34:54
回答 1查看 104关注 0票数 1

httpie打包到Python "PYZ“(zipapp)中很简单,例如使用

代码语言:javascript
复制
$ pip install --upgrade zapp
$ zapp httpie.pyz httpie.__main__:main httpie
$ python ./httpie.pyz --version
1.0.3

现在,我尝试将httpie-aws-authv4作为一个插件包含到httpie中,用于AWS身份验证。遗憾的是,httpie并没有采用这个插件。

代码语言:javascript
复制
$ zapp httpie-aws4.pyz httpie.__main__:main httpie httpie-aws-authv4
$ python ./httpie-aws4.pyz       
usage: http [--json] [--form] [--pretty {all,colors,format,none}]
...   
            [--auth USER[:PASS]] [--auth-type {basic,digest}]

$ python ./httpie-aws4.pyz -A aws4 http://localhost:9200/
...
http: error: argument --auth-type/-A: invalid choice: u'aws4' (choose from 'basic', 'digest')

它应该显示为[--auth-type {basic,digest,aws4}]

有人知道怎么做吗?

EN

回答 1

Stack Overflow用户

发布于 2019-11-13 19:49:01

根据记录,我通过在内置身份验证机制列表中注册扩展来解决插件加载问题。这使得插件可用并可操作,尽管是通过不同的机制。对于zipapp的使用,这是非常好的:

代码语言:javascript
复制
zapp httpie-aws4.pyz httpie.__main__:main httpie httpie-aws-authv4
mkdir -p httpie/plugins
unzip -q -c httpie-aws4.pyz httpie/plugins/__init__.py | gsed \
      -e '15i from httpie_aws_authv4 import AWSv4AuthPlugin # ADDED' \
      -e '19i AWSv4AuthPlugin, # ADDED' \
> httpie/plugins/__init__.py
zip httpie-aws4.pyz httpie/plugins/__init__.py

然后,根据需要显示aws4身份验证机制:

代码语言:javascript
复制
python ./httpie-aws4.pyz 2>&1 | grep auth-type
            [--auth USER[:PASS]] [--auth-type {aws4,basic,digest}]
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58806102

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档