mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #396 (Fix UnicodeDecodeError in linux installer script)
This commit is contained in:
parent
b189c31fc4
commit
4abd16a4a5
@ -15,7 +15,9 @@ is64bit = platform.architecture()[0] == '64bit'
|
|||||||
url = 'http://code.calibre-ebook.com/dist/linux'+('64' if is64bit else '32')
|
url = 'http://code.calibre-ebook.com/dist/linux'+('64' if is64bit else '32')
|
||||||
url = os.environ.get('CALIBRE_INSTALLER_LOCAL_URL', url)
|
url = os.environ.get('CALIBRE_INSTALLER_LOCAL_URL', url)
|
||||||
py3 = sys.version_info[0] > 2
|
py3 = sys.version_info[0] > 2
|
||||||
enc = getattr(sys.stdout, 'encoding', 'UTF-8') or 'utf-8'
|
enc = getattr(sys.stdout, 'encoding', 'utf-8') or 'utf-8'
|
||||||
|
if enc.lower() == 'ascii':
|
||||||
|
enc = 'utf-8'
|
||||||
calibre_version = signature = None
|
calibre_version = signature = None
|
||||||
urllib = __import__('urllib.request' if py3 else 'urllib', fromlist=1)
|
urllib = __import__('urllib.request' if py3 else 'urllib', fromlist=1)
|
||||||
has_ssl_verify = hasattr(ssl, 'PROTOCOL_TLSv1_2') and sys.version_info[:3] > (2, 7, 8)
|
has_ssl_verify = hasattr(ssl, 'PROTOCOL_TLSv1_2') and sys.version_info[:3] > (2, 7, 8)
|
||||||
@ -25,9 +27,15 @@ if py3:
|
|||||||
raw_input = input
|
raw_input = input
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
import http.client as httplib
|
import http.client as httplib
|
||||||
|
encode_for_subprocess = lambda x:x
|
||||||
else:
|
else:
|
||||||
|
from future_builtins import map
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
import httplib
|
import httplib
|
||||||
|
def encode_for_subprocess(x):
|
||||||
|
if isinstance(x, unicode):
|
||||||
|
x = x.encode(enc)
|
||||||
|
return x
|
||||||
|
|
||||||
class TerminalController: # {{{
|
class TerminalController: # {{{
|
||||||
BOL = '' #: Move the cursor to the beginning of the line
|
BOL = '' #: Move the cursor to the beginning of the line
|
||||||
@ -594,9 +602,10 @@ def get_https_resource_securely(url, timeout=60, max_redirects=5, ssl_version=No
|
|||||||
def extract_tarball(raw, destdir):
|
def extract_tarball(raw, destdir):
|
||||||
prints('Extracting application files...')
|
prints('Extracting application files...')
|
||||||
with open('/dev/null', 'w') as null:
|
with open('/dev/null', 'w') as null:
|
||||||
p = subprocess.Popen(['tar', 'xJof', '-', '-C', destdir], stdout=null, stdin=subprocess.PIPE, close_fds=True,
|
p = subprocess.Popen(
|
||||||
preexec_fn=lambda:
|
list(map(encode_for_subprocess, ['tar', 'xJof', '-', '-C', destdir])),
|
||||||
signal.signal(signal.SIGPIPE, signal.SIG_DFL))
|
stdout=null, stdin=subprocess.PIPE, close_fds=True, preexec_fn=lambda:
|
||||||
|
signal.signal(signal.SIGPIPE, signal.SIG_DFL))
|
||||||
p.stdin.write(raw)
|
p.stdin.write(raw)
|
||||||
p.stdin.close()
|
p.stdin.close()
|
||||||
if p.wait() != 0:
|
if p.wait() != 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user