diff --git a/src/Config.py b/src/Config.py index 56d04231..2cc993fa 100644 --- a/src/Config.py +++ b/src/Config.py @@ -13,7 +13,7 @@ class Config(object): def __init__(self, argv): self.version = "0.7.0" - self.rev = 4200 + self.rev = 4203 self.argv = argv self.action = None self.pending_changes = {} diff --git a/src/Crypt/CryptConnection.py b/src/Crypt/CryptConnection.py index 9734089e..c5ee2761 100644 --- a/src/Crypt/CryptConnection.py +++ b/src/Crypt/CryptConnection.py @@ -137,14 +137,14 @@ class CryptConnectionManager: cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, env=self.openssl_env ) - back = proc.stdout.read().strip().replace(b"\r", b"") + back = proc.stdout.read().strip().decode(errors="replace").replace("\r", "") proc.wait() if not (os.path.isfile(self.cacert_pem) and os.path.isfile(self.cakey_pem)): self.log.error("RSA ECC SSL CAcert generation failed, CAcert or CAkey files not exist. (%s)" % back) return False else: - self.log.debug("Result: %s" % back.decode()) + self.log.debug("Result: %s" % back) # Generate certificate key and signing request cmd_params = helper.shellquote( @@ -160,7 +160,7 @@ class CryptConnectionManager: cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, env=self.openssl_env ) - back = proc.stdout.read().strip().decode().replace("\r", "") + back = proc.stdout.read().strip().decode(errors="replace").replace("\r", "") proc.wait() self.log.debug("Running: %s\n%s" % (cmd, back)) @@ -179,7 +179,7 @@ class CryptConnectionManager: cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, env=self.openssl_env ) - back = proc.stdout.read().strip().decode().replace("\r", "") + back = proc.stdout.read().strip().decode(errors="replace").replace("\r", "") proc.wait() self.log.debug("Running: %s\n%s" % (cmd, back)) diff --git a/src/main.py b/src/main.py index 7ffbedd5..f75d2dff 100644 --- a/src/main.py +++ b/src/main.py @@ -76,6 +76,15 @@ if config.stack_size: if config.msgpack_purepython: os.environ["MSGPACK_PUREPYTHON"] = "True" +# Fix console encoding on Windows +if sys.platform.startswith("win"): + import subprocess + try: + chcp_res = subprocess.check_output("chcp 65001", shell=True).decode(errors="ignore").strip() + logging.debug("Changed console encoding to utf8: %s" % chcp_res) + except Exception as err: + logging.error("Error changing console encoding to utf8: %s" % err) + # Socket monkey patch if config.proxy: from util import SocksProxy