diff options
author | zoidberg10 <zoidberg@mujmail.cz> | 2011-12-14 16:18:30 +0100 |
---|---|---|
committer | zoidberg10 <zoidberg@mujmail.cz> | 2011-12-14 16:18:30 +0100 |
commit | 2ed683d477a547dcab2a554d0a1e95e3f4a35d48 (patch) | |
tree | 8dafe6796dcbba5c8a2aca99a0dc35deaf8d9ad8 | |
parent | fix input encoding in setup (diff) | |
download | pyload-2ed683d477a547dcab2a554d0a1e95e3f4a35d48.tar.xz |
cp65001 is broken
-rw-r--r-- | module/Utils.py | 10 | ||||
-rw-r--r-- | module/setup.py | 6 | ||||
-rwxr-xr-x | pyLoadCore.py | 8 |
3 files changed, 14 insertions, 10 deletions
diff --git a/module/Utils.py b/module/Utils.py index 1f4f8c047..9c0856e2a 100644 --- a/module/Utils.py +++ b/module/Utils.py @@ -61,6 +61,16 @@ if sys.getfilesystemencoding() == 'ANSI_X3.4-1968': else: fs_encode = fs_decode = lambda x: x # do nothing +def getConsoleEncoding(enc): + if os.name == "nt": + if enc == "cp65001": # aka UTF-8 + print "ERROR: Windows codepage 65001 is not supported." + exit() + elif enc == "ascii": + print "WARNING: Your console's encoding was identified as ASCII. Forcing UTF-8 instead." + enc = "UTF-8" + + return enc def compare_time(start, end): start = map(int, start) diff --git a/module/setup.py b/module/setup.py index 243758ff4..0e8b54848 100644 --- a/module/setup.py +++ b/module/setup.py @@ -28,6 +28,7 @@ from subprocess import PIPE from subprocess import call import sys from sys import exit +from module.utils import getConsoleEncoding class Setup(): """ @@ -37,10 +38,7 @@ class Setup(): def __init__(self, path, config): self.path = path self.config = config - self.stdin_encoding = sys.stdin.encoding - if self.stdin_encoding == "ascii": - self.stdin_encoding = 'utf_8' - print "Your terminal encoding was identified as ASCII. Forcing UTF-8." + self.stdin_encoding = getConsoleEncoding(sys.stdin.encoding) def start(self): langs = self.config.getMetaData("general", "language")["type"].split(";") diff --git a/pyLoadCore.py b/pyLoadCore.py index 2bcfde3c8..e43c4bcf8 100755 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -53,15 +53,11 @@ from module import remote from module.remote.RemoteManager import RemoteManager from module.database import DatabaseBackend, FileHandler -from module.utils import freeSpace, formatSize +from module.utils import freeSpace, formatSize, getConsoleEncoding from codecs import getwriter -if os.name == "nt": - enc = sys.stdout.encoding -else: - enc = "utf8" - +enc = getConsoleEncoding(sys.stdout.encoding) sys.stdout = getwriter(enc)(sys.stdout, errors="replace") # TODO List |