py3 compat

This commit is contained in:
Kovid Goyal 2014-02-24 13:55:20 +05:30
parent 6dc9091911
commit 552738a436

View File

@ -311,7 +311,7 @@ def download_tarball():
os.remove(dest) os.remove(dest)
try: try:
with open(cached_sigf, 'wb') as f: with open(cached_sigf, 'wb') as f:
f.write(signature.encode('utf-8')) f.write(signature)
except IOError as e: except IOError as e:
if e.errno != errno.EACCES: if e.errno != errno.EACCES:
raise raise
@ -322,7 +322,7 @@ def download_tarball():
prints('Checking downloaded file integrity...') prints('Checking downloaded file integrity...')
if not check_signature(dest, signature): if not check_signature(dest, signature):
os.remove(dest) os.remove(dest)
print ('The downloaded files\' hash does not match. ' print ('The downloaded files\' signature does not match. '
'Try the download again later.') 'Try the download again later.')
raise SystemExit(1) raise SystemExit(1)
return dest return dest
@ -586,9 +586,10 @@ def get_tarball_info():
print ('Downloading tarball signature securely...') print ('Downloading tarball signature securely...')
raw = get_https_resource_securely('https://status.calibre-ebook.com/tarball-info/' + raw = get_https_resource_securely('https://status.calibre-ebook.com/tarball-info/' +
('x86_64' if is64bit else 'i686')) ('x86_64' if is64bit else 'i686'))
signature, calibre_version = (x.decode('ascii') for x in raw.rpartition(b'@')[::2]) signature, calibre_version = raw.rpartition(b'@')[::2]
if not signature or not calibre_version: if not signature or not calibre_version:
raise ValueError('Failed to get install file signature, invalid signature returned') raise ValueError('Failed to get install file signature, invalid signature returned')
calibre_version = calibre_version.decode('utf-8')
def download_and_extract(destdir): def download_and_extract(destdir):