Package x2go :: Module cache :: Class X2GoListSessionsCache

[frames] | no frames]

# Class X2GoListSessionsCache

source code

    object --+
             |
            X2GoListSessionsCache

For non-blocking operations in client applications using Python X2Go, it is recommended to enable the X2GoListSessionsCache. This can be done by calling the constructor of the X2GoClient class.

The session list and desktop cache gets updated in regular intervals by a threaded X2GoSessionGuardian instance. For the session list and desktop list update, the X2Go server commands `x2golistsessions` and `x2godesktopsessions` are 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.

Instance Methods

__init__(self, client_instance, logger=None, loglevel=56) x.__init__(...) initializes x; see help(type(x)) for signature | source code

delete(self, profile_name) Remove session list from cache for a given profile. | source code

check_cache(self) Check if session list cache elements are still valid (i.e. | source code

update_all(self, update_sessions=True, update_desktops=False) Update X2GoListSessionsCache for all connected session profiles. | source code

update(self, profile_name, update_sessions=True, update_desktops=False, update_mounts=False) Update X2GoListSessionsCache (i.e. | source code

`X2GoServerSessionList*` instance (or `None`)

list_sessions(self, session_uuid) Retrieve a session list from the current cache content of X2GoListSessionsCache for a given X2GoSession instance (specified by its unique session UUID). | source code

`list` (or `None`)

list_desktops(self, session_uuid) Retrieve a list of available desktop sessions from the current cache content of X2GoListSessionsCache for a given X2GoSession instance (specified by its unique session UUID). | source code

`list` (or `None`)

list_mounts(self, session_uuid) Retrieve a list of mounted client shares from the current cache content of X2GoListSessionsCache for a given X2GoSession instance (specified by its unique session UUID). | source code

`bool`

is_cached(self, profile_name=None, session_uuid=None, cache_type=None) Check if session information is cached. | source code

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

Class Variables
| x2go_listsessions_cache = ``{``}``

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, client_instance, logger=None, loglevel=56)
(Constructor)

source code

x.__init__(...) initializes x; see help(type(x)) for signature

Parameters:
  - `client_instance` (`obj`) - the X2GoClient instance that uses this X2GoListSessionsCache
  - `logger` (`obj`) - you can pass an X2GoLogger object to the X2GoListSessionsCache constructor
  - `loglevel` (`int`) - if no X2GoLogger object has been supplied a new one will be constructed with the given loglevel
Overrides: object.__init__

### delete(self, profile_name)

source code

Remove session list from cache for a given profile.

Parameters:
  - `profile_name` (`str`) - name of profile to operate on

### check_cache(self)

source code

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.

### update_all(self, update_sessions=True, update_desktops=False)

source code

Update X2GoListSessionsCache for all connected session profiles.

Parameters:
  - `update_sessions` (`bool`) - cache recent session lists from all connected servers
  - `update_desktops` (`bool`) - cache recent desktop lists from all connected servers

### update(self, profile_name, update_sessions=True, update_desktops=False, update_mounts=False)

source code

Update X2GoListSessionsCache (i.e. session/desktops) for session profile `profile_name`.

Parameters:
  - `profile_name` (`str`) - name of profile to update
  - `update_sessions` (`bool`) - cache recent session list from server
  - `update_desktops` (`bool`) - cache recent desktop list from server
  - `update_mounts` (`bool`) - cache list of client-side mounts on server

### list_sessions(self, session_uuid)

source code

Retrieve a session list from the current cache content of X2GoListSessionsCache for a given X2GoSession instance (specified by its unique session UUID).

Parameters:
  - `session_uuid` (`str`) - unique identifier of session to query cache for
Returns: `X2GoServerSessionList*` instance (or `None`)
  a data object containing available session information

### list_desktops(self, session_uuid)

source code

Retrieve a list of available desktop sessions from the current cache content of X2GoListSessionsCache for a given X2GoSession instance (specified by its unique session UUID).

Parameters:
  - `session_uuid` (`str`) - unique identifier of session to query cache for
Returns: `list` (or `None`)
  a list of strings representing X2Go desktop sessions available for sharing

### list_mounts(self, session_uuid)

source code

Retrieve a list of mounted client shares from the current cache content of X2GoListSessionsCache for a given X2GoSession instance (specified by its unique session UUID).

Parameters:
  - `session_uuid` (`str`) - unique identifier of session to query cache for
Returns: `list` (or `None`)
  a list of strings representing mounted client shares

### is_cached(self, profile_name=None, session_uuid=None, cache_type=None)

source code

Check if session information is cached.

Parameters:
  - `profile_name` (`str`) - name of profile to update
  - `session_uuid` (`str`) - unique identifier of session to query cache for
Returns: `bool`
  `True` if session information is cached