小编Joe*_*Joe的帖子

错误:字段“ ctx”的类型不完整EVP_CIPHER_CTX

问题:我需要将Cepstral(tts引擎)安装到运行Debian 8的Freeswitch中。Freeswitch已经启动并正在运行,但是我需要从源代码构建它才能创建mod_cepstral模块。

当我运行make这是我得到的错误:

In file included from ./crypto/include/prng.h:17:0,
                 from ./crypto/include/crypto_kernel.h:50,
                 from ./include/srtp.h:53,
                 from srtp/srtp.c:46:
./crypto/include/aes_icm_ossl.h:66:20: error: field ‘ctx’ has incomplete type
     EVP_CIPHER_CTX ctx;
                    ^~~
In file included from srtp/srtp.c:50:0:
./crypto/include/aes_gcm_ossl.h:58:18: error: field ‘ctx’ has incomplete type
   EVP_CIPHER_CTX ctx;
                  ^~~
Makefile:646: recipe for target 'srtp.lo' failed
make[1]: *** [srtp.lo] Error 1
make[1]: Leaving directory '/usr/src/freeswitch/libs/srtp'
Makefile:3931: recipe for target 'libs/srtp/libsrtp.la' failed
make: *** [libs/srtp/libsrtp.la] Error 2
Run Code Online (Sandbox Code Playgroud)

我一直在互联网上寻找解决方案,但是我不是开发人员,这让我头疼。任何帮助,将不胜感激。

linux debian openssl freeswitch

6
推荐指数
3
解决办法
7520
查看次数

Python3 将“CaseInsensitiveDict”转换为 JSON

我正在处理我认为是一个简单的问题,但它真的很困惑。我正在使用ldap3模块在 Python 中进行 AD 查询。此查询将数据作为 python 词典的生成器返回。当我type()对数据运行命令时,它确认它是一个字典。

我需要将其转换为 JSON,以便将其写入日志文件。首先,我尝试过,json.dump(data, file)但是当我这样做时,我收到此错误: TypeError: Object of type 'CaseInsensitiveDict' is not JSON serializable

如果我首先尝试将字典转换为字符串,则数据用引号写入,内部字段用单引号留下,因此它不是真正的 JSON - 它看起来像这样: "{'key': 'value'}"

这是我所拥有的:

with open(outfile, 'w') as outfile:
    for entry in entry_generator: # Entry is equal to a dictionary of AD attributes
        json.dump(entry, outfile) # I have also tried json.dump(str(entry), outfile) etc
Run Code Online (Sandbox Code Playgroud)

我一直在搜索互联网,我看到很多关于requests模块的这个问题,但似乎没有任何东西可以解决我的情况。

对于 ldap3 模块entry_to_json(),我在其他脚本中使用了一种方法。由于生成器,它似乎在这里不起作用,如果有人知道如何再次使其工作,它可以解决我的问题。想法?

json dictionary python-3.x ldap3

6
推荐指数
1
解决办法
3953
查看次数

Python:将 /etc/services 文件导入到字典中

所以我必须创建一个 python 脚本来导入/etc/services文件并将其写入字典。

目标是端口/协议将成为关键并服务于价值。我希望能够打印输入关键信息的字典并查看服务返回如下:

print(yourdictionaryname["22/tcp"])
ssh
Run Code Online (Sandbox Code Playgroud)

这个脚本是我能得到的最远的。我在网上找到了它,它工作得很好,但它的设计目的只是显示未使用的端口。似乎无法修改它来执行我需要的操作:

# set the file name depending on the operating system
if sys.platform == 'win32':
file = r'C:\WINDOWS\system32\drivers\etc\services'
else:
file = '/etc/services'

# Create an empty dictionary
ports = dict()

# Iterate through the file, one line at a time
for line in open(file):

# Ignore lines starting with '#' and those containing only whitespace
if line[0:1] != '#' and not line.isspace():

   # Extract the second field (seperated by \s+)
   pp = …
Run Code Online (Sandbox Code Playgroud)

python linux format dictionary

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

MySQL 'SHOW TABLES' 返回计数而不是列表(Python)

我正在对用于查询数据库的脚本进行故障排除。为了确保一切正常,我将其分解为一个简单的“SHOW TABLES”查询。问题是它返回的是表的计数,而不是它应该返回的名称列表。

import pymysql

connection = pymysql.connect(host='10.0.0.208', user='admin', passwd='Passwrd')

cursor = connection.cursor()
sqlstring = 'SHOW TABLES;'
cursor.execute('USE CustDB')
x = cursor.execute(sqlstring)

print(x)
Run Code Online (Sandbox Code Playgroud)

这仅返回“17”。我错过了什么??

python mysql python-3.x pymysql

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

Python 从 API 请求流数据

用例:我正在尝试连接到流式 API、摄取这些事件、过滤它们并保存相关事件。

问题:我的代码运行良好,直到大约第 1100 次响应。在这一点之后,代码不会崩溃,但似乎停止从流中提取更多数据。我猜这是某种缓冲区问题,但老实说,流媒体对我来说是新的,我不知道是什么导致了这个问题。

代码

import requests
def stream():
    s = requests.Session()
    r = s.get(url, headers=headers, stream=True)
    for line in r.iter_lines():
        if line:
            print(line)
Run Code Online (Sandbox Code Playgroud)

我也在没有会话对象的情况下尝试过这个,我得到了相同的结果。

是否有我忽略的参数或我不知道的概念?我已经搜索了文档/互联网,但没有任何内容让我感到意外。

任何帮助深表感谢。

编辑 一切在我看来都是正确的 我认为流在初始连接时只会生成大量事件,然后它们会减慢速度。然而,现在的问题是,在连接几分钟后,我收到此错误:

Traceback (most recent call last):
  File "C:\Users\joe\PycharmProjects\proj\venv\lib\site-packages\urllib3\response.py", line 572, in _update_chunk_length
    self.chunk_left = int(line, 16)
ValueError: invalid literal for int() with base 16: b''
Run Code Online (Sandbox Code Playgroud)

python api python-3.x python-requests

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