Package x2go :: Package backends :: Package terminal :: Module plain :: Class X2GoTerminalSession

[frames] | no frames]

# Class X2GoTerminalSession

source code

    object --+
             |
            X2GoTerminalSession

Class for managing X2Go terminal sessions on a remote X2Go server via Paramiko/SSH.

With the x2go.backends.terminal.plain.X2GoTerminalSession class you can start new X2Go sessions, resume suspended sessions or suspend resp. terminate currently running sessions on a connected X2Go server.

An x2go.backends.terminal.plain.X2GoTerminalSession object uses two main data structure classes:

- X2GoSessionParams: stores all parameters that have been passed to the constructor method.
- `X2GoServerSessionInfo*` backend class: when starting or resuming a session, an object of this class will be used to store all information retrieved from the X2Go server.

The terminal session instance works closely together (i.e. depends on) a connected control session instance (e.g. x2go.backends.control.plain.X2GoControlSession). You never should use either of them as a standalone instance. Both, control session and terminal session(s) get managed/controlled via X2GoSession instances.

Instance Methods

__init__(self, control_session, session_info=None, geometry=`'``800x600``'`, depth=24, link=`'``adsl``'`, pack=`'``16m-jpeg-9``'`, dpi=`'````'`, cache_type=`'``unix-kde``'`, kbtype=`'``null/null``'`, kblayout=`'``null``'`, kbvariant=`'``null``'`, clipboard=`'``both``'`, session_type=`'``application``'`, snd_system=`'``pulse``'`, snd_port=4713, cmd=None, published_applications=False, set_session_title=False, session_title=`'````'`, applications=`[``]`, rdp_server=None, rdp_options=None, xdmcp_server=None, convert_encoding=False, server_encoding=`'``UTF-8``'`, client_encoding=`'``UTF-8``'`, rootdir=None, profile_name=`'``UNKNOWN``'`, profile_id=`'``20171103011108301208``'`, print_action=None, print_action_args=`{``}`, info_backend=`'``PLAIN``'`, list_backend=`'``PLAIN``'`, proxy_backend=`'``NX3``'`, proxy_options=`{``}`, printing_backend=`'``FILE``'`, client_rootdir=`'``/sbuild-nonexistent/.x2goclient``'`, sessions_rootdir=`'``/sbuild-nonexistent/.x2go``'`, session_instance=None, logger=None, loglevel=56)
Initialize an X2Go session.

source code

__del__(self) Tidy up if terminal session gets destructed. | source code

`str`

get_session_name(self) Retrieve the X2Go session's name from the session info object. | source code

`X2GoServerSessionInfo*`

get_session_info(self) Retrieve the X2Go session's session info object. | source code

`str`

get_session_cmd(self) Retrieve the X2Go session's command as stored in the session parameter object. | source code

`str`

get_session_type(self) Retrieve the X2Go session's session type as stored in the session parameter object. | source code

start_sound(self) Initialize Paramiko/SSH reverse forwarding tunnel for X2Go sound. | source code

start_sshfs(self) Initialize Paramiko/SSH reverse forwarding tunnel for X2Go folder sharing. | source code

stop_sound(self) Shutdown (pause) Paramiko/SSH reverse forwarding tunnel for X2Go sound. | source code

stop_sshfs(self) Shutdown (pause) Paramiko/SSH reverse forwarding tunnel for X2Go folder sharing. | source code

start_printing(self) Initialize X2Go print spooling. | source code

set_print_action(self, print_action, **kwargs) Set a print action for the next incoming print jobs. | source code

stop_printing(self) Shutdown (pause) the X2Go Print Queue thread. | source code

`str`

get_printing_spooldir(self) Return the server-side printing spooldir path. | source code

start_mimebox(self, mimebox_extensions=`[``]`, mimebox_action=None) Initialize the X2Go MIME box. | source code

set_mimebox_action(self, mimebox_action, **kwargs) Set a MIME box action for the next incoming MIME jobs. | source code

stop_mimebox(self) Shutdown (pause) the X2Go MIME box Queue thread. | source code

`str`

get_mimebox_spooldir(self) Return the server-side MIME box spooldir path. | source code

start_telekinesis(self) Initialize Telekinesis client for X2Go. | source code

`bool`

is_session_info_protected(self) Test if this terminal's session info object is write-protected. | source code

session_info_protect(self) Protect this terminal session's info object against updates. | source code

session_info_unprotect(self) Allow session info updates from within the list_sessions method of the control session. | source code

`bool`

share_local_folder(self, local_path=None, folder_type=`'``disk``'`) Share a local folder with the X2Go session. | source code

`bool`

unshare_all_local_folders(self) Unshare all local folders mount in the X2Go session. | source code

`bool`

unshare_local_folder(self, local_path) Unshare local folder given as <local_path> from X2Go session. | source code

`int`

color_depth(self) Retrieve the session's color depth. | source code

auto_session_window_title(self, dont_set=False) Automatically generate an appropriate human-readable session window title. | source code

find_session_window(self, timeout=60) Try for <timeout> seconds to find the X2Go session window of this terminal session. | source code

update_session_window_file(self) Create a file that contains information on the session window. | source code

set_session_window_title(self, title, timeout=60) Modify the session window title. | source code

raise_session_window(self, timeout=60) Try for <timeout> seconds to raise the X2Go session window of this terminal session to the top and bring it to focus. | source code

`bool`

has_command(self, cmd) ,,Guess'' if the command `<cmd>` exists on the X2Go server and is executable. | source code

`tuple` of `str`

run_command(self, cmd=None, env=`{``}`) Run a command in this session. | source code

`bool`

is_desktop_session(self) Is this (terminal) session a desktop session? | source code

`bool`

is_published_applications_provider(self) Is this (terminal) session a published applications provider? | source code

`bool`

set_keyboard(self, layout=`'``null``'`, variant=`'``null``'`) Set the keyboard layout and variant for this (running) session. | source code

exec_published_application(self, exec_name, timeout=20, env=`{``}`) Executed a published application. | source code

`bool`

ok(self) X2Go session OK? | source code

`bool`

is_running(self) X2Go session running? | source code

`bool`

is_suspended(self) X2Go session suspended? | source code

`bool`

is_connected(self) X2Go session connected? | source code

`bool`

start(self) Start a new X2Go session. | source code

`bool`

resume(self) Resume a running/suspended X2Go session. | source code

`bool`

suspend(self) Suspend this X2Go (terminal) session. | source code

`bool`

terminate(self) Terminate this X2Go (terminal) session. | source code

release_proxy(self) Let the X2Go proxy command cleanly die away... | source code

release_telekinesis(self) Let the attached Telekinesis client cleanly die away... | source code

post_terminate_cleanup(self) Do some cleanup after this session has terminated. | source code

`bool`

is_rootless_session(self) Test if this terminal session is a rootless session. | source code

`bool`

is_shadow_session(self) Test if this terminal session is a desktop sharing (aka shadow) session. | source code

`bool`

is_pubapp_session(self) Test if this terminal session is a published applications session. | source code

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

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, control_session, session_info=None, geometry=`'``800x600``'`, depth=24, link=`'``adsl``'`, pack=`'``16m-jpeg-9``'`, dpi=`'````'`, cache_type=`'``unix-kde``'`, kbtype=`'``null/null``'`, kblayout=`'``null``'`, kbvariant=`'``null``'`, clipboard=`'``both``'`, session_type=`'``application``'`, snd_system=`'``pulse``'`, snd_port=4713, cmd=None, published_applications=False, set_session_title=False, session_title=`'````'`, applications=`[``]`, rdp_server=None, rdp_options=None, xdmcp_server=None, convert_encoding=False, server_encoding=`'``UTF-8``'`, client_encoding=`'``UTF-8``'`, rootdir=None, profile_name=`'``UNKNOWN``'`, profile_id=`'``20171103011108301208``'`, print_action=None, print_action_args=`{``}`, info_backend=`'``PLAIN``'`, list_backend=`'``PLAIN``'`, proxy_backend=`'``NX3``'`, proxy_options=`{``}`, printing_backend=`'``FILE``'`, client_rootdir=`'``/sbuild-nonexistent/.x2goclient``'`, sessions_rootdir=`'``/sbuild-nonexistent/.x2go``'`, session_instance=None, logger=None, loglevel=56)
(Constructor)

source code

Initialize an X2Go session. With the x2go.backends.terminal.plain.X2GoTerminalSession class you can start new X2Go sessions, resume suspended sessions or suspend resp. terminate currently running sessions on a connected X2Go server.

Parameters:
  - `geometry` (`str`) - screen geometry of the X2Go session. Can be either `<width>x<height>`, `maximize` or `fullscreen`
  - `depth` (`int`) - color depth in bits (common values: `16`, `24`)
  - `link` (`str`) - network link quality (either one of `modem`, `isdn`, `adsl`, `wan` or `lan`)
  - `pack` (`str`) - compression method for NX based session proxying
  - `dpi` (`str`) - dots-per-inch value for the session screen (has an impact on the font size on screen)
  - `cache_type` (`str`) - a dummy parameter that is passed to the x2go.backends.proxy.base.X2GoProxy. In NX Proxy (class `X2GoProxyNX3`) this originally is the session name. With X2Go it defines the name of the NX cache directory. Best is to leave it untouched.
  - `kbtype` (`str`) - keyboard type, e.g. `pc105/us` (default), `pc105/de`, ...
  - `kblayout` (`str`) - keyboard layout, e.g. `us` (default), `de`, `fr`, ...
  - `kbvariant` (`str`) - keyboard variant, e.g. `nodeadkeys` (for `de` layout), `intl` (for `us` layout), etc.
  - `clipboard` (`str`) - clipboard mode (`both`: bidirectional copy+paste, `server`: copy+paste from server to client, `client`: copy+paste from client to server, `none`: disable clipboard completely
  - `session_type` (`str`) - either `desktop`, `application` (rootless session) or `shared`
  - `snd_system` (`str`) - sound system to be used on server (`none`, `pulse` (default), `arts` (obsolete) or `esd`)
  - `snd_port` (`int`) - local sound port for network capable audio system
  - `cmd` (`str`) - command to be run on X2Go server after session start (only used when x2go.backends.terminal.plain.X2GoTerminalSession.start() is called, ignored on resume, suspend etc.
  - `published_applications` (`bool`) - session is published applications provider
  - `set_session_title` (`bool`) - modify the session title (i.e. the Window title) of desktop or shared desktop sessions
  - `session_title` (`str`) - session title for this (desktop or shared desktop) session
  - `applications` (`list`) - applications available for rootless application execution
  - `rdp_server` (`str`) - host name of server-side RDP server
  - `rdp_options` (`str`) - options for the `rdesktop` command executed on the X2Go server (RDP proxy mode of X2Go)
  - `xdmcp_server` (`str`) - XDMCP server to connect to
  - `convert_encoding` (`bool`) - convert file system encodings between server and client (for client-side shared folders)
  - `server_encoding` (`str`) - server-side file system / session encoding
  - `client_encoding` (`str`) - client-side file system encoding (if client-side is MS Windows, this parameter gets overwritten to WINDOWS-1252)
  - `rootdir` (`str`) - X2Go session directory, normally `~/.x2go`
  - `profile_name` (`str`) - the session profile name for this terminal session
  - `profile_id` (`str`) - the session profile ID for this terminal session
  - `print_action` (`str` or `class`) - either a print action short name (PDFVIEW, PDFSAVE, PRINT, PRINTCMD) or the resp. `X2GoPrintActionXXX` class (where XXX equals one of the given short names)
  - `print_action_args` (dict) - optional arguments for a given print_action (for further info refer to X2GoPrintActionPDFVIEW, X2GoPrintActionPDFSAVE, X2GoPrintActionPRINT and X2GoPrintActionPRINTCMD)
  - `info_backend` (`X2GoServerSessionInfo*` instance) - backend for handling storage of server session information
  - `list_backend` (`X2GoServerSessionList*` instance) - backend for handling storage of session list information
  - `proxy_backend` (`X2GoProxy*` instance) - backend for handling the X-proxy connections
  - `proxy_options` (`dict`) - a set of very `X2GoProxy` backend specific options; any option that is not known to the `X2GoProxy` backend will simply be ignored
  - `client_rootdir` (`str`) - client base dir (default: ~/.x2goclient)
  - `sessions_rootdir` (`str`) - sessions base dir (default: ~/.x2go)
  - `session_instance` (`obj`) - the X2GoSession instance that is parent to this terminal session
  - `logger` (X2GoLogger instance) - you can pass an X2GoLogger object to the x2go.backends.terminal.plain.X2GoTerminalSession constructor
  - `loglevel` (`int`) - if no X2GoLogger object has been supplied a new one will be constructed with the given loglevel
Overrides: object.__init__

### get_session_name(self)

source code

Retrieve the X2Go session's name from the session info object.

Returns: `str`
  the session name

### get_session_info(self)

source code

Retrieve the X2Go session's session info object.

Returns: `X2GoServerSessionInfo*`
  the session info object

### get_session_cmd(self)

source code

Retrieve the X2Go session's command as stored in the session parameter object.

Returns: `str`
  the session command

### get_session_type(self)

source code

Retrieve the X2Go session's session type as stored in the session parameter object.

Returns: `str`
  the session type

### start_sound(self)

source code

Initialize Paramiko/SSH reverse forwarding tunnel for X2Go sound.

Currently supported audio protocols:

- PulseAudio
- Esound (not tested very much)

Raises:
  - `X2GoControlSessionException` - if the control session of this terminal session is not connected

### start_printing(self)

source code

Initialize X2Go print spooling.

Raises:
  - `X2GoUserException` - if the X2Go printing feature is not available to this user

### set_print_action(self, print_action, **kwargs)

source code

Set a print action for the next incoming print jobs.

This method is a wrapper for X2GoPrintQueue`.set_print_action()`.

Parameters:
  - `print_action` (`str` or `X2GoPrintAction*`) - print action name or object (i.e. an instance of `X2GoPrintAction*` classes)
  - `kwargs` (dict) - print action specific parameters

### get_printing_spooldir(self)

source code

Return the server-side printing spooldir path.

Returns: `str`
  the directory for remote print job spooling

### start_mimebox(self, mimebox_extensions=`[``]`, mimebox_action=None)

source code

Initialize the X2Go MIME box. Open/process incoming files from the server-side locally.

Parameters:
  - `mimebox_extensions` (`list`) - file name extensions that are allowed for local opening/processing
  - `mimebox_action` (`str` or `obj`) - MIME box action given as name or object (i.e. an instance of `X2GoMIMEboxAction*` classes).
Raises:
  - `X2GoUserException` - if the X2Go MIME box feature is not available to this user

### set_mimebox_action(self, mimebox_action, **kwargs)

source code

Set a MIME box action for the next incoming MIME jobs.

This method is a wrapper for X2GoMIMEboxQueue `set_mimebox_action()`.

Parameters:
  - `mimebox_action` (`str` or `X2GoMIMEboxAction*`) - MIME box action name or object (i.e. an instance of `X2GoMIMEboxAction*` classes)
  - `kwargs` (dict) - MIME box action specific parameters

### get_mimebox_spooldir(self)

source code

Return the server-side MIME box spooldir path.

Returns: `str`
  the directory where remote MIME box jobs are placed

### is_session_info_protected(self)

source code

Test if this terminal's session info object is write-protected.

Returns: `bool`
  `True`, if session info object is read-only, `False` for read-write.

### share_local_folder(self, local_path=None, folder_type=`'``disk``'`)

source code

Share a local folder with the X2Go session.

Parameters:
  - `local_path` (`str`) - the full path to an existing folder on the local file system
  - `folder_type` (`str`) - one of 'disk' (a folder on your local hard drive), 'rm' (removeable device), 'cdrom' (CD/DVD Rom) or 'spool' (for X2Go print spooling)
Returns: `bool`
  returns `True` if the local folder has been successfully mounted within the X2Go server session
Raises:
  - `X2GoUserException` - if local folder sharing is not available to this user
  - `Exception` - any other exception occuring on the way is passed through by this method

### unshare_all_local_folders(self)

source code

Unshare all local folders mount in the X2Go session.

Returns: `bool`
  returns `True` if all local folders could be successfully unmounted from the X2Go server session

### unshare_local_folder(self, local_path)

source code

Unshare local folder given as <local_path> from X2Go session.

Returns: `bool`
  returns `True` if the local folder <local_path> could be successfully unmounted from the X2Go server session

### color_depth(self)

source code

Retrieve the session's color depth.

Returns: `int`
  the session's color depth

### auto_session_window_title(self, dont_set=False)

source code

Automatically generate an appropriate human-readable session window title.

The session window title will be provider in the `session_title` property of this method.

Parameters:
  - `dont_set` (`bool`) - generate the session window title, but do not actually set it

### find_session_window(self, timeout=60)

source code

Try for <timeout> seconds to find the X2Go session window of this terminal session.

A background thread will get spawned for this operation.

Parameters:
  - `timeout` (`int`) - try for <timeout> seconds to find the session window

### update_session_window_file(self)

source code

Create a file that contains information on the session window. . If the file already exists, its content gets update.

### set_session_window_title(self, title, timeout=60)

source code

Modify the session window title.

A background thread will get spawned for this operation.

Parameters:
  - `title` (`str`) - new title for the terminal session's session window
  - `timeout` (`int`) - try for <timeout> seconds to find the session window

### raise_session_window(self, timeout=60)

source code

Try for <timeout> seconds to raise the X2Go session window of this terminal session to the top and bring it to focus.

A background thread will get spawned for this operation.

Parameters:
  - `timeout` (`int`) - try for <timeout> seconds to raise the session window

### has_command(self, cmd)

source code

,,Guess'' if the command `<cmd>` exists on the X2Go server and is executable. The expected result is not 100% safe, however, it comes with a high probability to be correct.

Parameters:
  - `cmd` (`str`) - session command
Returns: `bool`
  `True` if this method reckons that the command is executable on the remote X2Go server

### run_command(self, cmd=None, env=`{``}`)

source code

Run a command in this session.

After x2go.backends.terminal.plain.X2GoTerminalSession.start() has been called one or more commands can be executed with x2go.backends.terminal.plain.X2GoTerminalSession.run_command() within the current X2Go session.

Parameters:
  - `cmd` (`str`) - Command to be run
  - `env` (`dict`) - add server-side environment variables
Returns: `tuple` of `str`
  stdout.read() and stderr.read() as returned by the run command on the X2Go server

### is_desktop_session(self)

source code

Is this (terminal) session a desktop session?

Returns: `bool`
  Returns `True` is this session is a desktop session.

### is_published_applications_provider(self)

source code

Is this (terminal) session a published applications provider?

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

### set_keyboard(self, layout=`'``null``'`, variant=`'``null``'`)

source code

Set the keyboard layout and variant for this (running) session.

Parameters:
  - `layout` (`str`) - keyboard layout to be set
  - `variant` (`str`) - keyboard variant to be set
Returns: `bool`
  returns `True` if the {setxkbmap} command could be executed successfully.

### exec_published_application(self, exec_name, timeout=20, env=`{``}`)

source code

Executed a published application.

Parameters:
  - `exec_name` (`str`) - application to be executed
  - `timeout` (`int`) - execution timeout
  - `env` (`dict`) - session environment dictionary

### ok(self)

source code

X2Go session OK?

Returns: `bool`
  Returns `True` if this X2Go (terminal) session is up and running, `False` otherwise.

### is_running(self)

source code

X2Go session running?

Returns: `bool`
  Returns `True` if this X2Go (terminal) session is in running state, `False` otherwise.

### is_suspended(self)

source code

X2Go session suspended?

Returns: `bool`
  Returns `True` if this X2Go (terminal) session is in suspended state, `False` otherwise.

### is_connected(self)

source code

X2Go session connected?

Returns: `bool`
  Returns `True` if this X2Go session's Paramiko/SSH transport is connected/authenticated, `False` else.

### start(self)

source code

Start a new X2Go session.

Returns: `bool`
  `True` if session startup has been successful and the X2Go proxy is up-and-running
Raises:
  - `X2GoTerminalSessionException` - if the session startup failed
  - `X2GoDesktopSharingDenied` - if desktop sharing fails because of denial by the user running the desktop to be shared

### resume(self)

source code

Resume a running/suspended X2Go session.

Returns: `bool`
  `True` if the session could successfully be resumed
Raises:
  - `X2GoTerminalSessionException` - if the terminal session failed to update server-side reported port changes

### suspend(self)

source code

Suspend this X2Go (terminal) session.

Returns: `bool`
  `True` if the session terminal could be successfully suspended

### terminate(self)

source code

Terminate this X2Go (terminal) session.

Returns: `bool`
  `True` if the session could be successfully terminated

### release_proxy(self)

source code

Let the X2Go proxy command cleanly die away... (by calling its destructor).

### release_telekinesis(self)

source code

Let the attached Telekinesis client cleanly die away... (by calling its destructor).

### is_rootless_session(self)

source code

Test if this terminal 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 terminal 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 terminal session is a published applications session.

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