Package omero :: Module clients :: Class BaseClient
[hide private]
[frames] | no frames]

Class BaseClient

source code


Central client-side blitz entry point, and should be in sync with OmeroJava's omero.client and OmeroCpp's omero::client.

Typical usage includes:

   client = omero.client()                          # Uses --Ice.Config argument or ICE_CONFIG variable
   client = omero.client(host = host)               # Defines "omero.host"
   client = omero.client(host = host, port = port)  # Defines "omero.host" and "omero.port"

For more information, see:

Nested Classes [hide private]
  CallbackI
Implemention of ClientCallback which will be added to any Session which this instance creates.
Instance Methods [hide private]
 
__init__(self, args=None, id=None, host=None, port=None, pmap=None)
Constructor which takes one sys.argv-style list, one initialization data, one host string, one port integer, and one properties map, in that order.
source code
 
_repair(self, args, id, host, port, pmap)
Takes the 5 arguments passed to the __init__ method and attempts to re-order them based on their types.
source code
 
_initData(self, id)
Initializes the current client via an Ice.InitializationData instance.
source code
 
setAgent(self, agent)
Sets the omero.model.Session#getUserAgent() string for this client.
source code
 
isSecure(self)
Specifies whether or not this client was created via a call to createClient with a boolean of False.
source code
 
createClient(self, secure)
Creates a possibly insecure omero.client instance and calls joinSession using the current getSessionId value.
source code
 
__del__(self)
Calls closeSession() and ignores any exceptions.
source code
 
getCommunicator(self)
Returns the Ice.Communicator for this instance or throws an exception if None.
source code
 
getAdapter(self)
Returns the Ice.ObjectAdapter for this instance or throws an exception if None.
source code
 
getSession(self)
Returns the current active session or throws an exception if none has been created since the last closeSession()
source code
 
getSessionId(self)
Returns the UUID for the current session without making a remote call.
source code
 
getImplicitContext(self)
Returns the Ice.ImplicitContext which defines what properties will be sent on every method invocation.
source code
 
getProperties(self)
Returns the active properties for this instance
source code
 
getProperty(self, key)
Returns the property for the given key or "" if none present
source code
 
getPropertyMap(self, properties=None)
Returns all properties which are prefixed with "omero." or "Ice."
source code
 
joinSession(self, session)
Uses the given session uuid as name and password to rejoin a running session
source code
 
createSession(self, username=None, password=None)
Performs the actual logic of logging in, which is done via the getRouter().
source code
 
enableKeepAlive(self, seconds)
Resets the "omero.keep_alive" property on the current Ice.Communicator which is used on initialization to determine the time-period between Resource checks.
source code
 
getRouter(self, comm)
Acquires the default router, and throws an exception if it is not of type Glacier2.Router.
source code
 
sha1(self, filename)
Calculates the local sha1 for a file.
source code
 
upload(self, filename, name=None, path=None, type=None, ofile=None, block_size=1024)
Utility method to upload a file to the server.
source code
 
download(self, ofile, filename=None, block_size=1024*1024, filehandle=None) source code
 
closeSession(self)
Closes the Router connection created by createSession().
source code
 
killSession(self)
Calls ISession.closeSession(omero.model.Session) until the returned reference count is greater than zero.
source code
 
_env(self, _unwrap, method, *args)
Helper method to access session environment
source code
 
getInput(self, key, unwrap=False)
Retrieves an item from the "input" shared (session) memory.
source code
 
getOutput(self, key, unwrap=False)
Retrieves an item from the "output" shared (session) memory.
source code
 
setInput(self, key, value)
Sets an item in the "input" shared (session) memory under the given name.
source code
 
setOutput(self, key, value)
Sets an item in the "output" shared (session) memory under the given name.
source code
 
getInputKeys(self)
Returns a list of keys for all items in the "input" shared (session) memory
source code
 
getOutputKeys(self)
Returns a list of keys for all items in the "output" shared (session) memory
source code
 
getInputs(self, unwrap=False)
Returns all items in the "input" shared (session) memory
source code
 
getOutputs(self, unwrap=False)
Returns all items in the "output" shared (session) memory
source code
 
parseAndSetInt(self, data, key, newValue) source code
 
__getattr__(self, name)
Compatibility layer, which allows calls to getCommunicator() and getSession() to be called via self.ic and self.sf
source code
 
_getCb(self) source code
 
onHeartbeat(self, myCallable) source code
 
onSessionClosed(self, myCallable) source code
 
onShutdownIn(self, myCallable) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]
  __agent
See setAgent
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, args=None, id=None, host=None, port=None, pmap=None)
(Constructor)

source code 

Constructor which takes one sys.argv-style list, one initialization data, one host string, one port integer, and one properties map, in that order. *However*, to simplify use, we reassign values based on their type with a warning printed. A cleaner approach is to use named parameters. :

   c1 = omero.client(None, None, "host", myPort)   # Correct
   c2 = omero.client(host = "host", port = myPort) # Correct
   c3 = omero.client("host", myPort)               # Works with warning

Both "Ice" and "omero" prefixed properties will be parsed.

Defines the state variables:

   __previous : InitializationData from any previous communicator, if any
              Used to re-initialization the client post-closeSession()

   __ic       : communicator. Nullness => init() needed on createSession()

   __sf       : current session. Nullness => createSession() needed.

   __resources: if non-null, hs access to this client instance and will
              periodically call sf.keepAlive(None) in order to keep any
              session alive. This can be enabled either via the omero.keep_alive
              configuration property, or by calling the enableKeepAlive() method.
              Once enabled, the period cannot be adjusted during a single
              session.

Modifying these variables outside of the accessors can lead to undefined behavior.

Equivalent to all OmeroJava and OmeroCpp constructors

Overrides: object.__init__

_repair(self, args, id, host, port, pmap)

source code 

Takes the 5 arguments passed to the __init__ method and attempts to re-order them based on their types. This allows for simplified usage without parameter names.

_initData(self, id)

source code 

Initializes the current client via an Ice.InitializationData instance. This is called by all of the constructors, but may also be called on createSession(name, pass) if a previous call to closeSession() has nulled the Ice.Communicator.

setAgent(self, agent)

source code 

Sets the omero.model.Session#getUserAgent() string for this client. Every session creation will be passed this argument. Finding open sesssions with the same agent can be done via omero.api.ISessionPrx#getMyOpenAgentSessions(String).

isSecure(self)

source code 

Specifies whether or not this client was created via a call to createClient with a boolean of False. If insecure, then all remote calls will use the insecure connection defined by the server.

createClient(self, secure)

source code 

Creates a possibly insecure omero.client instance and calls joinSession using the current getSessionId value. If secure is False, then first the "omero.router.insecure" configuration property is retrieved from the server and used as the value of "Ice.Default.Router" for the new client. Any exception thrown during creation is passed on to the caller.

__del__(self)
(Destructor)

source code 

Calls closeSession() and ignores any exceptions.

Equivalent to close() in OmeroJava or omero::client::~client()

getSessionId(self)

source code 

Returns the UUID for the current session without making a remote call. Uses getSession() internally and will throw an exception if no session is active.

createSession(self, username=None, password=None)

source code 

Performs the actual logic of logging in, which is done via the getRouter(). Disallows an extant ServiceFactoryPrx, and tries to re-create a null Ice.Communicator. A null or empty username will throw an exception, but an empty password is allowed.

enableKeepAlive(self, seconds)

source code 

Resets the "omero.keep_alive" property on the current Ice.Communicator which is used on initialization to determine the time-period between Resource checks. If no __resources instance is available currently, one is also created.

getRouter(self, comm)

source code 

Acquires the default router, and throws an exception if it is not of type Glacier2.Router. Also sets the Ice.ImplicitContext on the router proxy.

closeSession(self)

source code 

Closes the Router connection created by createSession(). Due to a bug in Ice, only one connection is allowed per communicator, so we also destroy the communicator.

killSession(self)

source code 

Calls ISession.closeSession(omero.model.Session) until the returned reference count is greater than zero. The number of invocations is returned. If ISession.closeSession() cannot be called, -1 is returned.