我使用的各种bash命令 - 花哨的差异,构建脚本等,产生大量的颜色输出.
当我将此输出重定向到一个文件,然后cat或less更高版本的文件时,着色消失-大概B/C重定向剥离出来,告诉终端改变颜色的色码的输出的行为.
有没有办法捕获彩色输出,包括着色?
我有一个烧瓶应用程序,我正在像这样运行:
flask run --host=0.0.0.0
当我查看流程列表时,会看到以下内容:
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 23:48 pts/0 00:00:00 /bin/sh -c flask run --host=0.0.0.0
root 6 1 1 23:48 pts/0 00:00:01 /usr/local/bin/python /usr/local/bin/flask run --host=0.0.0.0
root 8 6 3 23:48 pts/0 00:00:02 /usr/local/bin/python /usr/local/bin/flask run --host=0.0.0.0
Run Code Online (Sandbox Code Playgroud)
三个过程。
如果我使用的--without-threads是相同的三个进程,请执行以下操作:
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 00:28 pts/0 00:00:00 /bin/sh -c flask run --host=0.0.0.0 --without-threads
root 6 1 2 00:28 pts/0 00:00:02 /usr/local/bin/python …Run Code Online (Sandbox Code Playgroud) 亚马逊提供iOS,Android和Javascript Cognito SDK,提供高级身份验证用户操作.
例如,请参见用例4:
https://github.com/aws/amazon-cognito-identity-js
但是,如果您使用的是python/boto3,那么您只需要一对基元:cognito.initiate_auth和cognito.respond_to_auth_challenge.
我试图使用这些原语以及pysrplib与USER_SRP_AUTH流进行身份验证,但我所拥有的是不起作用.
在调用RespondToAuthChallenge操作时出现"出错(NotAuthorizedException)总是失败:用户名或密码不正确." (使用JS SDK查找用户名/密码对.)
我的怀疑是我正在构建错误的挑战响应(步骤3),和/或当它想要base64时传递Congito十六进制字符串,反之亦然.
有没有人得到这个工作?有谁看到我做错了什么?
我试图复制authenticateUser在Javascript SDK中找到的调用的行为:
https://github.com/aws/amazon-cognito-identity-js/blob/master/src/CognitoUser.js#L138
但我做错了什么,无法弄清楚是什么.
#!/usr/bin/env python
import base64
import binascii
import boto3
import datetime as dt
import hashlib
import hmac
# http://pythonhosted.org/srp/
# https://github.com/cocagne/pysrp
import srp
bytes_to_hex = lambda x: "".join("{:02x}".format(ord(c)) for c in x)
cognito = boto3.client('cognito-idp', region_name="us-east-1")
username = "foobar@foobar.com"
password = "123456"
user_pool_id = u"us-east-1_XXXXXXXXX"
client_id = u"XXXXXXXXXXXXXXXXXXXXXXXXXX"
# Step 1:
# Use SRP lib …Run Code Online (Sandbox Code Playgroud) python amazon-web-services srp-protocol amazon-cognito boto3
我刚拿到一台MacBook,克隆了我正在做的项目,然后去设置python环境。创建环境后,我更新了 pip 并尝试使用pip install -r requirements.txt. 给我带来问题的 3 个库是cltk、PyYAML和stanza。
这是执行后给我的pip install -r requirements.txt:
Collecting PyYAML==5.4.1 (from -r requirements.txt (line 56))\n Using cached PyYAML-5.4.1.tar.gz (175 kB)\n Installing build dependencies ... done\n Getting requirements to build wheel ... error\n error: subprocess-exited-with-error\n \n \xc3\x97 Getting requirements to build wheel did not run successfully.\n \xe2\x94\x82 exit code: 1\n \xe2\x95\xb0\xe2\x94\x80> [62 lines of output]\n running egg_info\n writing lib3/PyYAML.egg-info/PKG-INFO\n writing dependency_links to lib3/PyYAML.egg-info/dependency_links.txt\n writing …Run Code Online (Sandbox Code Playgroud) 如果Elasticsearch中的"过滤器"和"过滤后的查询"之间存在差异,我正在尝试解决问题.
下面的两个示例请求在针对我的索引运行时返回相同的结果.
它们在某些微妙的方面实际上是不同的吗?
在不同的情况下,为什么人会优先于另一个?
DSL给一个顶层query,和一个顶层filter:
GET /index/type/_search?_source
{
"query": {
"multi_match": {
"query": "my dog has fleas",
"fields": ["name", "keywords"]
}
},
"filter": {
"term": {"status": 2}
}
}
Run Code Online (Sandbox Code Playgroud)
DSL 只query使用filtered构造提供顶级:
GET /index/type/_search?_source
{
"query": {
"filtered": {
"query": {
"multi_match": {
"query": "my dog has fleas",
"fields": ["name", "keywords"]
}
},
"filter": {
"term": {"status": 2}
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 我这样做是为了获取一些数据:
c = pycurl.Curl()
c.setopt(pycurl.ENCODING, 'gzip')
c.setopt(pycurl.URL, url)
c.setopt(pycurl.TIMEOUT, 10)
c.setopt(pycurl.FOLLOWLOCATION, True)
xml = StringIO()
c.setopt(pycurl.WRITEFUNCTION, xml.write )
c.perform()
c.close()
Run Code Online (Sandbox Code Playgroud)
我的网址通常是这样的:
http://host/path/to/resource-foo.xml
Run Code Online (Sandbox Code Playgroud)
通常我会回到302指向:
http://archive-host/path/to/resource-foo.xml.gz
Run Code Online (Sandbox Code Playgroud)
鉴于我已经设置了FOLLOWLOCATION和ENCODING gzip,一切都很好.
问题是,有时我有一个URL,不会导致重定向到gzip压缩资源.发生这种情况时,c.perform()会抛出此错误:
pycurl.error: (61, 'Error while processing content unencoding: invalid block type')
Run Code Online (Sandbox Code Playgroud)
这告诉我pycurl试图枪杀一个没有经过压缩的资源.
有没有什么方法可以指示pycurl找出响应编码,并在适当时使用gunzip?我玩过使用不同的值ENCODING,但到目前为止还没有bean.
pycurl文档似乎有点缺乏.:/
谢谢!