nxt.remote.nxt_socket module
- class COM_TYPE[source]
Bases:
objectConstants used as keys in the pickled message dicts sent over to the nxt socket server.
- LOG = 'log'
- CACHE = 'cache'
- SHUTDOWN = 'shutdown'
- PING = 'ping'
- WAIT = 'wait'
- ERR = 'error'
- setup()[source]
Setup a connection to the nxt socket server. Sets the global variable __nxt_server__ to the newly created socket instance. :return: socket instance
- format_msg(msg, com_typ, msg_dict=None)[source]
Formats the given msg into a dict matching the expected format used by nxt socket servers and clients. :param msg: Object to be formatted as a socket message :param com_typ: COM_TYPE constant :param msg_dict: Optionally if you are combining commands you can pass an existing msg_dict returned from a previous call to this function. :return: dict
- get_nxt_model()[source]
Gets the existing SocketClientModel instance in global scope, if none is found a new one is created and returned. It is stored in the global scope to allow maximum context compatibility. :return: SocketClientModel instance
- class SocketClientModel(com_server)[source]
Bases:
objectSimple nxt model used by remote socket clients
- load(filepath)[source]
Loads the given file path and builds a comp layer ready to be executed. :param filepath: string of nxt save filepath. :return: None
- run(exec_order=())[source]
General purpose run function meant to be called over a socket command port. If a GraphError is raised the internal nxt ERR message is sent over the socket to the server. :param exec_order: Optional list of node paths to execute. :return: None
- open()[source]
Opens connection to nxt socket server. Installs NXTSocketLogHandler logging handler if none is installed. :return: None
- send_log(record)[source]
Simple method for sending log records to an nxt socket server. :param record: logging record :return: None
- send_to_server(data_dict)[source]
Pickles the given data, assembles fixed length header, casts to bytes and sends to the nxt socket server. NOTE: This function catches ALL exceptions raised by the socket instance! :param data_dict: Dict formatted by format_msg :return: None
- class IPCWait(model)[source]
Bases:
objectSimple context manager for telling the server to wait while a command is being processed by the client interpreter.