Remote Objects

Remote method invocation from Python scripts to MHI application entities.

Remotable

class mhi.enerplot.common.remote.Remotable

Base class for Remote Method Invocation (RMI) enabled objects

main

A reference to the Application object that returned this Remotable object.

Application

class mhi.enerplot.common.remote.Application

A Remote Application object.

This object represents the running application. It implements the “context manager” protocol, allowing a Python script to automatically close the communication channel when the application object goes out of scope.

silence

When set to True, silence all popup dialogs, using the dialog’s “default” action.

is_alive()

Tests whether the application process is still running, and the communication socket to the application is still open.

Returns:True is the application communication channel is open, False otherwise.
Return type:bool
quit()

Terminate the remote application.

Note: The local side of the socket connection to the remote application is not explicitly closed. The client is responsible for explicitly closing the connection:

application.quit()
application.close_connection()

or by using a context manager:

with ... as application:
    # interact with the application
    #
    # application.close_connection() is automatically called
    # when the `with` statement block exits.
close_connection()

Terminate connection to remote application.

Note: The remote application will not be terminated. The “silence all dialog and message boxes” flag is cleared.

Decorators

@rmi

remote.rmi()

Remote Method Invocation

Apply this decorator to a method of a Remotable object causes the method invocation to be forwarded to the remote application object. The body of the decorated method is ignored.

@rmi_property

class mhi.enerplot.common.remote.rmi_property(fget=None, fset=None, fdel=None, doc=None, name=None)

A property which is stored in a remote object

Apply this decorator to a property of a Remotable object causes the property access attempts to be forwarded to the remote application object.

Remote properties may never be deleted.

Context

class mhi.enerplot.common.remote.Context

A Remote Context object

This class is responsible for communications between the Python script and the remote application objects.

Calls to rmi methods and access to rmi_properties are pickled, and sent over a communication channel. The results of these operations are received from the communication channel, depickled, and returned to the caller. Any exception generated by the remote operation is also transfered over the communication channel and raised locally.

Socket Context

class mhi.enerplot.common.remote.SocketContext(sock)

A context object with the communication channel implemented as a TCP/IP socket.

Queue Context

class mhi.enerplot.common.remote.QueueContext(server)

A context object with the communication channel implemented with a Queue

Exceptions

class mhi.enerplot.common.remote.RemoteException(message, *args)

Indication of an API error communicating with remote objects