omero.clients module

class clients.BaseClient(args=None, id=None, host=None, port=None, pmap=None)[source]

Bases: object

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

Typical usage includes:

# Uses --Ice.Config argument or ICE_CONFIG variable
client = omero.client()
# Defines "omero.host"
client = omero.client(host = host)
# Defines "omero.host" and "omero.port"
client = omero.client(host = host, port = port)
class CallbackI(*args: Any, **kwargs: Any)[source]

Bases: ClientCallback

Implemention of ClientCallback which will be added to any Session which this instance creates. Note: this client should avoid all interaction with the {@link client#lock} since it can lead to deadlocks during shutdown. See: ticket:1210

execute(myCallable, action)[source]
requestHeartbeat(current=None)[source]
sessionClosed(current=None)[source]
shutdownIn(milliseconds, current=None)[source]
closeSession()[source]

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.

createClient(secure)[source]

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.

Note: detachOnDestroy has NOT been called on the session in the returned client. Clients are responsible for doing this immediately if such desired.

createSession(username=None, password=None)[source]

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.

destroySession(session_uuid)[source]

Takes the UUID for a session and iterates over calls to ISession.closeSession until the reference count hits 0. Returns the number of calls to closeSession executed before hitting 0. Raises any non-RemovedSessionExceptions.

download(ofile, filename=None, block_size=1048576, filehandle=None)[source]
enableKeepAlive(seconds)[source]

Resets the “omero.keep_alive” property on the current Ice.Communicator which is used on initialization to determine the time-period between Resource checks. The __resources instance will be created as soon as an active session is detected.

getAdapter()[source]

Returns the Ice.ObjectAdapter for this instance or throws an exception if None.

getCategory()[source]

Returns the category which should be used for all callbacks passed to the server.

getCommunicator()[source]

Returns the Ice.Communicator for this instance or throws an exception if None.

getContext(group=None)[source]

Returns a copy of the implicit context’s context, i.e. dict(getImplicitContext().getContext()) for use as the last argument to any remote method.

getDefaultBlockSize()[source]

Returns the user-configured “omero.block_size” property or omero.constants.DEFAULTBLOCKSIZE if none is set.

getImplicitContext()[source]

Returns the Ice.ImplicitContext which defines what properties will be sent on every method invocation.

getInput(key, unwrap=False)[source]

Retrieves an item from the “input” shared (session) memory.

getInputKeys()[source]

Returns a list of keys for all items in the “input” shared (session) memory

getInputs(unwrap=False)[source]

Returns all items in the “input” shared (session) memory

getManagedRepository(description=False)[source]
getOutput(key, unwrap=False)[source]

Retrieves an item from the “output” shared (session) memory.

getOutputKeys()[source]

Returns a list of keys for all items in the “output” shared (session) memory

getOutputs(unwrap=False)[source]

Returns all items in the “output” shared (session) memory

getProperties()[source]

Returns the active properties for this instance

getProperty(key)[source]

Returns the property for the given key or “” if none present

getPropertyMap(properties=None)[source]

Returns all properties which are prefixed with “omero.” or “Ice.”

getRouter(comm)[source]

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.

getSession(blocking=True)[source]

Returns the current active session or throws an exception if none has been created since the last closeSession()

If blocking is False, then self.__lock is not acquired and the value of self.__sf is simply returned. Clients must properly handle the situation where this value is None.

getSessionId()[source]

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.

getStatefulServices()[source]

Returns all active StatefulServiceInterface proxies. This can be used to call close before calling setSecurityContext.

isSecure()[source]

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.

joinSession(session)[source]

Uses the given session uuid as name and password to rejoin a running session

killSession()[source]

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.

onHeartbeat(myCallable)[source]
onSessionClosed(myCallable)[source]
onShutdownIn(myCallable)[source]
parseAndSetInt(data, key, newValue)[source]
setAgent(agent)[source]

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

setIP(ip)[source]

Sets the omero.model.Session#getUserIP() string for this client. Every session creation will be passed this argument. Finding open sessions with the same IP can be done via omero.api.ISessionPrx#getMyOpenIPSessions(ip).

setInput(key, value)[source]

Sets an item in the “input” shared (session) memory under the given name.

setOutput(key, value)[source]

Sets an item in the “output” shared (session) memory under the given name.

sha1(filename)[source]

Calculates the local sha1 for a file.

startKeepAlive()[source]

Start a new __resources instance, stopping any that current exists IF omero.keep_alive is greater than 1.

stopKeepAlive()[source]
submit(req, loops=10, ms=500, failonerror=True, ctx=None, failontimeout=True)[source]
upload(filename, name=None, path=None, type=None, ofile=None, block_size=1024)[source]

Utility method to upload a file to the server.

waitOnCmd(handle, loops=10, ms=500, failonerror=True, failontimeout=False, closehandle=False)[source]
write_stream(file, prx, block_size=1048576)[source]