From 45e6468b017c9842dc98a788dd7ded5758817418 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 28 Feb 2014 13:58:06 +0530 Subject: [PATCH] Make the linux installer script compatible with python 2.6. Fixes #1286011 [Linux installer for calibre 1.26 does not work on CentOS 6.5](https://bugs.launchpad.net/calibre/+bug/1286011) --- setup/linux-installer.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/setup/linux-installer.py b/setup/linux-installer.py index 755e56f05f..b17de36bc5 100644 --- a/setup/linux-installer.py +++ b/setup/linux-installer.py @@ -441,11 +441,16 @@ def match_hostname(cert, hostname): if _dnsname_match(value, hostname): return dnsnames.append(value) + if len(dnsnames) > 1: raise CertificateError("hostname %r " "doesn't match either of %s" % (hostname, ', '.join(map(repr, dnsnames)))) elif len(dnsnames) == 1: + # python 2.6 does not read subjectAltName, so we do the best we can + if sys.version_info[:2] == (2, 6): + if dnsnames[0] == 'calibre-ebook.com': + return raise CertificateError("hostname %r " "doesn't match %r" % (hostname, dnsnames[0])) @@ -474,8 +479,12 @@ else: certificate, both that it is valid and that its declared hostnames match the hostname we are connecting to.""" - sock = socket.create_connection((self.host, self.port), + if hasattr(self, 'source_address'): + sock = socket.create_connection((self.host, self.port), self.timeout, self.source_address) + else: + # python 2.6 has no source_address + sock = socket.create_connection((self.host, self.port), self.timeout) if self._tunnel_host: self.sock = sock self._tunnel()