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)

This commit is contained in:
Kovid Goyal 2014-02-28 13:58:06 +05:30
parent 94741bab3b
commit 45e6468b01

View File

@ -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."""
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()