Rev4203, Change console encoding to utf8 on Windows
This commit is contained in:
parent
166a65e1b1
commit
0b04176f18
3 changed files with 14 additions and 5 deletions
|
@ -13,7 +13,7 @@ class Config(object):
|
||||||
|
|
||||||
def __init__(self, argv):
|
def __init__(self, argv):
|
||||||
self.version = "0.7.0"
|
self.version = "0.7.0"
|
||||||
self.rev = 4200
|
self.rev = 4203
|
||||||
self.argv = argv
|
self.argv = argv
|
||||||
self.action = None
|
self.action = None
|
||||||
self.pending_changes = {}
|
self.pending_changes = {}
|
||||||
|
|
|
@ -137,14 +137,14 @@ class CryptConnectionManager:
|
||||||
cmd, shell=True, stderr=subprocess.STDOUT,
|
cmd, shell=True, stderr=subprocess.STDOUT,
|
||||||
stdout=subprocess.PIPE, env=self.openssl_env
|
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()
|
proc.wait()
|
||||||
|
|
||||||
if not (os.path.isfile(self.cacert_pem) and os.path.isfile(self.cakey_pem)):
|
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)
|
self.log.error("RSA ECC SSL CAcert generation failed, CAcert or CAkey files not exist. (%s)" % back)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
self.log.debug("Result: %s" % back.decode())
|
self.log.debug("Result: %s" % back)
|
||||||
|
|
||||||
# Generate certificate key and signing request
|
# Generate certificate key and signing request
|
||||||
cmd_params = helper.shellquote(
|
cmd_params = helper.shellquote(
|
||||||
|
@ -160,7 +160,7 @@ class CryptConnectionManager:
|
||||||
cmd, shell=True, stderr=subprocess.STDOUT,
|
cmd, shell=True, stderr=subprocess.STDOUT,
|
||||||
stdout=subprocess.PIPE, env=self.openssl_env
|
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()
|
proc.wait()
|
||||||
self.log.debug("Running: %s\n%s" % (cmd, back))
|
self.log.debug("Running: %s\n%s" % (cmd, back))
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ class CryptConnectionManager:
|
||||||
cmd, shell=True, stderr=subprocess.STDOUT,
|
cmd, shell=True, stderr=subprocess.STDOUT,
|
||||||
stdout=subprocess.PIPE, env=self.openssl_env
|
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()
|
proc.wait()
|
||||||
self.log.debug("Running: %s\n%s" % (cmd, back))
|
self.log.debug("Running: %s\n%s" % (cmd, back))
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,15 @@ if config.stack_size:
|
||||||
if config.msgpack_purepython:
|
if config.msgpack_purepython:
|
||||||
os.environ["MSGPACK_PUREPYTHON"] = "True"
|
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
|
# Socket monkey patch
|
||||||
if config.proxy:
|
if config.proxy:
|
||||||
from util import SocksProxy
|
from util import SocksProxy
|
||||||
|
|
Loading…
Reference in a new issue