2018-03-15 21:04:29 +00:00
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns = "http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" / >
2018-04-25 20:25:07 +00:00
< title > pylorax.api.config — Lorax 19.7.14 documentation< / title >
2018-03-15 21:04:29 +00:00
< link rel = "stylesheet" href = "../../../_static/default.css" type = "text/css" / >
< link rel = "stylesheet" href = "../../../_static/pygments.css" type = "text/css" / >
< script type = "text/javascript" >
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../../',
2018-04-25 20:25:07 +00:00
VERSION: '19.7.14',
2018-03-15 21:04:29 +00:00
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
< / script >
< script type = "text/javascript" src = "../../../_static/jquery.js" > < / script >
< script type = "text/javascript" src = "../../../_static/underscore.js" > < / script >
< script type = "text/javascript" src = "../../../_static/doctools.js" > < / script >
2018-04-25 20:25:07 +00:00
< link rel = "top" title = "Lorax 19.7.14 documentation" href = "../../../index.html" / >
2018-03-15 21:04:29 +00:00
< link rel = "up" title = "pylorax.api" href = "../api.html" / >
< / head >
< body >
< div class = "related" >
< h3 > Navigation< / h3 >
< ul >
< li class = "right" style = "margin-right: 10px" >
< a href = "../../../genindex.html" title = "General Index"
accesskey="I">index< / a > < / li >
< li class = "right" >
< a href = "../../../py-modindex.html" title = "Python Module Index"
>modules< / a > |< / li >
2018-04-25 20:25:07 +00:00
< li > < a href = "../../../index.html" > Lorax 19.7.14 documentation< / a > » < / li >
2018-03-15 21:04:29 +00:00
< li > < a href = "../../index.html" > Module code< / a > » < / li >
2018-03-16 23:41:16 +00:00
< li > < a href = "../../pylorax.html" > pylorax< / a > » < / li >
2018-03-15 21:04:29 +00:00
< li > < a href = "../api.html" accesskey = "U" > pylorax.api< / a > » < / li >
< / ul >
< / div >
< div class = "document" >
< div class = "documentwrapper" >
< div class = "bodywrapper" >
< div class = "body" >
< h1 > Source code for pylorax.api.config< / h1 > < div class = "highlight" > < pre >
< span class = "c" > #< / span >
< span class = "c" > # Copyright (C) 2017 Red Hat, Inc.< / span >
< span class = "c" > #< / span >
< span class = "c" > # This program is free software; you can redistribute it and/or modify< / span >
< span class = "c" > # it under the terms of the GNU General Public License as published by< / span >
< span class = "c" > # the Free Software Foundation; either version 2 of the License, or< / span >
< span class = "c" > # (at your option) any later version.< / span >
< span class = "c" > #< / span >
< span class = "c" > # This program is distributed in the hope that it will be useful,< / span >
< span class = "c" > # but WITHOUT ANY WARRANTY; without even the implied warranty of< / span >
< span class = "c" > # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the< / span >
< span class = "c" > # GNU General Public License for more details.< / span >
< span class = "c" > #< / span >
< span class = "c" > # You should have received a copy of the GNU General Public License< / span >
< span class = "c" > # along with this program. If not, see < http://www.gnu.org/licenses/> .< / span >
< span class = "c" > #< / span >
< span class = "kn" > import< / span > < span class = "nn" > ConfigParser< / span >
< span class = "kn" > import< / span > < span class = "nn" > grp< / span >
< span class = "kn" > import< / span > < span class = "nn" > os< / span >
< span class = "kn" > from< / span > < span class = "nn" > pylorax.sysutils< / span > < span class = "kn" > import< / span > < span class = "n" > joinpaths< / span >
< div class = "viewcode-block" id = "ComposerConfig" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.config.ComposerConfig" > [docs]< / a > < span class = "k" > class< / span > < span class = "nc" > ComposerConfig< / span > < span class = "p" > (< / span > < span class = "n" > ConfigParser< / span > < span class = "o" > .< / span > < span class = "n" > SafeConfigParser< / span > < span class = "p" > ):< / span >
< div class = "viewcode-block" id = "ComposerConfig.get_default" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.config.ComposerConfig.get_default" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > get_default< / span > < span class = "p" > (< / span > < span class = "bp" > self< / span > < span class = "p" > ,< / span > < span class = "n" > section< / span > < span class = "p" > ,< / span > < span class = "n" > option< / span > < span class = "p" > ,< / span > < span class = "n" > default< / span > < span class = "p" > ):< / span >
< span class = "k" > try< / span > < span class = "p" > :< / span >
< span class = "k" > return< / span > < span class = "bp" > self< / span > < span class = "o" > .< / span > < span class = "n" > get< / span > < span class = "p" > (< / span > < span class = "n" > section< / span > < span class = "p" > ,< / span > < span class = "n" > option< / span > < span class = "p" > )< / span >
< span class = "k" > except< / span > < span class = "n" > ConfigParser< / span > < span class = "o" > .< / span > < span class = "n" > Error< / span > < span class = "p" > :< / span >
< span class = "k" > return< / span > < span class = "n" > default< / span >
< / div > < / div >
< div class = "viewcode-block" id = "configure" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.config.configure" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > configure< / span > < span class = "p" > (< / span > < span class = "n" > conf_file< / span > < span class = "o" > =< / span > < span class = "s" > " /etc/lorax/composer.conf" < / span > < span class = "p" > ,< / span > < span class = "n" > root_dir< / span > < span class = "o" > =< / span > < span class = "s" > " /" < / span > < span class = "p" > ,< / span > < span class = "n" > test_config< / span > < span class = "o" > =< / span > < span class = "bp" > False< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " lorax-composer configuration< / span >
< span class = "sd" > :param conf_file: Path to the config file overriding the default settings< / span >
< span class = "sd" > :type conf_file: str< / span >
< span class = "sd" > :param root_dir: Directory to prepend to paths, defaults to /< / span >
< span class = "sd" > :type root_dir: str< / span >
< span class = "sd" > :param test_config: Set to True to skip reading conf_file< / span >
< span class = "sd" > :type test_config: bool< / span >
< span class = "sd" > " " " < / span >
< span class = "n" > conf< / span > < span class = "o" > =< / span > < span class = "n" > ComposerConfig< / span > < span class = "p" > ()< / span >
< span class = "c" > # set defaults< / span >
< span class = "n" > conf< / span > < span class = "o" > .< / span > < span class = "n" > add_section< / span > < span class = "p" > (< / span > < span class = "s" > " composer" < / span > < span class = "p" > )< / span >
< span class = "n" > conf< / span > < span class = "o" > .< / span > < span class = "n" > set< / span > < span class = "p" > (< / span > < span class = "s" > " composer" < / span > < span class = "p" > ,< / span > < span class = "s" > " share_dir" < / span > < span class = "p" > ,< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > realpath< / span > < span class = "p" > (< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > root_dir< / span > < span class = "p" > ,< / span > < span class = "s" > " /usr/share/lorax/" < / span > < span class = "p" > )))< / span >
< span class = "n" > conf< / span > < span class = "o" > .< / span > < span class = "n" > set< / span > < span class = "p" > (< / span > < span class = "s" > " composer" < / span > < span class = "p" > ,< / span > < span class = "s" > " lib_dir" < / span > < span class = "p" > ,< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > realpath< / span > < span class = "p" > (< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > root_dir< / span > < span class = "p" > ,< / span > < span class = "s" > " /var/lib/lorax/composer/" < / span > < span class = "p" > )))< / span >
< span class = "n" > conf< / span > < span class = "o" > .< / span > < span class = "n" > set< / span > < span class = "p" > (< / span > < span class = "s" > " composer" < / span > < span class = "p" > ,< / span > < span class = "s" > " yum_conf" < / span > < span class = "p" > ,< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > realpath< / span > < span class = "p" > (< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > root_dir< / span > < span class = "p" > ,< / span > < span class = "s" > " /var/tmp/composer/yum.conf" < / span > < span class = "p" > )))< / span >
2018-04-25 20:25:07 +00:00
< span class = "n" > conf< / span > < span class = "o" > .< / span > < span class = "n" > set< / span > < span class = "p" > (< / span > < span class = "s" > " composer" < / span > < span class = "p" > ,< / span > < span class = "s" > " yum_root" < / span > < span class = "p" > ,< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > realpath< / span > < span class = "p" > (< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > root_dir< / span > < span class = "p" > ,< / span > < span class = "s" > " /var/tmp/composer/yum/root/" < / span > < span class = "p" > )))< / span >
2018-03-15 21:04:29 +00:00
< span class = "n" > conf< / span > < span class = "o" > .< / span > < span class = "n" > set< / span > < span class = "p" > (< / span > < span class = "s" > " composer" < / span > < span class = "p" > ,< / span > < span class = "s" > " repo_dir" < / span > < span class = "p" > ,< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > realpath< / span > < span class = "p" > (< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > root_dir< / span > < span class = "p" > ,< / span > < span class = "s" > " /var/tmp/composer/repos.d/" < / span > < span class = "p" > )))< / span >
< span class = "n" > conf< / span > < span class = "o" > .< / span > < span class = "n" > set< / span > < span class = "p" > (< / span > < span class = "s" > " composer" < / span > < span class = "p" > ,< / span > < span class = "s" > " cache_dir" < / span > < span class = "p" > ,< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > realpath< / span > < span class = "p" > (< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > root_dir< / span > < span class = "p" > ,< / span > < span class = "s" > " /var/tmp/composer/cache/" < / span > < span class = "p" > )))< / span >
< span class = "n" > conf< / span > < span class = "o" > .< / span > < span class = "n" > add_section< / span > < span class = "p" > (< / span > < span class = "s" > " users" < / span > < span class = "p" > )< / span >
< span class = "n" > conf< / span > < span class = "o" > .< / span > < span class = "n" > set< / span > < span class = "p" > (< / span > < span class = "s" > " users" < / span > < span class = "p" > ,< / span > < span class = "s" > " root" < / span > < span class = "p" > ,< / span > < span class = "s" > " 1" < / span > < span class = "p" > )< / span >
< span class = "c" > # Enable all available repo files by default< / span >
< span class = "n" > conf< / span > < span class = "o" > .< / span > < span class = "n" > add_section< / span > < span class = "p" > (< / span > < span class = "s" > " repos" < / span > < span class = "p" > )< / span >
< span class = "n" > conf< / span > < span class = "o" > .< / span > < span class = "n" > set< / span > < span class = "p" > (< / span > < span class = "s" > " repos" < / span > < span class = "p" > ,< / span > < span class = "s" > " use_system_repos" < / span > < span class = "p" > ,< / span > < span class = "s" > " 1" < / span > < span class = "p" > )< / span >
< span class = "n" > conf< / span > < span class = "o" > .< / span > < span class = "n" > set< / span > < span class = "p" > (< / span > < span class = "s" > " repos" < / span > < span class = "p" > ,< / span > < span class = "s" > " enabled" < / span > < span class = "p" > ,< / span > < span class = "s" > " *" < / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > test_config< / span > < span class = "p" > :< / span >
< span class = "c" > # read the config file< / span >
< span class = "k" > if< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > isfile< / span > < span class = "p" > (< / span > < span class = "n" > conf_file< / span > < span class = "p" > ):< / span >
< span class = "n" > conf< / span > < span class = "o" > .< / span > < span class = "n" > read< / span > < span class = "p" > (< / span > < span class = "n" > conf_file< / span > < span class = "p" > )< / span >
< span class = "k" > return< / span > < span class = "n" > conf< / span >
< / div >
< div class = "viewcode-block" id = "make_yum_dirs" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.config.make_yum_dirs" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > make_yum_dirs< / span > < span class = "p" > (< / span > < span class = "n" > conf< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Make any missing yum directories< / span >
< span class = "sd" > :param conf: The configuration to use< / span >
< span class = "sd" > :type conf: ComposerConfig< / span >
< span class = "sd" > :returns: None< / span >
< span class = "sd" > " " " < / span >
2018-04-25 20:25:07 +00:00
< span class = "k" > for< / span > < span class = "n" > p< / span > < span class = "ow" > in< / span > < span class = "p" > [< / span > < span class = "s" > " yum_conf" < / span > < span class = "p" > ,< / span > < span class = "s" > " repo_dir" < / span > < span class = "p" > ,< / span > < span class = "s" > " cache_dir" < / span > < span class = "p" > ,< / span > < span class = "s" > " yum_root" < / span > < span class = "p" > ]:< / span >
2018-03-15 21:04:29 +00:00
< span class = "n" > p_dir< / span > < span class = "o" > =< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > dirname< / span > < span class = "p" > (< / span > < span class = "n" > conf< / span > < span class = "o" > .< / span > < span class = "n" > get< / span > < span class = "p" > (< / span > < span class = "s" > " composer" < / span > < span class = "p" > ,< / span > < span class = "n" > p< / span > < span class = "p" > ))< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > exists< / span > < span class = "p" > (< / span > < span class = "n" > p_dir< / span > < span class = "p" > ):< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > makedirs< / span > < span class = "p" > (< / span > < span class = "n" > p_dir< / span > < span class = "p" > )< / span >
< / div >
< div class = "viewcode-block" id = "make_queue_dirs" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.config.make_queue_dirs" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > make_queue_dirs< / span > < span class = "p" > (< / span > < span class = "n" > conf< / span > < span class = "p" > ,< / span > < span class = "n" > gid< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Make any missing queue directories< / span >
< span class = "sd" > :param conf: The configuration to use< / span >
< span class = "sd" > :type conf: ComposerConfig< / span >
< span class = "sd" > :param gid: Group ID that has access to the queue directories< / span >
< span class = "sd" > :type gid: int< / span >
< span class = "sd" > :returns: list of errors< / span >
< span class = "sd" > :rtype: list of str< / span >
< span class = "sd" > " " " < / span >
< span class = "n" > errors< / span > < span class = "o" > =< / span > < span class = "p" > []< / span >
< span class = "n" > lib_dir< / span > < span class = "o" > =< / span > < span class = "n" > conf< / span > < span class = "o" > .< / span > < span class = "n" > get< / span > < span class = "p" > (< / span > < span class = "s" > " composer" < / span > < span class = "p" > ,< / span > < span class = "s" > " lib_dir" < / span > < span class = "p" > )< / span >
< span class = "k" > for< / span > < span class = "n" > p< / span > < span class = "ow" > in< / span > < span class = "p" > [< / span > < span class = "s" > " queue/run" < / span > < span class = "p" > ,< / span > < span class = "s" > " queue/new" < / span > < span class = "p" > ,< / span > < span class = "s" > " results" < / span > < span class = "p" > ]:< / span >
< span class = "n" > p_dir< / span > < span class = "o" > =< / span > < span class = "n" > joinpaths< / span > < span class = "p" > (< / span > < span class = "n" > lib_dir< / span > < span class = "p" > ,< / span > < span class = "n" > p< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > path< / span > < span class = "o" > .< / span > < span class = "n" > exists< / span > < span class = "p" > (< / span > < span class = "n" > p_dir< / span > < span class = "p" > ):< / span >
< span class = "n" > orig_umask< / span > < span class = "o" > =< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > umask< / span > < span class = "p" > (< / span > < span class = "mi" > 0< / span > < span class = "p" > )< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > makedirs< / span > < span class = "p" > (< / span > < span class = "n" > p_dir< / span > < span class = "p" > ,< / span > < span class = "mi" > 0< / span > < span class = "n" > o771< / span > < span class = "p" > )< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > chown< / span > < span class = "p" > (< / span > < span class = "n" > p_dir< / span > < span class = "p" > ,< / span > < span class = "mi" > 0< / span > < span class = "p" > ,< / span > < span class = "n" > gid< / span > < span class = "p" > )< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > umask< / span > < span class = "p" > (< / span > < span class = "n" > orig_umask< / span > < span class = "p" > )< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > p_stat< / span > < span class = "o" > =< / span > < span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > stat< / span > < span class = "p" > (< / span > < span class = "n" > p_dir< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > p_stat< / span > < span class = "o" > .< / span > < span class = "n" > st_mode< / span > < span class = "o" > & < / span > < span class = "mi" > 0< / span > < span class = "n" > o006< / span > < span class = "o" > !=< / span > < span class = "mi" > 0< / span > < span class = "p" > :< / span >
< span class = "n" > errors< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "s" > " Incorrect permissions on < / span > < span class = "si" > %s< / span > < span class = "s" > , no o+rw permissions are allowed." < / span > < span class = "o" > %< / span > < span class = "n" > p_dir< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > p_stat< / span > < span class = "o" > .< / span > < span class = "n" > st_gid< / span > < span class = "o" > !=< / span > < span class = "n" > gid< / span > < span class = "ow" > or< / span > < span class = "n" > p_stat< / span > < span class = "o" > .< / span > < span class = "n" > st_uid< / span > < span class = "o" > !=< / span > < span class = "mi" > 0< / span > < span class = "p" > :< / span >
< span class = "n" > gr_name< / span > < span class = "o" > =< / span > < span class = "n" > grp< / span > < span class = "o" > .< / span > < span class = "n" > getgrgid< / span > < span class = "p" > (< / span > < span class = "n" > gid< / span > < span class = "p" > )< / span > < span class = "o" > .< / span > < span class = "n" > gr_name< / span >
< span class = "n" > errors< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "s" > " < / span > < span class = "si" > %s< / span > < span class = "s" > should be owned by root:< / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "p" > (< / span > < span class = "n" > p_dir< / span > < span class = "p" > ,< / span > < span class = "n" > gr_name< / span > < span class = "p" > ))< / span >
< span class = "k" > return< / span > < span class = "n" > errors< / span > < / div >
< / pre > < / div >
< / div >
< / div >
< / div >
< div class = "sphinxsidebar" >
< div class = "sphinxsidebarwrapper" >
< div id = "searchbox" style = "display: none" >
< h3 > Quick search< / h3 >
< form class = "search" action = "../../../search.html" method = "get" >
< input type = "text" name = "q" / >
< input type = "submit" value = "Go" / >
< input type = "hidden" name = "check_keywords" value = "yes" / >
< input type = "hidden" name = "area" value = "default" / >
< / form >
< p class = "searchtip" style = "font-size: 90%" >
Enter search terms or a module, class or function name.
< / p >
< / div >
< script type = "text/javascript" > $ ( '#searchbox' ) . show ( 0 ) ; < / script >
< / div >
< / div >
< div class = "clearer" > < / div >
< / div >
< div class = "related" >
< h3 > Navigation< / h3 >
< ul >
< li class = "right" style = "margin-right: 10px" >
< a href = "../../../genindex.html" title = "General Index"
>index< / a > < / li >
< li class = "right" >
< a href = "../../../py-modindex.html" title = "Python Module Index"
>modules< / a > |< / li >
2018-04-25 20:25:07 +00:00
< li > < a href = "../../../index.html" > Lorax 19.7.14 documentation< / a > » < / li >
2018-03-15 21:04:29 +00:00
< li > < a href = "../../index.html" > Module code< / a > » < / li >
2018-03-16 23:41:16 +00:00
< li > < a href = "../../pylorax.html" > pylorax< / a > » < / li >
2018-03-15 21:04:29 +00:00
< li > < a href = "../api.html" > pylorax.api< / a > » < / li >
< / ul >
< / div >
< div class = "footer" >
2018-03-16 23:41:16 +00:00
© Copyright 2018, Red Hat, Inc..
2018-03-15 21:04:29 +00:00
Created using < a href = "http://sphinx.pocoo.org/" > Sphinx< / a > 1.1.3.
< / div >
< / body >
< / html >