LMIIndicationListener Package

class LMIIndicationListener.LMIIndicationHandler(request, client_address, server)[source]

Class representing indication handler. The class is derived from BaseHTTPRequestHandler, because the indications are transported by http protocol, and from ThreadingMixIn; the indication listener is designed as concurrent server to properly handle each incoming indication.

do_POST()[source]

Overridden method, which is called, when a indication is received. It parses the indication message and searches for a matching handler for the indication name. Each subscribed indication should have it’s Destination set something similar:

<schema>://<destination>/<indication_name>

where the indication_name is a string, which properly defines the indication.

class LMIIndicationListener.LMIIndicationHandlerCallback(callback, *args, **kwargs)[source]

Helper class, which stores indication handler callback with its arguments and keyword arguments.

Parameters:
  • callback – callback, which is called, when a indication arrives
  • args (tuple) – positional arguments for callback
  • kwargs – keyword arguments for callback
class LMIIndicationListener.LMIIndicationListener(hostname, port, certfile=None, keyfile=None)[source]

Class representing indication listener, which provides a unified API for the server startup and shutdown and for registering an indication handler.

Parameters:
  • hostname (string) – hostname or address of the machine, where the indications will be delivered
  • port (int) – TCP port, where the server should listen for incoming messages
  • certfile (string) – path to certificate file, if SSL used
  • keyfile (string) – path to key file, if SSL used
add_handler(handler_name_pattern, handler, *args, **kwargs)[source]

Registers a handler into the indication listener. Returns a string, which is used for the indication recognition, when a message arrives.

Parameters:
  • handler_name_pattern (string) – string, which may contain set of “X” characters at the end of the string. The “X” characters will be replaced by random characters and the whole string will form a unique string.
  • handler – callable, which will be executed, when a indication is received
  • args (tuple) – positional arguments for the handler
  • kwargs (dictionary) – keyword arguments for the handler
Returns:

handler unique name

Return type:

string

hostname[source]
Returns:hostname or address, where the indication listener is waiting for messages
Return type:string
is_alive[source]
Returns:flag indicating, if the indication listener is running
Return type:bool
port[source]
Returns:port, where the indication listener is waiting for messages
Return type:int
remove_handler(name)[source]

Removes a specified handler from the indication listener database.

Parameters:name (string) – indication name; returned by LMIIndicationListener.add_handler()
start()[source]

Starts a indication listener.

The indication listener runs in a newly-created thread.

Returns:True, if the indication listener started with no errors; False otherwise
stop()[source]

Stops the indication listener.

This method will also terminate the listener thread.

class LMIIndicationListener.LMIIndicationServer(server_address, RequestHandlerClass, bind_and_activate=True)[source]

Class representing indication server, derived from HTTPServer and designed as concurrent server.

This Page