x2go.cache module¶
X2GoListSessionCache class - caching X2Go session information.
- class x2go.cache.X2GoListSessionsCache(client_instance, logger=None, loglevel=56)[source]¶
Bases:
objectFor non-blocking operations in client applications using Python X2Go, it is recommended to enable the
x2go.cache.X2GoListSessionsCache. This can be done by calling the constructor of thex2go.client.X2GoClientclass.The session list and desktop cache gets updated in regular intervals by a threaded
x2go.guardian.X2GoSessionGuardianinstance. For the session list and desktop list update, the X2Go server commandsx2golistsessionsandx2godesktopsessionsare called and the command’s stdout is cached in the session list cache.Whenever your client application needs access to either the server’s session list or the server’s desktop list the session cache is queried instead. This assures that the server’s session/desktop list is available without delay, even on slow internet connections.
- check_cache()[source]¶
Check if session list cache elements are still valid (i.e. if all corresponding session profiles are still connected). If not so, remove invalid cache entries from the session list cache.
- delete(profile_name)[source]¶
Remove session list from cache for a given profile.
- Parameters:
profile_name (
str) – name of profile to operate on
- is_cached(profile_name=None, session_uuid=None, cache_type=None)[source]¶
Check if session information is cached.
- Parameters:
profile_name (
str) – name of profile to update (Default value = None)session_uuid (
str) – unique identifier of session to query cache for (Default value = None)cache_type (
str) – cache type (e.g. ‘mounts’, ‘desktops’, ‘sessions’) (Default value = None)
- Returns:
Trueif session information is cached- Return type:
bool
- list_desktops(session_uuid)[source]¶
Retrieve a list of available desktop sessions from the current cache content of
x2go.cache.X2GoListSessionsCachefor a givenx2go.session.X2GoSessioninstance (specified by its unique session UUID).- Parameters:
session_uuid (
str) – unique identifier of session to query cache for- Returns:
a list of strings representing X2Go desktop sessions available for sharing
- Return type:
list(orNone)
- list_mounts(session_uuid)[source]¶
Retrieve a list of mounted client shares from the current cache content of
x2go.cache.X2GoListSessionsCachefor a givenx2go.session.X2GoSessioninstance (specified by its unique session UUID).- Parameters:
session_uuid (
str) – unique identifier of session to query cache for- Returns:
a list of strings representing mounted client shares
- Return type:
list(orNone)
- list_sessions(session_uuid)[source]¶
Retrieve a session list from the current cache content of
x2go.cache.X2GoListSessionsCachefor a givenx2go.session.X2GoSessioninstance (specified by its unique session UUID).- Parameters:
session_uuid (
str) – unique identifier of session to query cache for- Returns:
a data object containing available session information
- Return type:
X2GoServerSessionList*instance (orNone)
- update(profile_name, update_sessions=True, update_desktops=False, update_mounts=False)[source]¶
Update
x2go.cache.X2GoListSessionsCache(i.e. session/desktops) for session profileprofile_name.- Parameters:
profile_name (
str) – name of profile to updateupdate_sessions (
bool) – cache recent session list from server (Default value = True)update_desktops (
bool) – cache recent desktop list from server (Default value = False)update_mounts (
bool) – cache list of client-side mounts on server (Default value = False)
- update_all(update_sessions=True, update_desktops=False)[source]¶
Update
x2go.cache.X2GoListSessionsCachefor all connected session profiles.- Parameters:
update_sessions (
bool) – cache recent session lists from all connected servers (Default value = True)update_desktops (
bool) – cache recent desktop lists from all connected servers (Default value = False)
- x2go_listsessions_cache = {}¶