mirror of
https://github.com/clearml/wexpect-venv
synced 2025-02-07 05:20:52 +00:00
[FIX] appveyor, by adding codepage parameter
This commit is contained in:
parent
ad50d38614
commit
7afcbe8f73
@ -46,6 +46,7 @@ import signal
|
||||
from io import StringIO
|
||||
|
||||
import ctypes
|
||||
from ctypes import windll
|
||||
import win32console
|
||||
import win32process
|
||||
import win32con
|
||||
@ -80,14 +81,14 @@ class ConsoleReaderBase:
|
||||
This class initialize the console starts the child in it and reads the console periodically.
|
||||
"""
|
||||
|
||||
def __init__(self, path, host_pid, cp=None, window_size_x=80, window_size_y=25,
|
||||
def __init__(self, path, host_pid, codepage=None, window_size_x=80, window_size_y=25,
|
||||
buffer_size_x=80, buffer_size_y=16000, local_echo=True, interact=False, **kwargs):
|
||||
"""Initialize the console starts the child in it and reads the console periodically.
|
||||
|
||||
Args:
|
||||
path (str): Child's executable with arguments.
|
||||
parent_pid (int): Parent (aka. host) process process-ID
|
||||
cp (:obj:, optional): Output console code page.
|
||||
codepage (:obj:, optional): Output console code page.
|
||||
"""
|
||||
self.lastRead = 0
|
||||
self.__bufferY = 0
|
||||
@ -109,13 +110,15 @@ class ConsoleReaderBase:
|
||||
|
||||
logger.info("ConsoleReader started")
|
||||
|
||||
if cp:
|
||||
try:
|
||||
logger.info("Setting console output code page to %s" % cp)
|
||||
win32console.SetConsoleOutputCP(cp)
|
||||
logger.info("Console output code page: %s" % ctypes.windll.kernel32.GetConsoleOutputCP())
|
||||
except Exception as e:
|
||||
logger.info(e)
|
||||
if codepage is None:
|
||||
codepage = windll.kernel32.GetACP()
|
||||
|
||||
try:
|
||||
logger.info("Setting console output code page to %s" % codepage)
|
||||
win32console.SetConsoleOutputCP(codepage)
|
||||
logger.info("Console output code page: %s" % ctypes.windll.kernel32.GetConsoleOutputCP())
|
||||
except Exception as e:
|
||||
logger.info(e)
|
||||
|
||||
try:
|
||||
self.create_connection(**kwargs)
|
||||
|
@ -243,6 +243,7 @@ class SpawnBase:
|
||||
self.child_fd = -1 # initially closed
|
||||
self.timeout = timeout
|
||||
self.delimiter = EOF
|
||||
self.codepage = codepage
|
||||
self.cwd = cwd
|
||||
self.env = env
|
||||
self.echo = echo
|
||||
@ -362,7 +363,8 @@ class SpawnBase:
|
||||
self.console_class_parameters.update({
|
||||
'host_pid': self.host_pid,
|
||||
'local_echo': self.echo,
|
||||
'interact': self.interact_state
|
||||
'interact': self.interact_state,
|
||||
'codepage': self.codepage
|
||||
})
|
||||
console_class_parameters_kv_pairs = [f'{k}={v}' for k,v in self.console_class_parameters.items() ]
|
||||
console_class_parameters_str = ', '.join(console_class_parameters_kv_pairs)
|
||||
|
Loading…
Reference in New Issue
Block a user