smartinspectpython.sipipeprotocol

Module: sipipeprotocol.py

Revision History

Date Version Description
2023/09/27 3.0.21.0 Updated documentation sample code and examples.
2023/06/09 3.0.8.0 Added call to RaiseInfoEvent for the SI Console Server banner.
2023/05/30 3.0.0.0 Initial Version.

@export
class SIPipeProtocol(smartinspectpython.siprotocol.SIProtocol):

Used for sending packets to a local SmartInspect Console over a named pipe connection. This protocol only works on Windows-based systems, as it utilizes a Win32 API for named pipe access.

This class is used for sending packets through a local named pipe to the SmartInspect Console. It is used when the 'pipe' protocol is specified in the SmartInspect.Connections. Please see the IsValidOption method for a list of available protocol options. Please note that this protocol can only be used for local connections. For remote connections to other machines, please use SITcpProtocol.

For a list of available protocol options, please refer to the IsValidOption method.

Threadsafety:

The public members of this class are thread-safe.

SIPipeProtocol()

Initializes a new instance of the class.

Name: str

Overridden. Returns "pipe".

def BuildOptions( self, builder: smartinspectpython.siconnectionsbuilder.SIConnectionsBuilder) -> None:

Overridden. Fills a SIConnectionsBuilder instance with the options currently used by this protocol.

Arguments:
  • builder (SIConnectionsBuilder): The SIConnectionsBuilder object to fill with the current options of this protocol.
def InternalConnect(self) -> None:

Overridden. Connects to the specified local named pipe.

Raises:
  • SIProtocolException: Establishing the named pipe connection failed.

This method tries to establish a connection to a local named pipe of a SmartInspect Console.

def InternalDisconnect(self) -> None:

Overridden. Closes the connection to the specified local named pipe.

Raises:
  • SIProtocolException: Closing the named pipe handle failed.

This method closes the named pipe handle if previously created and disposes any supplemental objects.

def InternalReconnect(self) -> bool:

Tries to reconnect to the specified local named pipe.

Returns:

True if the reconnect attempt has been successful and false otherwise.

This method tries to re-establish a connection to the local named pipe of a SmartInspect Console.

def InternalWritePacket(self, packet: smartinspectpython.sipacket.SIPacket) -> None:

Sends a packet to the Console.

Arguments:
  • packet (SIPacket): The packet to write.
Raises:
  • Exception: Sending the packet to the Console failed.

This method sends the supplied packet to the SmartInspect Console over the previously established named pipe connection.

def IsValidOption(self, name: str) -> bool:

Overridden. Validates if a protocol option is supported.

Arguments:
  • name (str): The option name to validate.
Returns:

True if the option is supported and false otherwise.

The following table lists all valid options, their default values and descriptions for the PIPE protocol.

Valid Options (default value) Description
- pipename ("smartinspect") Specifies the named pipe for sending log packets to the SmartInspect Console. This value must match the pipe name in the SmartInspect Console options.

Sample Code

# package imports.
from smartinspectpython.siauto import *

# the following are sample SI Connections options for this protocol.

# log messages to SI Console using all default options (pipename=smartinspect).
SIAuto.Si.Connections = "pipe()"

# log messages to SI Console using pipe name "sipipe", with asyncronous send enabled.
SIAuto.Si.Connections = "pipe(pipename=sipipe,reconnect=true,reconnect.interval=10s,async.enabled=true)"

def LoadOptions(self) -> None:

Overridden. Loads and inspects specific options for this protocol.

This method loads all relevant options and ensures their correctness. See IsValidOption for a list of options which are recognized by this protocol.