Package x2go :: Module session :: Class X2GoSession
[frames] | no frames]

Class X2GoSession

source code

object --+
         |
        X2GoSession

Public API class for launching X2Go sessions. Recommended is to manage X2Go sessions from within an X2GoClient instance. However, Python X2Go is designed in a way that it also allows the management of singel X2GoSession instance.

Thus, you can use the X2GoSession class to manually set up X2Go sessions without X2GoClient context (session registry, session list cache, auto-registration of new sessions etc.).

Instance Methods
 
__init__(self, server=None, port=22, control_session=None, use_sshproxy=False, sshproxy_reuse_authinfo=False, profile_id=None, profile_name='UNKNOWN', session_name=None, auto_start_or_resume=False, auto_connect=False, printing=False, allow_mimebox=False, mimebox_extensions=[], mimebox_action='OPEN', allow_share_local_folders=False, share_local_folders=[], restore_shared_local_folders=False, control_backend=<class 'x2go.backends.control._stdout.X2GoControlSessionSTDOUT'>, terminal_backend=<class 'x2go.backends.terminal._stdout.X2GoTerminalSessionSTDO..., info_backend=<class 'x2go.backends.info._stdout.X2GoServerSessionInfoSTDOUT'>, list_backend=<class 'x2go.backends.info._stdout.X2GoServerSessionListSTDOUT'>, proxy_backend=<class 'x2go.backends.proxy._nx3.X2GoProxyNX3'>, settings_backend=<class 'x2go.backends.settings._file.X2GoClientSettingsFILE'>, printing_backend=<class 'x2go.backends.printing._file.X2GoClientPrintingFILE'>, client_rootdir='/home/buildd/.x2goclient', sessions_rootdir='/home/buildd/.x2go', ssh_rootdir='/home/buildd/.ssh', keep_controlsession_alive=False, add_to_known_hosts=False, known_hosts=None, forward_sshagent=False, logger=None, loglevel=56, connected=False, activated=False, virgin=True, running=None, suspended=None, terminated=None, faulty=None, client_instance=None, **params)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
repr(x)
source code
 
__call__(self) source code
 
__del__(self)
Class destructor.
source code
 
get_client_instance(self)
Return parent X2GoClient instance if avaiable.
source code
 
HOOK_on_control_session_death(self)
HOOK method: called if a control session (server connection) has unexpectedly encountered a failure.
source code
 
HOOK_on_failing_SFTP_client(self)
HOOK method: called SFTP client support is unavailable for the session.
source code
 
HOOK_auto_connect(self)
HOOK method: called if the session demands to auto connect.
source code
 
HOOK_session_startup_failed(self)
HOOK method: called if the startup of a session failed.
source code
 
HOOK_desktop_sharing_denied(self)
HOOK method: called if the startup of a shadow session was denied by the other user.
source code
 
HOOK_list_desktops_timeout(self)
HOOK method: called if the x2golistdesktops command generates a timeout due to long execution time.
source code
 
HOOK_no_such_desktop(self, desktop='UNKNOWN')
HOOK method: called if it is tried to connect to a shared desktop that's not available (anymore).
source code
 
HOOK_rforward_request_denied(self, server_port=0)
HOOK method: called if a reverse port forwarding request has been denied.
source code
 
HOOK_forwarding_tunnel_setup_failed(self, chain_host='UNKNOWN', chain_port=0)
HOOK method: called if a port forwarding tunnel setup failed.
source code
 
HOOK_printing_not_available(self)
HOOK method: called if X2Go client-side printing is not available.
source code
 
HOOK_mimebox_not_available(self)
HOOK method: called if the X2Go MIME box is not available.
source code
 
HOOK_foldersharing_not_available(self)
HOOK method: called if X2Go client-side folder-sharing is not available.
source code
 
HOOK_sshfs_not_available(self)
HOOK method: called if the X2Go server denies SSHFS access.
source code
bool
HOOK_check_host_dialog(self, host, port, fingerprint='no fingerprint', fingerprint_type='UNKNOWN')
HOOK method: called if a host check is requested.
source code
 
init_control_session(self)
Initialize a new control session (X2GoControlSession*).
source code
bool
is_master_session(self)
Is this session a/the master session of sessions.
source code
 
set_master_session(self, wait=0, max_wait=20)
Declare this as a master session of a connection channel.
source code
 
unset_master_session(self)
Declare this as a non-master session of a connection channel.
source code
 
set_server(self, server)
Modify server name after X2GoSession has already been initialized.
source code
 
set_port(self, port)
Modify server port after X2GoSession has already been initialized.
source code
 
set_profile_name(self, profile_name)
Modify session profile name after X2GoSession has already been initialized.
source code
bool,str,int
get_session_profile_option(self, option)
Retrieve a specific profile parameter for this session.
source code
 
update_params(self, params)
This method can be used to modify X2GoSession parameters after the X2GoSession instance has already been initialized.
source code
str
get_uuid(self)
Retrieve session UUID hash for this X2GoSession.
source code
str
get_username(self)
After a session has been set up you can query the username the session runs as.
source code
bool
user_is_x2gouser(self, username=None)
Check if a given user is valid server-side X2Go user.
source code
str
get_password(self)
After a session has been setup up you can query the username's password from the session.
source code
tuple
get_server_peername(self)
After a session has been setup up you can query the peername of the host this session is connected to (or about to connect to).
source code
tuple
remote_peername(self)
After a session has been setup up you can query the peername of the host this session is connected to (or about to connect to).
source code
str
get_server_hostname(self)
After a session has been setup up you can query the hostname of the host this session is connected to (or about to connect to).
source code
str
get_server_port(self)
After a session has been setup up you can query the IP socket port used for connecting the remote X2Go server.
source code
str
get_session_name(self)
Retrieve the server-side X2Go session name for this session.
source code
 
set_session_name(self, session_name)
Manipulate the X2GoSession's session name.
source code
obj
get_session_info(self)
Retrieve the server-side X2Go session info object for this session.
source code
str
get_session_cmd(self)
Retrieve the server-side command that is used to start a session on the remote X2Go server.
source code
str
get_session_type(self)
Retrieve the session type of a session (R, D, S or P).
source code
str
get_session_title(self)
Retrieve the session window title of this session.
source code
X2GoControlSession* instance
get_control_session(self)
Retrieve the control session (X2GoControlSession* backend) of this X2GoSession.
source code
bool
has_control_session(self)
Check if this X2GoSession instance has an associated control session.
source code
X2GoControlTerminal* instance
get_terminal_session(self)
Retrieve the terminal session (X2GoTerminalSession* backend) of this X2GoSession.
source code
bool
has_terminal_session(self)
Check if this X2GoSession instance has an associated terminal session.
source code
bool
is_associated(self)
Check if this X2GoSession instance has an associated terminal session.
source code
bool
check_host(self)
Provide a host check mechanism.
source code
bool
uses_sshproxy(self)
Check if a session is configured to use an intermediate SSH proxy server.
source code
bool
reuses_sshproxy_authinfo(self)
Check if a session is configured to re-use the X2Go session's password / key for proxy authentication, as well.
source code
bool
can_sshproxy_auto_connect(self)
Check if a session's SSH proxy (if used) is configured adequately to be able to auto-connect to the SSH proxy server (e.g.
source code
bool
can_auto_connect(self)
Check if a session is configured adequately to be able to auto-connect to the X2Go server (e.g.
source code
bool
do_auto_connect(self, redirect_to_client=True)
Automatically connect this session.
source code
 
connect(self, username=None, password=None, passphrase=None, add_to_known_hosts=None, force_password_auth=None, look_for_keys=None, allow_agent=None, use_sshproxy=None, sshproxy_user=None, sshproxy_password=None, sshproxy_passphrase=None, sshproxy_force_password_auth=None, sshproxy_reuse_authinfo=None)
Connects to the X2GoSession's server host.
source code
bool
disconnect(self)
Disconnect this X2GoSession instance.
source code
 
retrieve_server_features(self)
Query the X2Go server for a list of supported features.
source code
list
get_server_features(self)
Return a list of X2Go server-sides features (supported functionalities).
source code
bool
has_server_feature(self, feature)
Check if feature is a present feature of the connected X2Go server.
source code
 
set_session_window_title(self, title='')
Modify session window title.
source code
 
raise_session_window(self)
Try to lift the session window above all other windows and bring it to focus.
source code
 
set_print_action(self, print_action, **kwargs)
If X2Go client-side printing is enable within this X2Go session you can use this method to alter the way how incoming print spool jobs are handled/processed.
source code
bool
is_alive(self)
Find out if this X2Go session is still alive (that is: connected to the server).
source code
 
clean_sessions(self, destroy_terminals=True, published_applications=False)
Clean all running sessions for the authenticated user on the remote X2Go server.
source code
X2GoServerSessionList* instance or list
list_sessions(self, raw=False)
List all sessions on the remote X2Go server that are owned by the authenticated user
source code
list
list_desktops(self, raw=False)
List X2Go desktops sessions available for desktop sharing on the remote X2Go server.
source code
list
list_mounts(self, raw=False)
Use the X2Go session registered under session_uuid to retrieve its list of mounted client shares for that session.
source code
 
update_status(self, session_list=None, force_update=False)
Update the current session status.
source code
bool
is_published_applications_provider(self)
Returns true if this session runs in published applications mode.
source code
list
get_published_applications(self, lang=None, refresh=False, raw=False, very_raw=False, max_no_submenus=10)
Return a list of published menu items from the X2Go server for session type published applications.
source code
 
exec_published_application(self, exec_name, timeout=20)
Execute an application while in published application mode.
source code
bool
do_auto_start_or_resume(self, newest=True, oldest=False, all_suspended=False, start=True, redirect_to_client=True)
Automatically start or resume this session, if already associated with a server session.
source code
 
reset_progress_status(self)
Reset session startup/resumption progress status.
source code
int
get_progress_status(self)
Retrieve session startup/resumption progress status.
source code
bool
resume(self, session_name=None, session_list=None, cmd=None, progress_event=None)
Resume or continue a suspended / running X2Go session on the remote X2Go server.
source code
bool
start(self, cmd=None, progress_event=None)
Start a new X2Go session on the remote X2Go server.
source code
bool
share_desktop(self, desktop=None, user=None, display=None, share_mode=0, check_desktop_list=True, progress_event=None)
Share an already running X2Go session on the remote X2Go server locally.
source code
bool
is_desktop_session(self)
Test if this X2Go session is a desktop session.
source code
bool
is_rootless_session(self)
Test if this X2Go session is a rootless session.
source code
bool
is_shadow_session(self)
Test if this X2Go session is a desktop sharing (aka shadow) session.
source code
bool
is_pubapp_session(self)
Test if this X2Go session is a published applications session.
source code
bool
suspend(self)
Suspend this X2Go session.
source code
bool
terminate(self)
Terminate this X2Go session.
source code
str
get_profile_name(self)
Retrieve the profile name of this X2GoSession instance.
source code
str
get_profile_id(self)
Retrieve the profile ID of this X2GoSession instance.
source code
bool
session_ok(self)
Test if this X2GoSession is in a healthy state.
source code
str
color_depth_from_session_name(self)
Extract color depth from session name.
source code
bool
is_color_depth_ok(self)
Check if this session will display properly with the local screen's color depth.
source code
bool
is_connected(self)
Test if the X2GoSession's control session is connected to the remote X2Go server.
source code
bool
is_running(self, update_status=False)
Test if the X2GoSession's terminal session is up and running.
source code
bool
is_suspended(self, update_status=False)
Test if the X2GoSession's terminal session is in suspended state.
source code
bool
has_terminated(self, update_status=False)
Test if the X2GoSession's terminal session has terminated.
source code
bool
is_folder_sharing_available(self)
Test if the remote session allows sharing of local folders with the session.
source code
bool
share_local_folder(self, local_path=None, folder_name=None, update_exported_folders=True)
Share a local folder with this registered X2Go session.
source code
bool
share_all_local_folders(self, update_exported_folders=True)
Share all local folders configured to be mounted within this X2Go session.
source code
bool
unshare_local_folder(self, local_path=None, update_exported_folders=True)
Unshare a local folder that is mounted within this X2Go session.
source code
bool
unshare_all_local_folders(self, force_all=False, update_exported_folders=True)
Unshare all local folders mounted within this X2Go session.
source code
list
get_shared_folders(self, check_list_mounts=False, mounts=None)
Get a list of local folders mounted within this X2Go session from this client.
source code
 
session_cleanup(self)
Clean up X2Go session.
source code
bool
is_locked(self)
Test if the session is lock at the moment.
source code

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

Properties

Inherited from object: __class__

Method Details

__init__(self, server=None, port=22, control_session=None, use_sshproxy=False, sshproxy_reuse_authinfo=False, profile_id=None, profile_name='UNKNOWN', session_name=None, auto_start_or_resume=False, auto_connect=False, printing=False, allow_mimebox=False, mimebox_extensions=[], mimebox_action='OPEN', allow_share_local_folders=False, share_local_folders=[], restore_shared_local_folders=False, control_backend=<class 'x2go.backends.control._stdout.X2GoControlSessionSTDOUT'>, terminal_backend=<class 'x2go.backends.terminal._stdout.X2GoTerminalSessionSTDO..., info_backend=<class 'x2go.backends.info._stdout.X2GoServerSessionInfoSTDOUT'>, list_backend=<class 'x2go.backends.info._stdout.X2GoServerSessionListSTDOUT'>, proxy_backend=<class 'x2go.backends.proxy._nx3.X2GoProxyNX3'>, settings_backend=<class 'x2go.backends.settings._file.X2GoClientSettingsFILE'>, printing_backend=<class 'x2go.backends.printing._file.X2GoClientPrintingFILE'>, client_rootdir='/home/buildd/.x2goclient', sessions_rootdir='/home/buildd/.x2go', ssh_rootdir='/home/buildd/.ssh', keep_controlsession_alive=False, add_to_known_hosts=False, known_hosts=None, forward_sshagent=False, logger=None, loglevel=56, connected=False, activated=False, virgin=True, running=None, suspended=None, terminated=None, faulty=None, client_instance=None, **params)
(Constructor)

source code 

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

Parameters:
  • server (str) - hostname of X2Go server
  • control_session (X2GoControlSession* instance) - an already initialized X2GoControlSession* instance
  • use_sshproxy (bool) - for communication with X2Go server use an SSH proxy host
  • sshproxy_reuse_authinfo (bool) - for proxy authentication re-use the X2Go session's password / key file
  • profile_id (str) - profile ID
  • profile_name (str) - profile name
  • session_name (str) - session name (if available)
  • auto_start_or_resume (bool) - automatically start a new or resume latest session after connect
  • auto_connect (bool) - call a hook method that handles connecting the session profile automatically after a session for this profile has been registered
  • printing (bool) - enable X2Go printing
  • allow_mimebox (bool) - enable X2Go MIME box support
  • mimebox_extensions (list) - whitelist of allowed X2Go MIME box extensions
  • mimebox_action (X2GoMimeBoxAction* or str) - action for incoming X2Go MIME box files
  • allow_share_local_folders (bool) - enable local folder sharing support
  • share_local_folders (list) - list of local folders to share with the remote X2Go session
  • restore_shared_local_folders (bool) - store actual list of shared local folders after session has been suspended or terminated
  • control_backend (class) - X2Go control session backend to use
  • terminal_backend (class) - X2Go terminal session backend to use
  • info_backend (class) - X2Go session info backend to use
  • list_backend (class) - X2Go session list backend to use
  • proxy_backend (class) - X2Go proxy backend to use
  • settings_backend (class) - X2Go client settings backend to use
  • printing_backend (class) - X2Go client printing backend to use
  • client_rootdir (str) - client base dir (default: ~/.x2goclient)
  • sessions_rootdir (str) - sessions base dir (default: ~/.x2go)
  • ssh_rootdir (str) - ssh base dir (default: ~/.ssh)
  • keep_controlsession_alive - On last X2GoSession.disconnect() keep the associated X2GoControlSession* instance alive? @ŧype keep_controlsession_alive: bool
  • add_to_known_hosts (bool) - Auto-accept server host validity?
  • known_hosts (str) - the underlying Paramiko/SSH systems known_hosts file
  • forward_sshagent (bool) - forward SSH agent authentication requests to the SSH agent on the X2Go client-side
  • connected (bool) - manipulate session state »connected« by giving a pre-set value
  • activated (bool) - normal leave this untouched, an activated session is a session that is about to be used
  • virgin (bool) - manipulate session state »virgin« by giving a pre-set value
  • running (bool) - manipulate session state »running« by giving a pre-set value
  • suspended (bool) - manipulate session state »suspended« by giving a pre-set value
  • terminated (bool) - manipulate session state »terminated« by giving a pre-set value
  • faulty (bool) - manipulate session state »faulty« by giving a pre-set value
  • client_instance (X2GoClient instance) - if available, the underlying X2GoClient instance
  • params (dict) - further control session, terminal session and SSH proxy class options
Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

get_client_instance(self)

source code 

Return parent X2GoClient instance if avaiable.

return: X2GoClient instance this session is associated with rtype: obj

HOOK_rforward_request_denied(self, server_port=0)

source code 

HOOK method: called if a reverse port forwarding request has been denied.

Parameters:
  • server_port (str) - remote server port (starting point of reverse forwarding tunnel)

HOOK_forwarding_tunnel_setup_failed(self, chain_host='UNKNOWN', chain_port=0)

source code 

HOOK method: called if a port forwarding tunnel setup failed.

Parameters:
  • chain_host (str) - hostname of chain host (forwarding tunnel end point)
  • chain_port (str) - port of chain host (forwarding tunnel end point)

HOOK_check_host_dialog(self, host, port, fingerprint='no fingerprint', fingerprint_type='UNKNOWN')

source code 

HOOK method: called if a host check is requested. This hook has to either return True (default) or False.

Parameters:
  • host (str) - SSH server name to validate
  • port (int) - SSH server port to validate
  • fingerprint (str) - the server's fingerprint
  • fingerprint_type (str) - finger print type (like RSA, DSA, ...)
Returns: bool
if host validity is verified, this hook method should return True

is_master_session(self)

source code 

Is this session a/the master session of sessions.

The master session is the session has been launched first for a specific connection, it also is _the_ session that controls the client-side shared folders.

If this X2GoSession instance is a standalone instance (without parent X2GoClient) this method will always return True.

Returns: bool
returns True if this session is a master session

set_master_session(self, wait=0, max_wait=20)

source code 

Declare this as a master session of a connection channel.

This method gets called by the X2GoSessionRegistry while sessions are starting or resuming and it relies on an already set-up terminal session.

Parameters:
  • wait (int) - wait for <wait> seconds before sharing local folders via the new master session of the corresponding session profile.
  • max_wait (int) - wait for <max_wait> seconds for the terminal session to appear

set_server(self, server)

source code 

Modify server name after X2GoSession has already been initialized.

Parameters:
  • server (str) - new server name

set_port(self, port)

source code 

Modify server port after X2GoSession has already been initialized.

Parameters:
  • port (int) - socket port of server to connect to

set_profile_name(self, profile_name)

source code 

Modify session profile name after X2GoSession has already been initialized.

Parameters:
  • profile_name (str) - new session profile name

get_session_profile_option(self, option)

source code 

Retrieve a specific profile parameter for this session.

Parameters:
  • option (str) - name of a specific profile option to be queried.
Returns: bool,str,int
value for profile option <option>
Raises:

update_params(self, params)

source code 

This method can be used to modify X2GoSession parameters after the X2GoSession instance has already been initialized.

Parameters:
  • params (dict) - a Python dictionary with X2GoSession parameters

get_uuid(self)

source code 

Retrieve session UUID hash for this X2GoSession.

Returns: str
the session's UUID hash

get_username(self)

source code 

After a session has been set up you can query the username the session runs as.

Returns: str
the remote username the X2Go session runs as

user_is_x2gouser(self, username=None)

source code 

Check if a given user is valid server-side X2Go user.

Parameters:
  • username (str) - username to check validity for
Returns: bool
True if the username is allowed to launch X2Go sessions

get_password(self)

source code 

After a session has been setup up you can query the username's password from the session.

Returns: str
the username's password

get_server_peername(self)

source code 

After a session has been setup up you can query the peername of the host this session is connected to (or about to connect to).

Returns: tuple
the address of the server the X2Go session is connected to (as an (addr,port) tuple)

remote_peername(self)

source code 

After a session has been setup up you can query the peername of the host this session is connected to (or about to connect to).

Returns: tuple
the address of the server the X2Go session is connected to (as an (addr,port) tuple)

get_server_hostname(self)

source code 

After a session has been setup up you can query the hostname of the host this session is connected to (or about to connect to).

Returns: str
the hostname of the server the X2Go session is connected to / about to connect to

get_server_port(self)

source code 

After a session has been setup up you can query the IP socket port used for connecting the remote X2Go server.

Returns: str
the server-side IP socket port that is used by the X2Go session to connect to the server

get_session_name(self)

source code 

Retrieve the server-side X2Go session name for this session.

Returns: str
X2Go session name

set_session_name(self, session_name)

source code 

Manipulate the X2GoSession's session name.

Parameters:
  • session_name (str) - the new session name to be set

get_session_info(self)

source code 

Retrieve the server-side X2Go session info object for this session.

Returns: obj
X2Go session info

get_session_cmd(self)

source code 

Retrieve the server-side command that is used to start a session on the remote X2Go server.

Returns: str
server-side session command

get_session_type(self)

source code 

Retrieve the session type of a session (R, D, S or P).

  • R: rootless session
  • D: desktop session
  • S: shadow session
  • P: session in published applications mode
Returns: str
session type

get_session_title(self)

source code 

Retrieve the session window title of this session.

Returns: str
session window title

get_control_session(self)

source code 

Retrieve the control session (X2GoControlSession* backend) of this X2GoSession.

Returns: X2GoControlSession* instance
the X2GoSession's control session

has_control_session(self)

source code 

Check if this X2GoSession instance has an associated control session.

Returns: bool
returns True if this X2GoSession has a control session associated to itself

get_terminal_session(self)

source code 

Retrieve the terminal session (X2GoTerminalSession* backend) of this X2GoSession.

Returns: X2GoControlTerminal* instance
the X2GoSession's terminal session

has_terminal_session(self)

source code 

Check if this X2GoSession instance has an associated terminal session.

Returns: bool
returns True if this X2GoSession has a terminal session associated to itself

is_associated(self)

source code 

Check if this X2GoSession instance has an associated terminal session.

Returns: bool
returns True if this X2GoSession has a terminal session associated to itself

check_host(self)

source code 

Provide a host check mechanism. This method basically calls the HOOK_check_host_dialog() method which by itself calls the X2GoClient.HOOK_check_host_dialog() method. Make sure you override any of these to enable user interaction on X2Go server validity checks.

Returns: bool
returns True if an X2Go server host is valid for authentication

uses_sshproxy(self)

source code 

Check if a session is configured to use an intermediate SSH proxy server.

Returns: bool
returns True if the session is configured to use an SSH proxy, False otherwise.

reuses_sshproxy_authinfo(self)

source code 

Check if a session is configured to re-use the X2Go session's password / key for proxy authentication, as well.

Returns: bool
returns True if the session is configured to re-use session password / key for proxy authentication

can_sshproxy_auto_connect(self)

source code 

Check if a session's SSH proxy (if used) is configured adequately to be able to auto-connect to the SSH proxy server (e.g. by public key authentication).

Returns: bool
returns True if the session's SSH proxy can auto-connect, False otherwise, None if no SSH proxy is used for this session, None is returned.

can_auto_connect(self)

source code 

Check if a session is configured adequately to be able to auto-connect to the X2Go server (e.g. public key authentication).

Returns: bool
returns True if the session can auto-connect, False otherwise, None if no control session has been set up yet.

do_auto_connect(self, redirect_to_client=True)

source code 

Automatically connect this session.

Returns: bool
Return success (or failure) of connecting this sessions

connect(self, username=None, password=None, passphrase=None, add_to_known_hosts=None, force_password_auth=None, look_for_keys=None, allow_agent=None, use_sshproxy=None, sshproxy_user=None, sshproxy_password=None, sshproxy_passphrase=None, sshproxy_force_password_auth=None, sshproxy_reuse_authinfo=None)

source code 

Connects to the X2GoSession's server host. This method basically wraps around the X2GoControlSession*.connect() method.

Parameters:
  • username (str) - the username for the X2Go server that is going to be connected to (as a last minute way of changing the session username)
  • password (str) - the user's password for the X2Go server that is going to be connected to
  • passphrase (str) - a passphrase to use for unlocking a private key in case the password is already needed for two-factor authentication
  • add_to_known_hosts (bool) - non-paramiko option, if True paramiko.AutoAddPolicy() is used as missing-host-key-policy. If set to False paramiko.RejectPolicy() is used
  • force_password_auth (bool) - disable SSH pub/priv key authentication mechanisms completely
  • look_for_keys (bool) - set to True to enable searching for discoverable private key files in ~/.ssh/
  • allow_agent (bool) - set to True to enable connecting to a local SSH agent for acquiring authentication information
  • use_sshproxy (bool) - use an SSH proxy host for connecting the target X2Go server
  • sshproxy_reuse_authinfo (bool) - for proxy authentication re-use the X2Go session's password / key file
  • sshproxy_user (str) - username for authentication against the SSH proxy host
  • sshproxy_password (str) - password for authentication against the SSH proxy host
  • sshproxy_passphrase (str) - a passphrase to use for unlocking a private key needed for the SSH proxy host in case the sshproxy_password is already needed for two-factor authentication
  • sshproxy_force_password_auth (bool) - enforce password authentication even is a key(file) is present
Returns:
returns True is the connection to the X2Go server has been successful @rtype bool
Raises:

disconnect(self)

source code 

Disconnect this X2GoSession instance.

Returns: bool
returns True if the disconnect operation has been successful

get_server_features(self)

source code 

Return a list of X2Go server-sides features (supported functionalities).

Returns: list
a list of X2Go feature names

has_server_feature(self, feature)

source code 

Check if feature is a present feature of the connected X2Go server.

Parameters:
  • feature (str) - an X2Go server feature as found in $SHAREDIR/x2go/feature.d/*
Returns: bool
returns True if the feature is present

set_session_window_title(self, title='')

source code 

Modify session window title. If the session ID does not occur in the given title, it will be prepended, so that every X2Go session window always contains the X2Go session ID of that window.

Parameters:
  • title (str) - new title for session window

set_print_action(self, print_action, **kwargs)

source code 

If X2Go client-side printing is enable within this X2Go session you can use this method to alter the way how incoming print spool jobs are handled/processed.

For further information, please refer to the documentation of the X2GoClient.set_session_print_action() method.

Parameters:
  • print_action (str or instance) - one of the named above print actions, either as string or class instance
  • kwargs (dict) - additional information for the given print action (print action arguments), for possible print action arguments and their values see each individual print action class

is_alive(self)

source code 

Find out if this X2Go session is still alive (that is: connected to the server).

Returns: bool
returns True if the server connection is still alive

clean_sessions(self, destroy_terminals=True, published_applications=False)

source code 

Clean all running sessions for the authenticated user on the remote X2Go server.

Parameters:
  • destroy_terminals (bool) - destroy associated terminal sessions
  • published_applications (bool) - clean sessions that are published applications providers, too

list_sessions(self, raw=False)

source code 

List all sessions on the remote X2Go server that are owned by the authenticated user

Parameters:
  • raw (bool) - if True the output of this method equals the output of the server-side x2golistsessions command
Returns: X2GoServerSessionList* instance or list
a session list (as data object or list of strings when called with raw=True option)

list_desktops(self, raw=False)

source code 

List X2Go desktops sessions available for desktop sharing on the remote X2Go server.

Parameters:
  • raw (bool) - if True the output of this method equals the output of the server-side x2golistdesktops command
Returns: list
a list of strings representing available desktop sessions

list_mounts(self, raw=False)

source code 

Use the X2Go session registered under session_uuid to retrieve its list of mounted client shares for that session.

Parameters:
  • raw (bool) - output the list of mounted client shares in X2Go's raw x2golistmounts format
Returns: list
a list of strings representing mounted client shares for this session

update_status(self, session_list=None, force_update=False)

source code 

Update the current session status. The X2GoSession instance uses an internal session status cache that allows to query the session status without the need of retrieving data from the remote X2Go server for each query.

The session status (if initialized properly with the X2GoClient constructor gets updated in regularly intervals.

In case you use the X2GoSession class in standalone instances (that is: without being embedded into an X2GoSession context) then run this method in regular intervals to make sure the X2GoSession's internal status cache information is always up-to-date.

Parameters:
  • session_list (X2GoServerSessionList* instance) - provide an X2GoServerSessionList* that refers to X2Go sessions we want to update. This option is mainly for reducing server/client traffic.
  • force_update (bool) - force a session status update, if if the last update is less then 1 second ago
Raises:
  • Exception - any exception is passed through in case the session disconnected surprisingly or has been marked as faulty

is_published_applications_provider(self)

source code 

Returns true if this session runs in published applications mode.

Returns: bool
returns True if this session is a provider session for published applications.

get_published_applications(self, lang=None, refresh=False, raw=False, very_raw=False, max_no_submenus=10)

source code 

Return a list of published menu items from the X2Go server for session type published applications.

Parameters:
  • lang (str) - locale/language identifier
  • refresh (bool) - force reload of the menu tree from X2Go server
  • raw (bool) - retrieve a raw output of the server list of published applications
  • very_raw (bool) - retrieve a very raw output of the server list of published applications (as-is output of x2gogetapps script)
Returns: list
A list of dict elements. Each dict elements has a desktop key containing the text output of a .desktop file and an icon key which contains the desktop icon data base64 encoded

exec_published_application(self, exec_name, timeout=20)

source code 

Execute an application while in published application mode.

Parameters:
  • exec_name (str) - command to execute on server

do_auto_start_or_resume(self, newest=True, oldest=False, all_suspended=False, start=True, redirect_to_client=True)

source code 

Automatically start or resume this session, if already associated with a server session. Otherwise resume a server-side available/suspended session (see options to declare which session to resume). If no session is available for resuming a new session will be launched.

Sessions in published applications mode are not resumed/started by this method.

Parameters:
  • newest (bool) - if resuming, only resume newest/youngest session
  • oldest (bool) - if resuming, only resume oldest session
  • all_suspended (bool) - if resuming, resume all suspended sessions
  • start (bool) - is no session is to be resumed, start a new session
  • redirect_to_client (bool) - redirect this call to the X2GoClient instance (if available) to allow frontend interaction
Returns: bool
returns success (or failure) of starting/resuming this sessions

get_progress_status(self)

source code 

Retrieve session startup/resumption progress status.

Returns: int
returns an int value between 0 and 100 reflecting the session startup/resumption status

resume(self, session_name=None, session_list=None, cmd=None, progress_event=None)

source code 

Resume or continue a suspended / running X2Go session on the remote X2Go server.

Parameters:
  • session_name (str) - the server-side name of an X2Go session
  • session_list (dict) - a session list to avoid a server-side session list query
  • cmd (str) - if starting a new session, manually hand over the command to be launched in the new session
  • progress_event (obj) - a thread.Event object that notifies a status object like the one in utils.ProgressStatus.
Returns: bool
returns True if resuming the session has been successful, False otherwise
Raises:
  • Exception - any exception that occurs during published application menu retrieval is passed through

start(self, cmd=None, progress_event=None)

source code 

Start a new X2Go session on the remote X2Go server.

Parameters:
  • cmd (str) - manually hand over the command that is to be launched in the new session
  • progress_event (obj) - a thread.Event object that notifies a status object like the one in utils.ProgressStatus.
Returns: bool
returns True if starting the session has been successful, False otherwise

share_desktop(self, desktop=None, user=None, display=None, share_mode=0, check_desktop_list=True, progress_event=None)

source code 

Share an already running X2Go session on the remote X2Go server locally. The shared session may be either owned by the same user or by a user that grants access to his/her desktop session by the local user.

Parameters:
  • desktop (str) - desktop ID of a sharable desktop in format <user>@<display>
  • user (str) - user name and display number can be given separately, here give the name of the user who wants to share a session with you.
  • display (str) - user name and display number can be given separately, here give the number of the display that a user allows you to be shared with.
  • share_mode (int) - desktop sharing mode, 0 is VIEW-ONLY, 1 is FULL-ACCESS.
  • check_desktop_list (bool) - check if the given desktop is available on the X2Go server; handle with care as the server-side x2golistdesktops command might block client I/O.
  • progress_event (obj) - a thread.Event object that notifies a status object like the one in utils.ProgressStatus.
Returns: bool
returns True if starting the session has been successful, False otherwise
Raises:
  • X2GoDesktopSharingException - if a given desktop ID does not specify an available desktop session
  • X2GoSessionException - if the available desktop session appears to be dead, in fact

is_desktop_session(self)

source code 

Test if this X2Go session is a desktop session.

Returns: bool
True if this session is of session type desktop ('D').

is_rootless_session(self)

source code 

Test if this X2Go session is a rootless session.

Returns: bool
True if this session is of session type rootless ('R').

is_shadow_session(self)

source code 

Test if this X2Go session is a desktop sharing (aka shadow) session.

Returns: bool
True if this session is of session type shadow ('S').

is_pubapp_session(self)

source code 

Test if this X2Go session is a published applications session.

Returns: bool
True if this session is of session type published applications ('P').

suspend(self)

source code 

Suspend this X2Go session.

Returns: bool
returns True if suspending the session has been successful, False otherwise
Raises:

terminate(self)

source code 

Terminate this X2Go session.

Returns: bool
returns True if terminating the session has been successful, False otherwise
Raises:

get_profile_name(self)

source code 

Retrieve the profile name of this X2GoSession instance.

Returns: str
X2Go client profile name of the session

get_profile_id(self)

source code 

Retrieve the profile ID of this X2GoSession instance.

Returns: str
the session profile's id

session_ok(self)

source code 

Test if this X2GoSession is in a healthy state.

Returns: bool
True if session is ok, False otherwise

color_depth_from_session_name(self)

source code 

Extract color depth from session name.

Returns: str
the session's color depth (as found in the session name)

is_color_depth_ok(self)

source code 

Check if this session will display properly with the local screen's color depth.

Returns: bool
True if the session will display on this client screen, False otherwise. If no terminal session is yet registered with this session, None is returned.

is_connected(self)

source code 

Test if the X2GoSession's control session is connected to the remote X2Go server.

Returns: bool
True if session is connected, False otherwise

is_running(self, update_status=False)

source code 

Test if the X2GoSession's terminal session is up and running.

Returns: bool
True if session is running, False otherwise

is_suspended(self, update_status=False)

source code 

Test if the X2GoSession's terminal session is in suspended state.

Returns: bool
True if session is suspended, False otherwise

has_terminated(self, update_status=False)

source code 

Test if the X2GoSession's terminal session has terminated.

Returns: bool
True if session has terminated, False otherwise

is_folder_sharing_available(self)

source code 

Test if the remote session allows sharing of local folders with the session.

Returns: bool
returns True if local folder sharing is available in the remote session

share_local_folder(self, local_path=None, folder_name=None, update_exported_folders=True)

source code 

Share a local folder with this registered X2Go session.

Parameters:
  • local_path (str) - the full path to an existing folder on the local file system
  • folder_name (str) - synonymous to local_path
  • update_exported_folders (bool) - do an update of the session profile option ,,export'' after the operation
Returns: bool
returns True if the local folder has been successfully mounted within this X2Go session
Raises:

share_all_local_folders(self, update_exported_folders=True)

source code 

Share all local folders configured to be mounted within this X2Go session.

Parameters:
  • update_exported_folders (bool) - do an update of the session profile option ,,export'' after the operation
Returns: bool
returns True if all local folders could be successfully mounted inside this X2Go session

unshare_local_folder(self, local_path=None, update_exported_folders=True)

source code 

Unshare a local folder that is mounted within this X2Go session.

Parameters:
  • local_path (str) - the full path to an existing folder on the local file system that is mounted in this X2Go session and shall be unmounted
  • update_exported_folders (bool) - do an update of the session profile option ,,export'' after the operation
Returns: bool
returns True if all local folders could be successfully unmounted inside this X2Go session
Raises:

unshare_all_local_folders(self, force_all=False, update_exported_folders=True)

source code 

Unshare all local folders mounted within this X2Go session.

Parameters:
  • force_all (bool) - Really unmount _all_ shared folders, including the print spool folder and the MIME box spool dir (not recommended).
  • update_exported_folders (bool) - do an update of the session profile option ,,export'' after the operation
Returns: bool
returns True if all local folders could be successfully unmounted inside this X2Go session
Raises:

get_shared_folders(self, check_list_mounts=False, mounts=None)

source code 

Get a list of local folders mounted within this X2Go session from this client.

Parameters:
  • check_list_mounts (bool) - if set to True the list of shared folders is referenced against the latest status of the server-side mount list.
  • mounts (dict) - a server-side dictionary of session name keys and lists of mounted shares (server-side mount points)
Returns: list
returns a list of those local folder names that are mounted with this X2Go session.

is_locked(self)

source code 

Test if the session is lock at the moment. This normally occurs if there is some action running that will result in a session status change.

Returns: bool
returns True if the session is locked