[ADD] terminal local echo feature

This commit is contained in:
Benedek Racz 2020-01-22 12:33:09 +01:00
parent 9998875dd9
commit 3965fd4f65
2 changed files with 5 additions and 4 deletions

View File

@ -85,7 +85,7 @@ class ConsoleReaderBase:
"""
def __init__(self, path, host_pid, cp=None, window_size_x=80, window_size_y=25,
buffer_size_x=80, buffer_size_y=16000, **kwargs):
buffer_size_x=80, buffer_size_y=16000, local_echo=True, **kwargs):
"""Initialize the console starts the child in it and reads the console periodically.
Args:
@ -103,7 +103,7 @@ class ConsoleReaderBase:
self.connection = None
self.consin = None
self.consout = None
self.local_echo = True
self.local_echo = local_echo
self.console_pid = os.getpid()
self.host_pid = host_pid
self.host_process = psutil.Process(host_pid)

View File

@ -242,6 +242,7 @@ class SpawnBase:
self.delimiter = EOF
self.cwd = cwd
self.env = env
self.echo = echo
self.maxread = maxread # max bytes to read at one time into buffer
self.delaybeforesend = 0.05 # Sets sleep time used just before sending data to child. Time in seconds.
self.delayafterterminate = 0.1 # Sets delay in terminate() method to allow kernel time to update process status. Time in seconds.
@ -913,7 +914,7 @@ class SpawnPipe(SpawnBase):
"import wexpect;"
"import time;"
"wexpect.console_reader.logger.info('loggerStart.');"
f"wexpect.ConsoleReaderPipe(wexpect.join_args({args}), {pid});"
f"wexpect.ConsoleReaderPipe(wexpect.join_args({args}), {pid}, local_echo={self.echo});"
"wexpect.console_reader.logger.info('Console finished2.');"
)
@ -1030,7 +1031,7 @@ class SpawnSocket(SpawnBase):
"import wexpect;"
"import time;"
"wexpect.console_reader.logger.info('loggerStart.');"
f"wexpect.ConsoleReaderSocket(wexpect.join_args({args}), {pid}, port={self.port});"
f"wexpect.ConsoleReaderSocket(wexpect.join_args({args}), {pid}, port={self.port}, local_echo={self.echo});"
"wexpect.console_reader.logger.info('Console finished2.');"
)