从源代码安装或作为 RPM 安装时,httplib2 API 有所不同?

发布于 2025-01-02 06:41:44 字数 981 浏览 0 评论 0 原文

天哪,这令人沮丧吗...

我通过从 httplib2我的 CentOS 开发虚拟机上的 ="nofollow">站点。在花了 1/2 天让它进行双向 ssl 身份验证后,我在目标 RHEL 5.7 计算机上安装了 python26-httplib2.noarch。由于类构造函数不同,代码突然无法运行!

官方文档定义了 Http类如下:

class httplib2.Http([cache=None][, timeout=None][, proxy_info=None][, ca_certs=无][,disable_ssl_certificate_validation=False])

我使用 tar 安装的代码确实做到了这一点,并且它有效:

client = httplib2.Http(ca_certs='/path-to/ca.cert')

但是,在 RPM 安装中无法识别 ca_cert 参数。查看库,我确实看到以下内容:

class Http(object):

    def __init__(self, cache=None, timeout=None, proxy_info=None):

即完全不同的参数列表。

对此有什么解释吗?

附言。抱歉,如果我听起来很愤怒——我确实很愤怒。现在是晚上 8 点,我希望今天签入代码...
聚苯硫醚。 Python 2.6

Boy, is this frustrating...

I installed the httplib2 by downloading the .tar.gz package from the site on my CentOS development VM. After spending 1/2 day to get it do two-way ssl authentication, I install the python26-httplib2.noarch on the target RHEL 5.7 machine. Suddenly the code does not run as the class constructor is different!

The official documentation defines the Http class as follows:

class httplib2.Http([cache=None][, timeout=None][, proxy_info=None][,
ca_certs=None][, disable_ssl_certificate_validation=False])

My code that uses the tar installation indeed does this, and it works:

client = httplib2.Http(ca_certs='/path-to/ca.cert')

However, the ca_cert parameter is not recognized in the RPM installation. Looking in the lib, I indeed see the following:

class Http(object):

    def __init__(self, cache=None, timeout=None, proxy_info=None):

i.e. totally different parameter list.

Is there any explanation for this?

PS. Sorry if I sound furious - I am. It's 8pm and I hoped to check in the code today...
PPS. Python 2.6

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晚风撩人 2025-01-09 06:41:44

我猜想:不同的 httplib2 版本。据我了解,通过快速浏览更改日志和代码,ca_certs 支持 SSL 服务器证书验证,该验证已在 httplib2 0.7.0 中添加。来自 RPM 的 httplib2 版本是否可能比该版本更旧? print httplib2.__version__ 显示什么?

作为解决方法,我建议不要从 tar.gz 文件或 Red Hat 软件包安装 Python 库;使用 pip 代替,可能带有一个要求文件,您可以在其中指定确切的版本号(甚至是程序运行所需的每个外部库的下限之一)。

I would guess: different httplib2 versions. As far as I understand from a quick glance at the change log and code, ca_certs supports SSL server certificate validation, which has been added in httplib2 0.7.0. Is it possible that the httplib2 version coming from RPM is older than that? What does print httplib2.__version__ show?

As a workaround, I would suggest not to install Python libraries from tar.gz files or from Red Hat packages; use pip instead, possibly with a requirement file where you can specify the exact version number (or even a lower-bound one) of each external library you need for your program to run.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文