omero.util.sessions module

Library for managing user sessions.

class util.sessions.SessionsStore(dir=None)[source]

Bases: object

The store is a file-based repository of user sessions. By default, stores use $HOME/omero/sessions as their repository path.

Use add() to add items to the repository

add(host, name, id, props, sudo=None)[source]

Stores a file containing the properties at REPO/host/name/id

attach(server, name, sess, set_current=True)[source]

Simple helper. Delegates to create() using the session as both the username and the password. This reproduces the logic of client.joinSession()

available(host, name)[source]

Returns the path to property files which are stored. Internal accounting files are not returned.

clear(host=None, name=None, sess=None)[source]

Walks through all sessions and calls killSession. Regardless of exceptions, it will remove the session files from the store.

conflicts(host, name, id, new_props, ignore_nulls=False, check_group=True)[source]

Compares if the passed properties are compatible with with those for the host, name, id tuple

If ignore_nulls is True, then a null in new_props means matches anything.

contents()[source]

Returns a map of maps with all the contents of the store. Internal accounting files are skipped.

count(host=None, name=None)[source]

Returns the sum of all files visited by walk()

create(name, pasw, props, new=True, set_current=True, sudo=None)[source]

Creates a new omero.client object, and returns: (cilent, session_id, timeToIdle, timeToLive)

exists(host, name, uuid)[source]

Checks if the given file exists.

find_name_by_key(server, uuid)[source]

Returns the name of a user for which the session key exists. This value is taken from the path rather than from the properties file since that value may have been overwritten. An exception is raised if there is more than one name since keys should be UUIDs. A None may be returned.

get(host, name, uuid)[source]

Returns the properties stored in the given session file

get_current()[source]
host_file()[source]

Returns the path-object which stores the last active host

last_host()[source]

Prints either the last saved host (see get_current()) or “localhost”

last_port()[source]

Prints either the last saved port (see get_current()) or “4064”

non_dot(d)[source]

Only returns the files (not directories) contained in d that don’t start with a dot

port_file()[source]

Returns the path-object which stores the last active port

props(f)[source]

Parses the path-object into properties

remove(host, name, uuid)[source]

Removes the given session file from the store and removes the sess_file() if it is equal to the session we just removed.

report()[source]

Simple dump utility

sess_file(host, user)[source]

Returns the path-object which stores the last active session

set_current(host, name=None, uuid=None, props=None)[source]

Sets the current session, user, and host files These are used as defaults by other methods.

user_file(host)[source]

Returns the path-object which stores the last active user

walk(func, host=None, name=None, sess=None)[source]

Applies func to all host, name, and session path-objects.