def __init__(self, master_pty, user_pty, cmd_pipe, dbg_pipe): """Initalises a Console object with the provided arguments. Args: master_pty: File descriptor to the master side of the PTY. Used for driving output to the user and receiving user input. user_pty: A string representing the PTY name of the served console. cmd_pipe: A multiprocessing.Connection object which represents the console side of the command pipe. This must be a bidirectional pipe. Console commands and responses utilize this pipe. dbg_pipe: A multiprocessing.Connection object which represents the console's read-only side of the debug pipe. This must be a unidirectional pipe attached to the intepreter. EC debug messages use this pipe. """ logger = logging.getLogger('EC3PO.Console') self.logger = interpreter.LoggerAdapter(logger, {'pty': user_pty}) self.master_pty = master_pty self.user_pty = user_pty self.cmd_pipe = cmd_pipe self.dbg_pipe = dbg_pipe self.oobm_queue = multiprocessing.Queue() self.input_buffer = '' self.input_buffer_pos = 0 self.partial_cmd = '' self.esc_state = 0 self.line_limit = CONSOLE_INPUT_LINE_SIZE self.history = [] self.history_pos = 0 self.prompt = PROMPT self.enhanced_ec = False self.interrogation_timeout = NON_ENHANCED_EC_INTERROGATION_TIMEOUT self.receiving_oobm_cmd = False self.pending_oobm_cmd = '' self.interrogation_mode = 'auto' self.look_buffer = ''
def __init__(self, master_pty, user_pty, interface_pty, cmd_pipe, dbg_pipe, name=None): """Initalises a Console object with the provided arguments. Args: master_pty: File descriptor to the master side of the PTY. Used for driving output to the user and receiving user input. user_pty: A string representing the PTY name of the served console. interface_pty: A string representing the PTY name of the served command interface. cmd_pipe: A socket.socket or multiprocessing.Connection object which represents the console side of the command pipe. This must be a bidirectional pipe. Console commands and responses utilize this pipe. dbg_pipe: A socket.socket or multiprocessing.Connection object which represents the console's read-only side of the debug pipe. This must be a unidirectional pipe attached to the intepreter. EC debug messages use this pipe. name: the console source name """ # Create a unique logger based on the console name console_prefix = ('%s - ' % name) if name else '' logger = logging.getLogger('%sEC3PO.Console' % console_prefix) self.logger = interpreter.LoggerAdapter(logger, {'pty': user_pty}) self.master_pty = master_pty self.user_pty = user_pty self.interface_pty = interface_pty self.cmd_pipe = cmd_pipe self.dbg_pipe = dbg_pipe self.oobm_queue = threadproc_shim.Queue() self.input_buffer = b'' self.input_buffer_pos = 0 self.partial_cmd = b'' self.esc_state = 0 self.line_limit = CONSOLE_INPUT_LINE_SIZE self.history = [] self.history_pos = 0 self.prompt = PROMPT self.enhanced_ec = False self.interrogation_timeout = NON_ENHANCED_EC_INTERROGATION_TIMEOUT self.receiving_oobm_cmd = False self.pending_oobm_cmd = b'' self.interrogation_mode = b'auto' self.timestamp_enabled = True self.look_buffer = b'' self.raw_debug = False self.output_line_log_buffer = []