Package entropy :: Module const

Module const

source code


Author: Fabio Erculiani <lxnay@sabayonlinux.org>

Contact: lxnay@sabayonlinux.org

Copyright: Fabio Erculiani

License: GPL-2

Entropy Framework constants module.

This module contains all the Entropy constants used all around the "entropy" package.

Some of the constants in this module are used as "default" for the SystemSettings interface. So, make sure to read the documentation of SystemSettings in the "entropy.core" module.

Even if possible, etpConst, etpUi, etpCache and etpSys objects *SHOULD* be never ever modified manually. This freedom could change in future, so, if you want to produce a stable code, DON'T do that at all!

Basic Entropy constants handling functions are available in this module and are all prefixed with "const_*" or "initconfig_*". If you are writing a third party application, you should always try to avoid to deal directly with functions here unless specified otherwise. In fact, usually these here are wrapper in upper-level modules (entropy.client, entropy.server, entropy.services).

Functions
None
initconfig_entropy_constants(rootdir)
Main constants configurators, this is the only function that you should call from the outside, anytime you want.
source code
None
const_default_settings(rootdir)
Initialization of all the Entropy base settings.
source code
int
const_set_nice_level(nice_level=0)
Change current process scheduler "nice" level.
source code
tuple (string, dict)
const_extract_cli_repo_params(repostring, branch=None, product=None)
Extract repository information from the provided repository string, usually contained in the repository settings file, repositories.conf.
source code
None
const_read_entropy_release()
Read Entropy release file content and fill etpConst['entropyversion']
source code
None
const_setup_entropy_pid(just_read=False)
Setup Entropy pid file, if possible and if UID = 0 (root).
source code
None
const_secure_config_file(config_file)
Setup entropy file needing strict permissions, no world readable.
source code
 
const_chmod_entropy_pid()
Setup entropy pid file permissions, if possible.
source code
None
const_create_working_dirs()
Setup Entropy directory structure, as much automagically as possible.
source code
None
const_configure_lock_paths()
Setup Entropy lock file paths.
source code
None
const_extract_srv_repo_params(repostring, product=None)
Analyze a server repository string (usually contained in server.conf), extracting all the parameters.
source code
None
const_setup_perms(mydir, gid)
Setup permissions and group id (GID) to a directory, recursively.
source code
None
const_setup_file(myfile, gid, chmod)
Setup file permissions and group id (GID).
source code
integer(8) (octal)
const_get_chmod(myfile)
This function get the current permissions of the specified file.
source code
None
const_set_chmod(myfile, chmod)
This function sets specified permissions to a file.
source code
None
const_get_entropy_gid()
This function tries to retrieve the "entropy" user group GID.
source code
None
const_add_entropy_group()
This function looks for an "entropy" user group.
source code
bool
const_islive()
Live environments (Operating System running off a CD/DVD) must feature the "cdroot" parameter in kernel /proc/cmdline
source code
None
const_kill_threads()
Entropy threads killer.
source code
None
const_debug_write(identifier, msg)
Entropy debugging output write functions.
source code
Variables
  ETP_ARCH_MAP = {('i386', 'i486', 'i586', 'i686'): 'x86', ('ppc...
  ETP_ARCH_CONST = 'amd64'
  etpSys = {'api': '3', 'arch': 'amd64', 'archs': ['x86', 'amd64...
  etpUi = {'ask': False, 'clean': False, 'debug': False, 'mute':...
  ETP_LOGLEVEL_NORMAL = 1
  ETP_LOGLEVEL_VERBOSE = 2
  ETP_LOGPRI_INFO = '[ INFO ]'
  ETP_LOGPRI_WARNING = '[ WARNING ]'
  ETP_LOGPRI_ERROR = '[ ERROR ]'
  etpCache = {'advisories': 'security/advisories_cache_', 'atomM...
  etpConst = {'applicationlock': False, 'backed_up': {}, 'branch...
  arch = 'x86'
  arches = ('i386', 'i486', 'i586', 'i686')
Function Details

initconfig_entropy_constants(rootdir)

source code 

Main constants configurators, this is the only function that you should call from the outside, anytime you want. it will reset all the variables excluding those backed up previously.

Parameters:
  • rootdir (string) - current root directory, if any, or ""
Returns: None
None
Raises:
  • AttributeError - when specified rootdir is not a directory

const_default_settings(rootdir)

source code 

Initialization of all the Entropy base settings.

Parameters:
  • rootdir (string) - current root directory, if any, or ""
Returns: None
None

const_set_nice_level(nice_level=0)

source code 

Change current process scheduler "nice" level.

Parameters:
  • nice_level (int) - new valid nice level
Returns: int
current_nice new nice level

const_extract_cli_repo_params(repostring, branch=None, product=None)

source code 

Extract repository information from the provided repository string, usually contained in the repository settings file, repositories.conf.

Parameters:
  • repostring (string) - valid repository identifier
Returns: tuple (string, dict)
tuple composed by (repository identifier, extracted repository metadata)

const_read_entropy_release()

source code 

Read Entropy release file content and fill etpConst['entropyversion']

Returns: None
None

const_setup_entropy_pid(just_read=False)

source code 

Setup Entropy pid file, if possible and if UID = 0 (root). If the application is run with --no-pid-handling argument, this function will have no effect. If just_read is specified, this function will only try to read the current pid string in the Entropy pid file (etpConst['pidfile']). If any other entropy istance is currently owning the contained pid, etpConst['applicationlock'] becomes True.

Parameters:
  • just_read (bool) - only read the current pid file, if any and if possible
Returns: None
None

const_secure_config_file(config_file)

source code 

Setup entropy file needing strict permissions, no world readable.

Parameters:
  • config_file (string) - valid config file path
Returns: None
None

const_chmod_entropy_pid()

source code 

Setup entropy pid file permissions, if possible.

Returns:
None

const_create_working_dirs()

source code 

Setup Entropy directory structure, as much automagically as possible.

Returns: None
None

const_configure_lock_paths()

source code 

Setup Entropy lock file paths.

Returns: None
None

const_extract_srv_repo_params(repostring, product=None)

source code 

Analyze a server repository string (usually contained in server.conf), extracting all the parameters.

Parameters:
  • repostring (string) - repository string
  • product - system product which repository belongs to
Returns: None
None

const_setup_perms(mydir, gid)

source code 

Setup permissions and group id (GID) to a directory, recursively.

Parameters:
  • mydir (string) - valid file path
  • gid (int) - valid group id (GID)
Returns: None
None

const_setup_file(myfile, gid, chmod)

source code 

Setup file permissions and group id (GID).

Parameters:
  • myfile (string) - valid file path
  • gid (int) - valid group id (GID)
  • chmod (integer representing an octal) - permissions
Returns: None
None

const_get_chmod(myfile)

source code 

This function get the current permissions of the specified file. If you want to use the returning value with const_set_chmod you need to convert it back to int.

Parameters:
  • myfile (string) - valid file path
Returns: integer(8) (octal)
octal representing permissions

const_set_chmod(myfile, chmod)

source code 

This function sets specified permissions to a file. If they differ from the current ones.

Parameters:
  • myfile (string) - valid file path
  • chmod (integer representing an octal) - permissions
Returns: None
None

const_get_entropy_gid()

source code 

This function tries to retrieve the "entropy" user group GID.

Returns: None
None
Raises:
  • KeyError - when "entropy" system GID is not available

const_add_entropy_group()

source code 

This function looks for an "entropy" user group. If not available, it tries to create one.

Returns: None
None
Raises:
  • KeyError - if ${ROOT}/etc/group is not found

const_islive()

source code 

Live environments (Operating System running off a CD/DVD) must feature the "cdroot" parameter in kernel /proc/cmdline

Sample code:

>>> from entropy.const import const_islive
>>> const_islive()
False
Returns: bool
determine wether this is a Live system or not

const_kill_threads()

source code 

Entropy threads killer. Even if Python threads cannot be stopped or killed, TimeScheduled ones can, exporting the kill() method.

Sample code:

>>> from entropy.const import const_kill_threads
>>> const_kill_threads()
Returns: None
None

const_debug_write(identifier, msg)

source code 

Entropy debugging output write functions.

Parameters:
  • identifier (string) - debug identifier
  • msg (string) - debugging message
Returns: None
None

Variables Details

ETP_ARCH_MAP

Value:
{('i386', 'i486', 'i586', 'i686'): 'x86',
 ('ppc'): None,
 ('sun4u'): None,
 ('x86_64'): 'amd64'}

etpSys

Value:
{'api': '3',
 'arch': 'amd64',
 'archs': ['x86', 'amd64'],
 'dirstoclean': set([]),
 'keywords': set(['amd64', '~amd64']),
 'killpids': set([]),
 'maxthreads': 100,
 'rootdir': '',
...

etpUi

Value:
{'ask': False,
 'clean': False,
 'debug': False,
 'mute': False,
 'nolog': False,
 'pretend': False,
 'quiet': False,
 'verbose': False,
...

etpCache

Value:
{'advisories': 'security/advisories_cache_',
 'atomMatch': 'atom_match/atom_match_',
 'check_package_update': 'check_update/package_update_',
 'configfiles': 'conf/scanfs',
 'critical_update': 'critical_update/critical_cache_',
 'dbMatch': 'match/db',
 'dbSearch': 'search/db',
 'dep_tree': 'deptree/dep_tree_',
...

etpConst

Value:
{'applicationlock': False,
 'backed_up': {},
 'branch': '4',
 'cachedumpext': '.dmp',
 'client_treeupdatescalled': set([]),
 'clientconf': '/etc/entropy/client.conf',
 'clientdbid': 'client',
 'clientserverrepoid': '__system__',
...