Package x2go :: Package backends :: Package profiles :: Module _file :: Class X2GoSessionProfilesFILE

[frames] | no frames]

# Class X2GoSessionProfilesFILE

source code

              object --+
                       |
    inifiles.X2GoIniFile --+
                           |
                          X2GoSessionProfilesFILE

Instance Methods

__init__(self, config_files=`[``'``/home/buildd/.x2goclient/sessions``'``,` `'``/etc/x2goclient/sessions``'``]`, defaults=None, session_profile_defaults=None, logger=None, loglevel=56) Retrieve X2Go session profiles from a file, typically `~/.x2goclient/sessions`. | source code

`dict`

__call__(self, profile_id_or_name) Retrieve the session profile configuration for a given session profile ID (or name) | source code

`str`

get_profile_metatype(self, profile_id_or_name, force=False) Detect a human readable session profile type from the session profile configuration. | source code

`bool`

write(self) Write the ini file modifications (SafeConfigParser object) from RAM to disk. | source code

`type`

get_profile_option_type(self, option) Get the data type for a specific session profile option. | source code

`type`

get_type(self, section, key) Override the parent class's get_type method due to the special layout of this class. | source code

`dict`

get_profile_config(self, profile_id_or_name=None, parameter=None, profile_id=None) The configuration options for a single session profile. | source code

`dict`

default_profile_config(self) Return a default session profile. | source code

`bool`

has_profile(self, profile_id_or_name) Does a session profile of a given profile ID or profile name exist? | source code

`bool`

has_profile_id(self, profile_id) Does a session profile of a given profile ID exist? (Faster than has_profile().) | source code

`bool`

has_profile_name(self, profile_name) Does a session profile of a given profile name exist? (Faster than has_profile().) | source code

`str`

to_profile_id(self, profile_name) Convert profile name to profile ID. | source code

`str`

to_profile_name(self, profile_id) Convert profile ID to profile name. | source code

`str`

add_profile(self, profile_id=None, force_add=False, **kwargs) Add a new session profile. | source code

delete_profile(self, profile_id_or_name) Delete a session profile from the configuration file. | source code

update_value(self, section, key, value, profile_id=None) Update a value in a session profile. | source code

`str`

check_profile_id_or_name(self, profile_id_or_name) Detect the profile ID from a given string which maybe profile ID or profile name. | source code

`dict`

to_session_params(self, profile_id_or_name=None, profile_id=None) Convert session profile options to X2GoSession constructor method parameters. | source code

depends on the session profile option requested

get_session_param(self, profile_id_or_name, param) Get a single X2GoSession parameter from a specific session profile. | source code

Inherited from `inifiles.X2GoIniFile`: `__repr__`, `get`, `get_value`, `load` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Class Variables
| defaultSessionProfile = ``{``'``applications``'``:` `[``'``WWWBROWSER``'``,` `'``MAILC``...``
Inherited from `inifiles.X2GoIniFile`: `defaultValues`, `user_config_file`, `write_user_config`

Properties
| profile_ids Renders a list of all profile IDs found in the session profile configuration file.
| profile_names Renders a list of all profile names found in the session profile configuration file.
Inherited from `inifiles.X2GoIniFile`: `printable_config_file` Inherited from `object`: `__class__`

Method Details

### __init__(self, config_files=`[``'``/home/buildd/.x2goclient/sessions``'``,` `'``/etc/x2goclient/sessions``'``]`, defaults=None, session_profile_defaults=None, logger=None, loglevel=56)
(Constructor)

source code

Retrieve X2Go session profiles from a file, typically `~/.x2goclient/sessions`.

Parameters:
  - `config_files` (`list`) - a list of config file locations, the first file name in this list the user has write access to will be the user configuration file
  - `defaults` (`dict`) - not used for this class
  - `session_profile_defaults` (`dict`) - a default session profile
  - `logger` (X2GoLogger instance) - you can pass an X2GoLogger object to the X2GoSessionProfilesFILE constructor
  - `loglevel` (`int`) - if no X2GoLogger object has been supplied a new one will be constructed with the given loglevel
Overrides: object.__init__

### __call__(self, profile_id_or_name)
(Call operator)

source code

Retrieve the session profile configuration for a given session profile ID (or name)

Parameters:
  - `profile_id_or_name` (`str`) - profile ID or profile name
Returns: `dict`
  the profile ID's / name's profile configuration
Overrides: inifiles.X2GoIniFile.get_value

### get_profile_metatype(self, profile_id_or_name, force=False)

source code

Detect a human readable session profile type from the session profile configuration.

Parameters:
  - `profile_id_or_name` (`str`) - profile ID or profile name
  - `force` (`bool`) - re-detect the meta type, otherwise use a cached result
Returns: `str`
  the profile ID's / name's meta type

### write(self)

source code

Write the ini file modifications (SafeConfigParser object) from RAM to disk.

For writing the first of the `config_files` specified on instance construction that is writable will be used.

Returns: `bool`
  `True` if the user config file has been successfully writte, `False` otherwise.
Overrides: inifiles.X2GoIniFile.write
  (inherited documentation)

### get_profile_option_type(self, option)

source code

Get the data type for a specific session profile option.

Parameters:
  - `option` (will be detected by this method) - the option to get the data type for
Returns: `type`
  the data type of `option`

### get_type(self, section, key)

source code

Override the parent class's get_type method due to the special layout of this class.

Parameters:
  - `section` (`str`) - INI file section
  - `key` (`str`) - key in INI file section
Returns: `type`
  the data type of `key` in `section`
Overrides: inifiles.X2GoIniFile.get_type

### get_profile_config(self, profile_id_or_name=None, parameter=None, profile_id=None)

source code

The configuration options for a single session profile.

Parameters:
  - `profile_id_or_name` (`str`) - either profile ID or profile name is accepted
  - `parameter` (`str`) - if specified, only the value for the given parameter is returned
  - `profile_id` (`str`) - profile ID (faster than specifying `profile_id_or_name`)
Returns: `dict`
  the session profile configuration for the given profile ID (or name)

### default_profile_config(self)

source code

Return a default session profile.

Returns: `dict`
  default session profile

### has_profile(self, profile_id_or_name)

source code

Does a session profile of a given profile ID or profile name exist?

Parameters:
  - `profile_id_or_name` (`str`) - profile ID or profile name
Returns: `bool`
  `True` if there is such a session profile, `False` otherwise

### has_profile_id(self, profile_id)

source code

Does a session profile of a given profile ID exist? (Faster than has_profile().)

Parameters:
  - `profile_id` (`str`) - profile ID
Returns: `bool`
  `True` if there is such a session profile, `False` otherwise

### has_profile_name(self, profile_name)

source code

Does a session profile of a given profile name exist? (Faster than has_profile().)

Parameters:
  - `profile_name` (`str`) - profile name
Returns: `bool`
  `True` if there is such a session profile, `False` otherwise

### to_profile_id(self, profile_name)

source code

Convert profile name to profile ID.

Parameters:
  - `profile_name` (`str`) - profile name
Returns: `str`
  profile ID

### to_profile_name(self, profile_id)

source code

Convert profile ID to profile name.

Parameters:
  - `profile_id` (`str`) - profile ID
Returns: `str`
  profile name

### add_profile(self, profile_id=None, force_add=False, **kwargs)

source code

Add a new session profile.

Parameters:
  - `profile_id` (`str`) - a custom profile ID--if left empty a profile ID will be auto-generated
  - `kwargs` (`dict`) - session profile options for this new session profile
Returns: `str`
  the (auto-generated) profile ID of the new session profile

### delete_profile(self, profile_id_or_name)

source code

Delete a session profile from the configuration file.

Parameters:
  - `profile_id_or_name` (`str`) - profile ID or profile name

### update_value(self, section, key, value, profile_id=None)

source code

Update a value in a session profile.

Parameters:
  - `section` (`str`) - the profile ID
  - `key` (`str`) - the session profile option of the given profile ID
  - `value` (any type, depends on the session profile option) - the value to update the session profile option with
Overrides: inifiles.X2GoIniFile.update_value

### check_profile_id_or_name(self, profile_id_or_name)

source code

Detect the profile ID from a given string which maybe profile ID or profile name.

Parameters:
  - `profile_id_or_name` (`str`) - profile ID or profile name
Returns: `str`
  profile ID
Raises:
  - `X2GoProfileException` - if no such session profile exists

### to_session_params(self, profile_id_or_name=None, profile_id=None)

source code

Convert session profile options to X2GoSession constructor method parameters.

Parameters:
  - `profile_id_or_name` (`str`) - either profile ID or profile name is accepted
  - `profile_id` (`str`) - profile ID (fast than specifying `profile_id_or_name`)
Returns: `dict`
  a dictionary of X2GoSession constructor method parameters

### get_session_param(self, profile_id_or_name, param)

source code

Get a single X2GoSession parameter from a specific session profile.

Parameters:
  - `profile_id_or_name` (`str`) - either profile ID or profile name is accepted
  - `param` (`str`) - the parameter name in the X2GoSession constructor method
Returns: depends on the session profile option requested
  the value of the session profile option represented by `param`

Class Variable Details

### defaultSessionProfile

Value:

      {'applications': ['WWWBROWSER', 'MAILCLIENT', 'OFFICE', 'TERMINAL'],
       'autoconnect': False,
       'autologin': True,
       'autostart': False,
       'command': 'TERMINAL',
       'defsndport': True,
       'directrdp': False,
       'directrdpsettings': '',
      ...

Property Details

### profile_ids

Renders a list of all profile IDs found in the session profile configuration file.

Get Method:
  unreachable.profile_ids(self) - Renders a list of all profile IDs found in the session profile configuration file.

### profile_names

Renders a list of all profile names found in the session profile configuration file.

Get Method:
  unreachable.profile_names(self) - Renders a list of all profile names found in the session profile configuration file.