Console reader¶
Wexpect is a Windows variant of pexpect https://pexpect.readthedocs.io.
Wexpect is a Python module for spawning child applications and controlling them automatically.
console_reader Implements a virtual terminal, and starts the child program. The main wexpect.spawn class connect to this class to reach the child’s terminal.
ConsoleReaderPipe¶
-
class
wexpect.console_reader.
ConsoleReaderPipe
(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)¶ -
__init__
(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 codepage (:obj:, optional): Output console code page.
-
read_loop
()¶
-
suspend_child
()¶ Pauses the main thread of the child process.
-
resume_child
()¶ Un-pauses the main thread of the child process.
-
refresh_console
()¶ Clears the console after pausing the child and reading all the data currently on the console.
-
terminate_child
()¶
-
isalive
(process)¶ True if the child is still alive, false otherwise
-
write
(s)¶ Writes input into the child consoles input buffer.
-
createKeyEvent
(char)¶ Creates a single key record corrosponding to the ascii character char.
-
initConsole
(consout=None, window_size_x=80, window_size_y=25, buffer_size_x=80, buffer_size_y=16000)¶
-
parseData
(s)¶ Ensures that special characters are interpretted as newlines or blanks, depending on if there written over characters or screen-buffer-fill characters.
-
getConsoleOut
()¶
-
getCoord
(offset)¶ Converts an offset to a point represented as a tuple.
-
getOffset
(coord)¶ Converts a tuple-point to an offset.
-
readConsole
(startCo, endCo)¶ Reads the console area from startCo to endCo and returns it as a string.
-
readConsoleToCursor
()¶ Reads from the current read position to the current cursor position and inserts the string into self.__buffer.
-
interact
()¶ Displays the child console for interaction.
-
sendeof
()¶ This sends an EOF to the host. This sends a character which inform the host that child has been finished, and all of it’s output has been send to host.
-
create_connection
(timeout=-1, **kwargs)¶
-
close_connection
()¶
-
send_to_host
(msg)¶
-
get_from_host
()¶
-
ConsoleReaderSocket¶
-
class
wexpect.console_reader.
ConsoleReaderSocket
(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)¶ -
__init__
(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 codepage (:obj:, optional): Output console code page.
-
read_loop
()¶
-
suspend_child
()¶ Pauses the main thread of the child process.
-
resume_child
()¶ Un-pauses the main thread of the child process.
-
refresh_console
()¶ Clears the console after pausing the child and reading all the data currently on the console.
-
terminate_child
()¶
-
isalive
(process)¶ True if the child is still alive, false otherwise
-
write
(s)¶ Writes input into the child consoles input buffer.
-
createKeyEvent
(char)¶ Creates a single key record corrosponding to the ascii character char.
-
initConsole
(consout=None, window_size_x=80, window_size_y=25, buffer_size_x=80, buffer_size_y=16000)¶
-
parseData
(s)¶ Ensures that special characters are interpretted as newlines or blanks, depending on if there written over characters or screen-buffer-fill characters.
-
getConsoleOut
()¶
-
getCoord
(offset)¶ Converts an offset to a point represented as a tuple.
-
getOffset
(coord)¶ Converts a tuple-point to an offset.
-
readConsole
(startCo, endCo)¶ Reads the console area from startCo to endCo and returns it as a string.
-
readConsoleToCursor
()¶ Reads from the current read position to the current cursor position and inserts the string into self.__buffer.
-
interact
()¶ Displays the child console for interaction.
-
sendeof
()¶ This sends an EOF to the host. This sends a character which inform the host that child has been finished, and all of it’s output has been send to host.
-
create_connection
(**kwargs)¶
-
close_connection
()¶
-
send_to_host
(msg)¶
-
get_from_host
()¶
-