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-09-06 21:14:02 +00:00
< title > pylorax.api.projects — Lorax 19.7.22 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-09-06 21:14:02 +00:00
VERSION: '19.7.22',
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-09-06 21:14:02 +00:00
< link rel = "top" title = "Lorax 19.7.22 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-09-06 21:14:02 +00:00
< li > < a href = "../../../index.html" > Lorax 19.7.22 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.projects< / 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" > logging< / span >
< span class = "n" > log< / span > < span class = "o" > =< / span > < span class = "n" > logging< / span > < span class = "o" > .< / span > < span class = "n" > getLogger< / span > < span class = "p" > (< / span > < span class = "s" > " lorax-composer" < / span > < span class = "p" > )< / span >
2018-06-29 20:46:27 +00:00
< span class = "kn" > import< / span > < span class = "nn" > os< / span >
< span class = "kn" > from< / span > < span class = "nn" > ConfigParser< / span > < span class = "kn" > import< / span > < span class = "n" > ConfigParser< / span >
< span class = "kn" > from< / span > < span class = "nn" > glob< / span > < span class = "kn" > import< / span > < span class = "n" > glob< / span >
2018-03-15 21:04:29 +00:00
< span class = "kn" > import< / span > < span class = "nn" > time< / span >
< span class = "kn" > from< / span > < span class = "nn" > yum.Errors< / span > < span class = "kn" > import< / span > < span class = "n" > YumBaseError< / span >
< span class = "n" > TIME_FORMAT< / span > < span class = "o" > =< / span > < span class = "s" > " %Y-%m-< / span > < span class = "si" > %d< / span > < span class = "s" > T%H:%M:%S" < / span >
< div class = "viewcode-block" id = "ProjectsError" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.ProjectsError" > [docs]< / a > < span class = "k" > class< / span > < span class = "nc" > ProjectsError< / span > < span class = "p" > (< / span > < span class = "ne" > Exception< / span > < span class = "p" > ):< / span >
< span class = "k" > pass< / span >
< / div >
< div class = "viewcode-block" id = "api_time" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.api_time" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > api_time< / span > < span class = "p" > (< / span > < span class = "n" > t< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Convert time since epoch to a string< / span >
< span class = "sd" > :param t: Seconds since epoch< / span >
< span class = "sd" > :type t: int< / span >
< span class = "sd" > :returns: Time string< / span >
< span class = "sd" > :rtype: str< / span >
< span class = "sd" > " " " < / span >
< span class = "k" > return< / span > < span class = "n" > time< / span > < span class = "o" > .< / span > < span class = "n" > strftime< / span > < span class = "p" > (< / span > < span class = "n" > TIME_FORMAT< / span > < span class = "p" > ,< / span > < span class = "n" > time< / span > < span class = "o" > .< / span > < span class = "n" > localtime< / span > < span class = "p" > (< / span > < span class = "n" > t< / span > < span class = "p" > ))< / span >
< / div >
< div class = "viewcode-block" id = "api_changelog" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.api_changelog" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > api_changelog< / span > < span class = "p" > (< / span > < span class = "n" > changelog< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Convert the changelog to a string< / span >
< span class = "sd" > :param changelog: A list of time, author, string tuples.< / span >
< span class = "sd" > :type changelog: tuple< / span >
< span class = "sd" > :returns: The most recent changelog text or " " < / span >
< span class = "sd" > :rtype: str< / span >
< span class = "sd" > This returns only the most recent changelog entry.< / span >
< span class = "sd" > " " " < / span >
< span class = "k" > try< / span > < span class = "p" > :< / span >
< span class = "n" > entry< / span > < span class = "o" > =< / span > < span class = "n" > changelog< / span > < span class = "p" > [< / span > < span class = "mi" > 0< / span > < span class = "p" > ][< / span > < span class = "mi" > 2< / span > < span class = "p" > ]< / span >
< span class = "k" > except< / span > < span class = "ne" > IndexError< / span > < span class = "p" > :< / span >
< span class = "n" > entry< / span > < span class = "o" > =< / span > < span class = "s" > " " < / span >
< span class = "k" > return< / span > < span class = "n" > entry< / span >
< / div >
< div class = "viewcode-block" id = "yaps_to_project" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.yaps_to_project" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > yaps_to_project< / span > < span class = "p" > (< / span > < span class = "n" > yaps< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Extract the details from a YumAvailablePackageSqlite object< / span >
< span class = "sd" > :param yaps: Yum object with package details< / span >
< span class = "sd" > :type yaps: YumAvailablePackageSqlite< / span >
< span class = "sd" > :returns: A dict with the name, summary, description, and url.< / span >
< span class = "sd" > :rtype: dict< / span >
< span class = "sd" > upstream_vcs is hard-coded to UPSTREAM_VCS< / span >
< span class = "sd" > " " " < / span >
< span class = "k" > return< / span > < span class = "p" > {< / span > < span class = "s" > " name" < / span > < span class = "p" > :< / span > < span class = "n" > yaps< / span > < span class = "o" > .< / span > < span class = "n" > name< / span > < span class = "p" > ,< / span >
< span class = "s" > " summary" < / span > < span class = "p" > :< / span > < span class = "n" > yaps< / span > < span class = "o" > .< / span > < span class = "n" > summary< / span > < span class = "p" > ,< / span >
< span class = "s" > " description" < / span > < span class = "p" > :< / span > < span class = "n" > yaps< / span > < span class = "o" > .< / span > < span class = "n" > description< / span > < span class = "p" > ,< / span >
< span class = "s" > " homepage" < / span > < span class = "p" > :< / span > < span class = "n" > yaps< / span > < span class = "o" > .< / span > < span class = "n" > url< / span > < span class = "p" > ,< / span >
< span class = "s" > " upstream_vcs" < / span > < span class = "p" > :< / span > < span class = "s" > " UPSTREAM_VCS" < / span > < span class = "p" > }< / span >
< / div >
< div class = "viewcode-block" id = "yaps_to_project_info" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.yaps_to_project_info" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > yaps_to_project_info< / span > < span class = "p" > (< / span > < span class = "n" > yaps< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Extract the details from a YumAvailablePackageSqlite object< / span >
< span class = "sd" > :param yaps: Yum object with package details< / span >
< span class = "sd" > :type yaps: YumAvailablePackageSqlite< / span >
< span class = "sd" > :returns: A dict with the project details, as well as epoch, release, arch, build_time, changelog, ...< / span >
< span class = "sd" > :rtype: dict< / span >
< span class = "sd" > metadata entries are hard-coded to {}< / span >
< span class = "sd" > " " " < / span >
2018-04-25 20:25:07 +00:00
< span class = "n" > build< / span > < span class = "o" > =< / span > < span class = "p" > {< / span > < span class = "s" > " epoch" < / span > < span class = "p" > :< / span > < span class = "nb" > int< / span > < span class = "p" > (< / span > < span class = "n" > yaps< / span > < span class = "o" > .< / span > < span class = "n" > epoch< / span > < span class = "p" > ),< / span >
2018-03-15 21:04:29 +00:00
< span class = "s" > " release" < / span > < span class = "p" > :< / span > < span class = "n" > yaps< / span > < span class = "o" > .< / span > < span class = "n" > release< / span > < span class = "p" > ,< / span >
< span class = "s" > " arch" < / span > < span class = "p" > :< / span > < span class = "n" > yaps< / span > < span class = "o" > .< / span > < span class = "n" > arch< / span > < span class = "p" > ,< / span >
< span class = "s" > " build_time" < / span > < span class = "p" > :< / span > < span class = "n" > api_time< / span > < span class = "p" > (< / span > < span class = "n" > yaps< / span > < span class = "o" > .< / span > < span class = "n" > buildtime< / span > < span class = "p" > ),< / span >
< span class = "s" > " changelog" < / span > < span class = "p" > :< / span > < span class = "n" > api_changelog< / span > < span class = "p" > (< / span > < span class = "n" > yaps< / span > < span class = "o" > .< / span > < span class = "n" > returnChangelog< / span > < span class = "p" > ()),< / span >
< span class = "s" > " build_config_ref" < / span > < span class = "p" > :< / span > < span class = "s" > " BUILD_CONFIG_REF" < / span > < span class = "p" > ,< / span >
< span class = "s" > " build_env_ref" < / span > < span class = "p" > :< / span > < span class = "s" > " BUILD_ENV_REF" < / span > < span class = "p" > ,< / span >
< span class = "s" > " metadata" < / span > < span class = "p" > :< / span > < span class = "p" > {},< / span >
< span class = "s" > " source" < / span > < span class = "p" > :< / span > < span class = "p" > {< / span > < span class = "s" > " license" < / span > < span class = "p" > :< / span > < span class = "n" > yaps< / span > < span class = "o" > .< / span > < span class = "n" > license< / span > < span class = "p" > ,< / span >
< span class = "s" > " version" < / span > < span class = "p" > :< / span > < span class = "n" > yaps< / span > < span class = "o" > .< / span > < span class = "n" > version< / span > < span class = "p" > ,< / span >
< span class = "s" > " source_ref" < / span > < span class = "p" > :< / span > < span class = "s" > " SOURCE_REF" < / span > < span class = "p" > ,< / span >
< span class = "s" > " metadata" < / span > < span class = "p" > :< / span > < span class = "p" > {}}}< / span >
< span class = "k" > return< / span > < span class = "p" > {< / span > < span class = "s" > " name" < / span > < span class = "p" > :< / span > < span class = "n" > yaps< / span > < span class = "o" > .< / span > < span class = "n" > name< / span > < span class = "p" > ,< / span >
< span class = "s" > " summary" < / span > < span class = "p" > :< / span > < span class = "n" > yaps< / span > < span class = "o" > .< / span > < span class = "n" > summary< / span > < span class = "p" > ,< / span >
< span class = "s" > " description" < / span > < span class = "p" > :< / span > < span class = "n" > yaps< / span > < span class = "o" > .< / span > < span class = "n" > description< / span > < span class = "p" > ,< / span >
< span class = "s" > " homepage" < / span > < span class = "p" > :< / span > < span class = "n" > yaps< / span > < span class = "o" > .< / span > < span class = "n" > url< / span > < span class = "p" > ,< / span >
< span class = "s" > " upstream_vcs" < / span > < span class = "p" > :< / span > < span class = "s" > " UPSTREAM_VCS" < / span > < span class = "p" > ,< / span >
< span class = "s" > " builds" < / span > < span class = "p" > :< / span > < span class = "p" > [< / span > < span class = "n" > build< / span > < span class = "p" > ]}< / span >
< / div >
< div class = "viewcode-block" id = "tm_to_dep" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.tm_to_dep" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > tm_to_dep< / span > < span class = "p" > (< / span > < span class = "n" > tm< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Extract the info from a TransactionMember object< / span >
< span class = "sd" > :param tm: A Yum transaction object< / span >
< span class = "sd" > :type tm: TransactionMember< / span >
< span class = "sd" > :returns: A dict with name, epoch, version, release, arch< / span >
< span class = "sd" > :rtype: dict< / span >
< span class = "sd" > " " " < / span >
< span class = "k" > return< / span > < span class = "p" > {< / span > < span class = "s" > " name" < / span > < span class = "p" > :< / span > < span class = "n" > tm< / span > < span class = "o" > .< / span > < span class = "n" > name< / span > < span class = "p" > ,< / span >
2018-04-25 20:25:07 +00:00
< span class = "s" > " epoch" < / span > < span class = "p" > :< / span > < span class = "nb" > int< / span > < span class = "p" > (< / span > < span class = "n" > tm< / span > < span class = "o" > .< / span > < span class = "n" > epoch< / span > < span class = "p" > ),< / span >
2018-03-15 21:04:29 +00:00
< span class = "s" > " version" < / span > < span class = "p" > :< / span > < span class = "n" > tm< / span > < span class = "o" > .< / span > < span class = "n" > version< / span > < span class = "p" > ,< / span >
< span class = "s" > " release" < / span > < span class = "p" > :< / span > < span class = "n" > tm< / span > < span class = "o" > .< / span > < span class = "n" > release< / span > < span class = "p" > ,< / span >
< span class = "s" > " arch" < / span > < span class = "p" > :< / span > < span class = "n" > tm< / span > < span class = "o" > .< / span > < span class = "n" > arch< / span > < span class = "p" > }< / span >
< / div >
< div class = "viewcode-block" id = "yaps_to_module" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.yaps_to_module" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > yaps_to_module< / span > < span class = "p" > (< / span > < span class = "n" > yaps< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Extract the name from a YumAvailablePackageSqlite object< / span >
< span class = "sd" > :param yaps: Yum object with package details< / span >
< span class = "sd" > :type yaps: YumAvailablePackageSqlite< / span >
< span class = "sd" > :returns: A dict with name, and group_type< / span >
< span class = "sd" > :rtype: dict< / span >
< span class = "sd" > group_type is hard-coded to " rpm" < / span >
< span class = "sd" > " " " < / span >
< span class = "k" > return< / span > < span class = "p" > {< / span > < span class = "s" > " name" < / span > < span class = "p" > :< / span > < span class = "n" > yaps< / span > < span class = "o" > .< / span > < span class = "n" > name< / span > < span class = "p" > ,< / span >
< span class = "s" > " group_type" < / span > < span class = "p" > :< / span > < span class = "s" > " rpm" < / span > < span class = "p" > }< / span >
< / div >
< div class = "viewcode-block" id = "dep_evra" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.dep_evra" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > dep_evra< / span > < span class = "p" > (< / span > < span class = "n" > dep< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Return the epoch:version-release.arch for the dep< / span >
< span class = "sd" > :param dep: dependency dict< / span >
< span class = "sd" > :type dep: dict< / span >
< span class = "sd" > :returns: epoch:version-release.arch< / span >
< span class = "sd" > :rtype: str< / span >
< span class = "sd" > " " " < / span >
2018-04-25 20:25:07 +00:00
< span class = "k" > if< / span > < span class = "n" > dep< / span > < span class = "p" > [< / span > < span class = "s" > " epoch" < / span > < span class = "p" > ]< / span > < span class = "o" > ==< / span > < span class = "mi" > 0< / span > < span class = "p" > :< / span >
2018-03-15 21:04:29 +00:00
< span class = "k" > return< / span > < span class = "n" > dep< / span > < span class = "p" > [< / span > < span class = "s" > " version" < / span > < span class = "p" > ]< / span > < span class = "o" > +< / span > < span class = "s" > " -" < / span > < span class = "o" > +< / span > < span class = "n" > dep< / span > < span class = "p" > [< / span > < span class = "s" > " release" < / span > < span class = "p" > ]< / span > < span class = "o" > +< / span > < span class = "s" > " ." < / span > < span class = "o" > +< / span > < span class = "n" > dep< / span > < span class = "p" > [< / span > < span class = "s" > " arch" < / span > < span class = "p" > ]< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
2018-04-25 20:25:07 +00:00
< span class = "k" > return< / span > < span class = "nb" > str< / span > < span class = "p" > (< / span > < span class = "n" > dep< / span > < span class = "p" > [< / span > < span class = "s" > " epoch" < / span > < span class = "p" > ])< / span > < span class = "o" > +< / span > < span class = "s" > " :" < / span > < span class = "o" > +< / span > < span class = "n" > dep< / span > < span class = "p" > [< / span > < span class = "s" > " version" < / span > < span class = "p" > ]< / span > < span class = "o" > +< / span > < span class = "s" > " -" < / span > < span class = "o" > +< / span > < span class = "n" > dep< / span > < span class = "p" > [< / span > < span class = "s" > " release" < / span > < span class = "p" > ]< / span > < span class = "o" > +< / span > < span class = "s" > " ." < / span > < span class = "o" > +< / span > < span class = "n" > dep< / span > < span class = "p" > [< / span > < span class = "s" > " arch" < / span > < span class = "p" > ]< / span >
2018-03-15 21:04:29 +00:00
< / div >
< div class = "viewcode-block" id = "dep_nevra" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.dep_nevra" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > dep_nevra< / span > < span class = "p" > (< / span > < span class = "n" > dep< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Return the name-epoch:version-release.arch" " " < / span >
< span class = "k" > return< / span > < span class = "n" > dep< / span > < span class = "p" > [< / span > < span class = "s" > " name" < / span > < span class = "p" > ]< / span > < span class = "o" > +< / span > < span class = "s" > " -" < / span > < span class = "o" > +< / span > < span class = "n" > dep_evra< / span > < span class = "p" > (< / span > < span class = "n" > dep< / span > < span class = "p" > )< / span >
< / div >
< div class = "viewcode-block" id = "projects_list" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.projects_list" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > projects_list< / span > < span class = "p" > (< / span > < span class = "n" > yb< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Return a list of projects< / span >
< span class = "sd" > :param yb: yum base object< / span >
< span class = "sd" > :type yb: YumBase< / span >
< span class = "sd" > :returns: List of project info dicts with name, summary, description, homepage, upstream_vcs< / span >
< span class = "sd" > :rtype: list of dicts< / span >
< span class = "sd" > " " " < / span >
< span class = "k" > try< / span > < span class = "p" > :< / span >
< span class = "n" > ybl< / span > < span class = "o" > =< / span > < span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > doPackageLists< / span > < span class = "p" > (< / span > < span class = "n" > pkgnarrow< / span > < span class = "o" > =< / span > < span class = "s" > " available" < / span > < span class = "p" > ,< / span > < span class = "n" > showdups< / span > < span class = "o" > =< / span > < span class = "bp" > False< / span > < span class = "p" > )< / span >
< span class = "k" > except< / span > < span class = "n" > YumBaseError< / span > < span class = "k" > as< / span > < span class = "n" > e< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "n" > ProjectsError< / span > < span class = "p" > (< / span > < span class = "s" > " There was a problem listing projects: < / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "nb" > str< / span > < span class = "p" > (< / span > < span class = "n" > e< / span > < span class = "p" > ))< / span >
< span class = "k" > finally< / span > < span class = "p" > :< / span >
< span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > closeRpmDB< / span > < span class = "p" > ()< / span >
< span class = "k" > return< / span > < span class = "nb" > sorted< / span > < span class = "p" > (< / span > < span class = "nb" > map< / span > < span class = "p" > (< / span > < span class = "n" > yaps_to_project< / span > < span class = "p" > ,< / span > < span class = "n" > ybl< / span > < span class = "o" > .< / span > < span class = "n" > available< / span > < span class = "p" > ),< / span > < span class = "n" > key< / span > < span class = "o" > =< / span > < span class = "k" > lambda< / span > < span class = "n" > p< / span > < span class = "p" > :< / span > < span class = "n" > p< / span > < span class = "p" > [< / span > < span class = "s" > " name" < / span > < span class = "p" > ]< / span > < span class = "o" > .< / span > < span class = "n" > lower< / span > < span class = "p" > ())< / span >
< / div >
< div class = "viewcode-block" id = "projects_info" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.projects_info" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > projects_info< / span > < span class = "p" > (< / span > < span class = "n" > yb< / span > < span class = "p" > ,< / span > < span class = "n" > project_names< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Return details about specific projects< / span >
< span class = "sd" > :param yb: yum base object< / span >
< span class = "sd" > :type yb: YumBase< / span >
< span class = "sd" > :param project_names: List of names of projects to get info about< / span >
< span class = "sd" > :type project_names: str< / span >
< span class = "sd" > :returns: List of project info dicts with yaps_to_project as well as epoch, version, release, etc.< / span >
< span class = "sd" > :rtype: list of dicts< / span >
< span class = "sd" > " " " < / span >
< span class = "k" > try< / span > < span class = "p" > :< / span >
< span class = "n" > ybl< / span > < span class = "o" > =< / span > < span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > doPackageLists< / span > < span class = "p" > (< / span > < span class = "n" > pkgnarrow< / span > < span class = "o" > =< / span > < span class = "s" > " available" < / span > < span class = "p" > ,< / span > < span class = "n" > patterns< / span > < span class = "o" > =< / span > < span class = "n" > project_names< / span > < span class = "p" > ,< / span > < span class = "n" > showdups< / span > < span class = "o" > =< / span > < span class = "bp" > False< / span > < span class = "p" > )< / span >
< span class = "k" > except< / span > < span class = "n" > YumBaseError< / span > < span class = "k" > as< / span > < span class = "n" > e< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "n" > ProjectsError< / span > < span class = "p" > (< / span > < span class = "s" > " There was a problem with info for < / span > < span class = "si" > %s< / span > < span class = "s" > : < / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "p" > (< / span > < span class = "n" > project_names< / span > < span class = "p" > ,< / span > < span class = "nb" > str< / span > < span class = "p" > (< / span > < span class = "n" > e< / span > < span class = "p" > )))< / span >
< span class = "k" > finally< / span > < span class = "p" > :< / span >
< span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > closeRpmDB< / span > < span class = "p" > ()< / span >
< span class = "k" > return< / span > < span class = "nb" > sorted< / span > < span class = "p" > (< / span > < span class = "nb" > map< / span > < span class = "p" > (< / span > < span class = "n" > yaps_to_project_info< / span > < span class = "p" > ,< / span > < span class = "n" > ybl< / span > < span class = "o" > .< / span > < span class = "n" > available< / span > < span class = "p" > ),< / span > < span class = "n" > key< / span > < span class = "o" > =< / span > < span class = "k" > lambda< / span > < span class = "n" > p< / span > < span class = "p" > :< / span > < span class = "n" > p< / span > < span class = "p" > [< / span > < span class = "s" > " name" < / span > < span class = "p" > ]< / span > < span class = "o" > .< / span > < span class = "n" > lower< / span > < span class = "p" > ())< / span >
< / div >
2018-08-14 00:00:02 +00:00
< div class = "viewcode-block" id = "projects_depsolve" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.projects_depsolve" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > projects_depsolve< / span > < span class = "p" > (< / span > < span class = "n" > yb< / span > < span class = "p" > ,< / span > < span class = "n" > projects< / span > < span class = "p" > ,< / span > < span class = "n" > groups< / span > < span class = "p" > ):< / span >
2018-03-15 21:04:29 +00:00
< span class = "sd" > " " " Return the dependencies for a list of projects< / span >
< span class = "sd" > :param yb: yum base object< / span >
< span class = "sd" > :type yb: YumBase< / span >
2018-06-29 20:46:27 +00:00
< span class = "sd" > :param projects: The projects and version globs to find the dependencies for< / span >
< span class = "sd" > :type projects: List of tuples< / span >
2018-08-14 00:00:02 +00:00
< span class = "sd" > :param groups: The groups to include in dependency solving< / span >
< span class = "sd" > :type groups: List of str< / span >
2018-03-15 21:04:29 +00:00
< span class = "sd" > :returns: NEVRA' s of the project and its dependencies< / span >
< span class = "sd" > :rtype: list of dicts< / span >
2018-06-29 20:46:27 +00:00
< span class = "sd" > :raises: ProjectsError if there was a problem installing something< / span >
2018-03-15 21:04:29 +00:00
< span class = "sd" > " " " < / span >
< span class = "k" > try< / span > < span class = "p" > :< / span >
< span class = "c" > # This resets the transaction< / span >
< span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > closeRpmDB< / span > < span class = "p" > ()< / span >
2018-08-14 00:00:02 +00:00
< span class = "n" > install_errors< / span > < span class = "o" > =< / span > < span class = "p" > []< / span >
< span class = "k" > for< / span > < span class = "n" > name< / span > < span class = "ow" > in< / span > < span class = "n" > groups< / span > < span class = "p" > :< / span >
< span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > selectGroup< / span > < span class = "p" > (< / span > < span class = "n" > name< / span > < span class = "p" > ,< / span > < span class = "p" > [< / span > < span class = "s" > " mandatory" < / span > < span class = "p" > ,< / span > < span class = "s" > " default" < / span > < span class = "p" > ])< / span >
2018-06-29 20:46:27 +00:00
< span class = "k" > for< / span > < span class = "n" > name< / span > < span class = "p" > ,< / span > < span class = "n" > version< / span > < span class = "ow" > in< / span > < span class = "n" > projects< / span > < span class = "p" > :< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > version< / span > < span class = "p" > :< / span >
< span class = "n" > version< / span > < span class = "o" > =< / span > < span class = "s" > " *" < / span >
2018-08-14 00:00:02 +00:00
< span class = "n" > pattern< / span > < span class = "o" > =< / span > < span class = "s" > " < / span > < span class = "si" > %s< / span > < span class = "s" > -< / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "p" > (< / span > < span class = "n" > name< / span > < span class = "p" > ,< / span > < span class = "n" > version< / span > < span class = "p" > )< / span >
< span class = "k" > try< / span > < span class = "p" > :< / span >
< span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > install< / span > < span class = "p" > (< / span > < span class = "n" > pattern< / span > < span class = "o" > =< / span > < span class = "n" > pattern< / span > < span class = "p" > )< / span >
< span class = "k" > except< / span > < span class = "n" > YumBaseError< / span > < span class = "k" > as< / span > < span class = "n" > e< / span > < span class = "p" > :< / span >
< span class = "n" > install_errors< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > ((< / span > < span class = "n" > pattern< / span > < span class = "p" > ,< / span > < span class = "nb" > str< / span > < span class = "p" > (< / span > < span class = "n" > e< / span > < span class = "p" > )))< / span >
< span class = "c" > # Were there problems installing these packages?< / span >
< span class = "k" > if< / span > < span class = "n" > install_errors< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "n" > ProjectsError< / span > < span class = "p" > (< / span > < span class = "s" > " The following package(s) had problems: < / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "s" > " ," < / span > < span class = "o" > .< / span > < span class = "n" > join< / span > < span class = "p" > ([< / span > < span class = "s" > " < / span > < span class = "si" > %s< / span > < span class = "s" > (< / span > < span class = "si" > %s< / span > < span class = "s" > )" < / span > < span class = "o" > %< / span > < span class = "p" > (< / span > < span class = "n" > pattern< / span > < span class = "p" > ,< / span > < span class = "n" > err< / span > < span class = "p" > )< / span > < span class = "k" > for< / span > < span class = "n" > pattern< / span > < span class = "p" > ,< / span > < span class = "n" > err< / span > < span class = "ow" > in< / span > < span class = "n" > install_errors< / span > < span class = "p" > ]))< / span >
2018-03-15 21:04:29 +00:00
< span class = "p" > (< / span > < span class = "n" > rc< / span > < span class = "p" > ,< / span > < span class = "n" > msg< / span > < span class = "p" > )< / span > < span class = "o" > =< / span > < span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > buildTransaction< / span > < span class = "p" > ()< / span >
< span class = "k" > if< / span > < span class = "n" > rc< / span > < span class = "ow" > not< / span > < span class = "ow" > in< / span > < span class = "p" > [< / span > < span class = "mi" > 0< / span > < span class = "p" > ,< / span > < span class = "mi" > 1< / span > < span class = "p" > ,< / span > < span class = "mi" > 2< / span > < span class = "p" > ]:< / span >
2018-06-29 20:46:27 +00:00
< span class = "k" > raise< / span > < span class = "n" > ProjectsError< / span > < span class = "p" > (< / span > < span class = "s" > " There was a problem depsolving < / span > < span class = "si" > %s< / span > < span class = "s" > : < / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "p" > (< / span > < span class = "n" > projects< / span > < span class = "p" > ,< / span > < span class = "n" > msg< / span > < span class = "p" > ))< / span >
2018-03-15 21:04:29 +00:00
< span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > tsInfo< / span > < span class = "o" > .< / span > < span class = "n" > makelists< / span > < span class = "p" > ()< / span >
< span class = "n" > deps< / span > < span class = "o" > =< / span > < span class = "nb" > sorted< / span > < span class = "p" > (< / span > < span class = "nb" > map< / span > < span class = "p" > (< / span > < span class = "n" > tm_to_dep< / span > < span class = "p" > ,< / span > < span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > tsInfo< / span > < span class = "o" > .< / span > < span class = "n" > installed< / span > < span class = "o" > +< / span > < span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > tsInfo< / span > < span class = "o" > .< / span > < span class = "n" > depinstalled< / span > < span class = "p" > ),< / span > < span class = "n" > key< / span > < span class = "o" > =< / span > < span class = "k" > lambda< / span > < span class = "n" > p< / span > < span class = "p" > :< / span > < span class = "n" > p< / span > < span class = "p" > [< / span > < span class = "s" > " name" < / span > < span class = "p" > ]< / span > < span class = "o" > .< / span > < span class = "n" > lower< / span > < span class = "p" > ())< / span >
< span class = "k" > except< / span > < span class = "n" > YumBaseError< / span > < span class = "k" > as< / span > < span class = "n" > e< / span > < span class = "p" > :< / span >
2018-06-29 20:46:27 +00:00
< span class = "k" > raise< / span > < span class = "n" > ProjectsError< / span > < span class = "p" > (< / span > < span class = "s" > " There was a problem depsolving < / span > < span class = "si" > %s< / span > < span class = "s" > : < / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "p" > (< / span > < span class = "n" > projects< / span > < span class = "p" > ,< / span > < span class = "nb" > str< / span > < span class = "p" > (< / span > < span class = "n" > e< / span > < span class = "p" > )))< / span >
2018-03-15 21:04:29 +00:00
< span class = "k" > finally< / span > < span class = "p" > :< / span >
< span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > closeRpmDB< / span > < span class = "p" > ()< / span >
< span class = "k" > return< / span > < span class = "n" > deps< / span >
2018-04-25 20:25:07 +00:00
< / div >
< div class = "viewcode-block" id = "estimate_size" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.estimate_size" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > estimate_size< / span > < span class = "p" > (< / span > < span class = "n" > packages< / span > < span class = "p" > ,< / span > < span class = "n" > block_size< / span > < span class = "o" > =< / span > < span class = "mi" > 4096< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Estimate the installed size of a package list< / span >
< span class = "sd" > :param packages: The packages to be installed< / span >
< span class = "sd" > :type packages: list of TransactionMember objects< / span >
< span class = "sd" > :param block_size: The block size to use for rounding up file sizes.< / span >
< span class = "sd" > :type block_size: int< / span >
< span class = "sd" > :returns: The estimated size of installed packages< / span >
< span class = "sd" > :rtype: int< / span >
< span class = "sd" > Estimating actual requirements is difficult without the actual file sizes, which< / span >
< span class = "sd" > yum doesn' t provide access to. So use the file count and block size to estimate< / span >
< span class = "sd" > a minimum size for each package.< / span >
< span class = "sd" > " " " < / span >
< span class = "n" > installed_size< / span > < span class = "o" > =< / span > < span class = "mi" > 0< / span >
< span class = "k" > for< / span > < span class = "n" > p< / span > < span class = "ow" > in< / span > < span class = "n" > packages< / span > < span class = "p" > :< / span >
< span class = "n" > installed_size< / span > < span class = "o" > +=< / span > < span class = "nb" > len< / span > < span class = "p" > (< / span > < span class = "n" > p< / span > < span class = "o" > .< / span > < span class = "n" > po< / span > < span class = "o" > .< / span > < span class = "n" > filelist< / span > < span class = "p" > )< / span > < span class = "o" > *< / span > < span class = "n" > block_size< / span >
< span class = "n" > installed_size< / span > < span class = "o" > +=< / span > < span class = "n" > p< / span > < span class = "o" > .< / span > < span class = "n" > po< / span > < span class = "o" > .< / span > < span class = "n" > installedsize< / span >
< span class = "k" > return< / span > < span class = "n" > installed_size< / span >
< / div >
2018-08-14 00:00:02 +00:00
< div class = "viewcode-block" id = "projects_depsolve_with_size" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.projects_depsolve_with_size" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > projects_depsolve_with_size< / span > < span class = "p" > (< / span > < span class = "n" > yb< / span > < span class = "p" > ,< / span > < span class = "n" > projects< / span > < span class = "p" > ,< / span > < span class = "n" > groups< / span > < span class = "p" > ,< / span > < span class = "n" > with_core< / span > < span class = "o" > =< / span > < span class = "bp" > True< / span > < span class = "p" > ):< / span >
2018-04-25 20:25:07 +00:00
< span class = "sd" > " " " Return the dependencies and installed size for a list of projects< / span >
2018-03-15 21:04:29 +00:00
2018-04-25 20:25:07 +00:00
< span class = "sd" > :param yb: yum base object< / span >
< span class = "sd" > :type yb: YumBase< / span >
2018-06-29 20:46:27 +00:00
< span class = "sd" > :param projects: The projects and version globs to find the dependencies for< / span >
< span class = "sd" > :type projects: List of tuples< / span >
2018-08-14 00:00:02 +00:00
< span class = "sd" > :param groups: The groups to include in dependency solving< / span >
< span class = "sd" > :type groups: List of str< / span >
2018-04-25 20:25:07 +00:00
< span class = "sd" > :returns: installed size and a list of NEVRA' s of the project and its dependencies< / span >
< span class = "sd" > :rtype: tuple of (int, list of dicts)< / span >
2018-06-29 20:46:27 +00:00
< span class = "sd" > :raises: ProjectsError if there was a problem installing something< / span >
2018-04-25 20:25:07 +00:00
< span class = "sd" > " " " < / span >
< span class = "k" > try< / span > < span class = "p" > :< / span >
< span class = "c" > # This resets the transaction< / span >
< span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > closeRpmDB< / span > < span class = "p" > ()< / span >
2018-08-14 00:00:02 +00:00
< span class = "n" > install_errors< / span > < span class = "o" > =< / span > < span class = "p" > []< / span >
< span class = "k" > for< / span > < span class = "n" > name< / span > < span class = "ow" > in< / span > < span class = "n" > groups< / span > < span class = "p" > :< / span >
< span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > selectGroup< / span > < span class = "p" > (< / span > < span class = "n" > name< / span > < span class = "p" > ,< / span > < span class = "p" > [< / span > < span class = "s" > " mandatory" < / span > < span class = "p" > ,< / span > < span class = "s" > " default" < / span > < span class = "p" > ])< / span >
2018-06-29 20:46:27 +00:00
< span class = "k" > for< / span > < span class = "n" > name< / span > < span class = "p" > ,< / span > < span class = "n" > version< / span > < span class = "ow" > in< / span > < span class = "n" > projects< / span > < span class = "p" > :< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > version< / span > < span class = "p" > :< / span >
< span class = "n" > version< / span > < span class = "o" > =< / span > < span class = "s" > " *" < / span >
2018-08-14 00:00:02 +00:00
< span class = "n" > pattern< / span > < span class = "o" > =< / span > < span class = "s" > " < / span > < span class = "si" > %s< / span > < span class = "s" > -< / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "p" > (< / span > < span class = "n" > name< / span > < span class = "p" > ,< / span > < span class = "n" > version< / span > < span class = "p" > )< / span >
< span class = "k" > try< / span > < span class = "p" > :< / span >
< span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > install< / span > < span class = "p" > (< / span > < span class = "n" > pattern< / span > < span class = "o" > =< / span > < span class = "n" > pattern< / span > < span class = "p" > )< / span >
< span class = "k" > except< / span > < span class = "n" > YumBaseError< / span > < span class = "k" > as< / span > < span class = "n" > e< / span > < span class = "p" > :< / span >
< span class = "n" > install_errors< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > ((< / span > < span class = "n" > pattern< / span > < span class = "p" > ,< / span > < span class = "nb" > str< / span > < span class = "p" > (< / span > < span class = "n" > e< / span > < span class = "p" > )))< / span >
< span class = "c" > # Were there problems installing these packages?< / span >
< span class = "k" > if< / span > < span class = "n" > install_errors< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "n" > ProjectsError< / span > < span class = "p" > (< / span > < span class = "s" > " The following package(s) had problems: < / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "s" > " ," < / span > < span class = "o" > .< / span > < span class = "n" > join< / span > < span class = "p" > ([< / span > < span class = "s" > " < / span > < span class = "si" > %s< / span > < span class = "s" > (< / span > < span class = "si" > %s< / span > < span class = "s" > )" < / span > < span class = "o" > %< / span > < span class = "p" > (< / span > < span class = "n" > pattern< / span > < span class = "p" > ,< / span > < span class = "n" > err< / span > < span class = "p" > )< / span > < span class = "k" > for< / span > < span class = "n" > pattern< / span > < span class = "p" > ,< / span > < span class = "n" > err< / span > < span class = "ow" > in< / span > < span class = "n" > install_errors< / span > < span class = "p" > ]))< / span >
2018-04-25 20:25:07 +00:00
< span class = "k" > if< / span > < span class = "n" > with_core< / span > < span class = "p" > :< / span >
< span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > selectGroup< / span > < span class = "p" > (< / span > < span class = "s" > " core" < / span > < span class = "p" > ,< / span > < span class = "n" > group_package_types< / span > < span class = "o" > =< / span > < span class = "p" > [< / span > < span class = "s" > ' mandatory' < / span > < span class = "p" > ,< / span > < span class = "s" > ' default' < / span > < span class = "p" > ,< / span > < span class = "s" > ' optional' < / span > < span class = "p" > ])< / span >
< span class = "p" > (< / span > < span class = "n" > rc< / span > < span class = "p" > ,< / span > < span class = "n" > msg< / span > < span class = "p" > )< / span > < span class = "o" > =< / span > < span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > buildTransaction< / span > < span class = "p" > ()< / span >
< span class = "k" > if< / span > < span class = "n" > rc< / span > < span class = "ow" > not< / span > < span class = "ow" > in< / span > < span class = "p" > [< / span > < span class = "mi" > 0< / span > < span class = "p" > ,< / span > < span class = "mi" > 1< / span > < span class = "p" > ,< / span > < span class = "mi" > 2< / span > < span class = "p" > ]:< / span >
2018-06-29 20:46:27 +00:00
< span class = "k" > raise< / span > < span class = "n" > ProjectsError< / span > < span class = "p" > (< / span > < span class = "s" > " There was a problem depsolving < / span > < span class = "si" > %s< / span > < span class = "s" > : < / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "p" > (< / span > < span class = "n" > projects< / span > < span class = "p" > ,< / span > < span class = "n" > msg< / span > < span class = "p" > ))< / span >
2018-04-25 20:25:07 +00:00
< span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > tsInfo< / span > < span class = "o" > .< / span > < span class = "n" > makelists< / span > < span class = "p" > ()< / span >
< span class = "n" > installed_size< / span > < span class = "o" > =< / span > < span class = "n" > estimate_size< / span > < span class = "p" > (< / span > < span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > tsInfo< / span > < span class = "o" > .< / span > < span class = "n" > installed< / span > < span class = "o" > +< / span > < span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > tsInfo< / span > < span class = "o" > .< / span > < span class = "n" > depinstalled< / span > < span class = "p" > )< / span >
< span class = "n" > deps< / span > < span class = "o" > =< / span > < span class = "nb" > sorted< / span > < span class = "p" > (< / span > < span class = "nb" > map< / span > < span class = "p" > (< / span > < span class = "n" > tm_to_dep< / span > < span class = "p" > ,< / span > < span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > tsInfo< / span > < span class = "o" > .< / span > < span class = "n" > installed< / span > < span class = "o" > +< / span > < span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > tsInfo< / span > < span class = "o" > .< / span > < span class = "n" > depinstalled< / span > < span class = "p" > ),< / span > < span class = "n" > key< / span > < span class = "o" > =< / span > < span class = "k" > lambda< / span > < span class = "n" > p< / span > < span class = "p" > :< / span > < span class = "n" > p< / span > < span class = "p" > [< / span > < span class = "s" > " name" < / span > < span class = "p" > ]< / span > < span class = "o" > .< / span > < span class = "n" > lower< / span > < span class = "p" > ())< / span >
< span class = "k" > except< / span > < span class = "n" > YumBaseError< / span > < span class = "k" > as< / span > < span class = "n" > e< / span > < span class = "p" > :< / span >
2018-06-29 20:46:27 +00:00
< span class = "k" > raise< / span > < span class = "n" > ProjectsError< / span > < span class = "p" > (< / span > < span class = "s" > " There was a problem depsolving < / span > < span class = "si" > %s< / span > < span class = "s" > : < / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "p" > (< / span > < span class = "n" > projects< / span > < span class = "p" > ,< / span > < span class = "nb" > str< / span > < span class = "p" > (< / span > < span class = "n" > e< / span > < span class = "p" > )))< / span >
2018-04-25 20:25:07 +00:00
< span class = "k" > finally< / span > < span class = "p" > :< / span >
< span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > closeRpmDB< / span > < span class = "p" > ()< / span >
< span class = "k" > return< / span > < span class = "p" > (< / span > < span class = "n" > installed_size< / span > < span class = "p" > ,< / span > < span class = "n" > deps< / span > < span class = "p" > )< / span >
2018-03-15 21:04:29 +00:00
< / div >
< div class = "viewcode-block" id = "modules_list" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.modules_list" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > modules_list< / span > < span class = "p" > (< / span > < span class = "n" > yb< / span > < span class = "p" > ,< / span > < span class = "n" > module_names< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Return a list of modules< / span >
< span class = "sd" > :param yb: yum base object< / span >
< span class = "sd" > :type yb: YumBase< / span >
< span class = "sd" > :param offset: Number of modules to skip< / span >
< span class = "sd" > :type limit: int< / span >
< span class = "sd" > :param limit: Maximum number of modules to return< / span >
< span class = "sd" > :type limit: int< / span >
< span class = "sd" > :returns: List of module information and total count< / span >
< span class = "sd" > :rtype: tuple of a list of dicts and an Int< / span >
< span class = "sd" > Modules don' t exist in RHEL7 so this only returns projects< / span >
< span class = "sd" > and sets the type to " rpm" < / span >
< span class = "sd" > " " " < / span >
< span class = "k" > try< / span > < span class = "p" > :< / span >
< span class = "n" > ybl< / span > < span class = "o" > =< / span > < span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > doPackageLists< / span > < span class = "p" > (< / span > < span class = "n" > pkgnarrow< / span > < span class = "o" > =< / span > < span class = "s" > " available" < / span > < span class = "p" > ,< / span > < span class = "n" > patterns< / span > < span class = "o" > =< / span > < span class = "n" > module_names< / span > < span class = "p" > ,< / span > < span class = "n" > showdups< / span > < span class = "o" > =< / span > < span class = "bp" > False< / span > < span class = "p" > )< / span >
< span class = "k" > except< / span > < span class = "n" > YumBaseError< / span > < span class = "k" > as< / span > < span class = "n" > e< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "n" > ProjectsError< / span > < span class = "p" > (< / span > < span class = "s" > " There was a problem listing modules: < / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "nb" > str< / span > < span class = "p" > (< / span > < span class = "n" > e< / span > < span class = "p" > ))< / span >
< span class = "k" > finally< / span > < span class = "p" > :< / span >
< span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > closeRpmDB< / span > < span class = "p" > ()< / span >
< span class = "k" > return< / span > < span class = "nb" > sorted< / span > < span class = "p" > (< / span > < span class = "nb" > map< / span > < span class = "p" > (< / span > < span class = "n" > yaps_to_module< / span > < span class = "p" > ,< / span > < span class = "n" > ybl< / span > < span class = "o" > .< / span > < span class = "n" > available< / span > < span class = "p" > ),< / span > < span class = "n" > key< / span > < span class = "o" > =< / span > < span class = "k" > lambda< / span > < span class = "n" > p< / span > < span class = "p" > :< / span > < span class = "n" > p< / span > < span class = "p" > [< / span > < span class = "s" > " name" < / span > < span class = "p" > ]< / span > < span class = "o" > .< / span > < span class = "n" > lower< / span > < span class = "p" > ())< / span >
< / div >
< div class = "viewcode-block" id = "modules_info" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.modules_info" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > modules_info< / span > < span class = "p" > (< / span > < span class = "n" > yb< / span > < span class = "p" > ,< / span > < span class = "n" > module_names< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Return details about a module, including dependencies< / span >
< span class = "sd" > :param yb: yum base object< / span >
< span class = "sd" > :type yb: YumBase< / span >
< span class = "sd" > :param module_names: Names of the modules to get info about< / span >
< span class = "sd" > :type module_names: str< / span >
< span class = "sd" > :returns: List of dicts with module details and dependencies.< / span >
< span class = "sd" > :rtype: list of dicts< / span >
< span class = "sd" > " " " < / span >
< span class = "k" > try< / span > < span class = "p" > :< / span >
< span class = "c" > # Get the info about each module< / span >
< span class = "n" > ybl< / span > < span class = "o" > =< / span > < span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > doPackageLists< / span > < span class = "p" > (< / span > < span class = "n" > pkgnarrow< / span > < span class = "o" > =< / span > < span class = "s" > " available" < / span > < span class = "p" > ,< / span > < span class = "n" > patterns< / span > < span class = "o" > =< / span > < span class = "n" > module_names< / span > < span class = "p" > ,< / span > < span class = "n" > showdups< / span > < span class = "o" > =< / span > < span class = "bp" > False< / span > < span class = "p" > )< / span >
< span class = "k" > except< / span > < span class = "n" > YumBaseError< / span > < span class = "k" > as< / span > < span class = "n" > e< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "n" > ProjectsError< / span > < span class = "p" > (< / span > < span class = "s" > " There was a problem with info for < / span > < span class = "si" > %s< / span > < span class = "s" > : < / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "p" > (< / span > < span class = "n" > module_names< / span > < span class = "p" > ,< / span > < span class = "nb" > str< / span > < span class = "p" > (< / span > < span class = "n" > e< / span > < span class = "p" > )))< / span >
< span class = "k" > finally< / span > < span class = "p" > :< / span >
< span class = "n" > yb< / span > < span class = "o" > .< / span > < span class = "n" > closeRpmDB< / span > < span class = "p" > ()< / span >
< span class = "n" > modules< / span > < span class = "o" > =< / span > < span class = "nb" > sorted< / span > < span class = "p" > (< / span > < span class = "nb" > map< / span > < span class = "p" > (< / span > < span class = "n" > yaps_to_project< / span > < span class = "p" > ,< / span > < span class = "n" > ybl< / span > < span class = "o" > .< / span > < span class = "n" > available< / span > < span class = "p" > ),< / span > < span class = "n" > key< / span > < span class = "o" > =< / span > < span class = "k" > lambda< / span > < span class = "n" > p< / span > < span class = "p" > :< / span > < span class = "n" > p< / span > < span class = "p" > [< / span > < span class = "s" > " name" < / span > < span class = "p" > ]< / span > < span class = "o" > .< / span > < span class = "n" > lower< / span > < span class = "p" > ())< / span >
< span class = "c" > # Add the dependency info to each one< / span >
< span class = "k" > for< / span > < span class = "n" > module< / span > < span class = "ow" > in< / span > < span class = "n" > modules< / span > < span class = "p" > :< / span >
2018-08-14 00:00:02 +00:00
< span class = "n" > module< / span > < span class = "p" > [< / span > < span class = "s" > " dependencies" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "n" > projects_depsolve< / span > < span class = "p" > (< / span > < span class = "n" > yb< / span > < span class = "p" > ,< / span > < span class = "p" > [(< / span > < span class = "n" > module< / span > < span class = "p" > [< / span > < span class = "s" > " name" < / span > < span class = "p" > ],< / span > < span class = "s" > " *" < / span > < span class = "p" > )],< / span > < span class = "p" > [])< / span >
2018-03-15 21:04:29 +00:00
2018-06-29 20:46:27 +00:00
< span class = "k" > return< / span > < span class = "n" > modules< / span >
< / div >
< div class = "viewcode-block" id = "yum_repo_to_file_repo" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.yum_repo_to_file_repo" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > yum_repo_to_file_repo< / span > < span class = "p" > (< / span > < span class = "n" > repo< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Return a string representation of a repo dict suitable for writing to a .repo file< / span >
< span class = "sd" > :param repo: Yum Repository represented as a dict< / span >
< span class = "sd" > :type repo: dict< / span >
< span class = "sd" > :returns: A string< / span >
< span class = "sd" > :rtype: str< / span >
< span class = "sd" > The YumRepo.dump() function does not produce a string that can be used as a< / span >
< span class = "sd" > yum .repo file. So do this manually with only the attributes we care about.< / span >
< span class = "sd" > " " " < / span >
< span class = "n" > repo_str< / span > < span class = "o" > =< / span > < span class = "s" > " [< / span > < span class = "si" > %s< / span > < span class = "s" > ]< / span > < span class = "se" > \n< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " id" < / span > < span class = "p" > ]< / span >
< span class = "k" > if< / span > < span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " metalink" < / span > < span class = "p" > ]:< / span >
< span class = "n" > repo_str< / span > < span class = "o" > +=< / span > < span class = "s" > " metalink = < / span > < span class = "si" > %s< / span > < span class = "se" > \n< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " metalink" < / span > < span class = "p" > ]< / span >
< span class = "k" > elif< / span > < span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " mirrorlist" < / span > < span class = "p" > ]:< / span >
< span class = "n" > repo_str< / span > < span class = "o" > +=< / span > < span class = "s" > " mirrorlist = < / span > < span class = "si" > %s< / span > < span class = "se" > \n< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " mirrorlist" < / span > < span class = "p" > ]< / span >
< span class = "k" > elif< / span > < span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " baseurl" < / span > < span class = "p" > ]:< / span >
< span class = "n" > repo_str< / span > < span class = "o" > +=< / span > < span class = "s" > " baseurl = < / span > < span class = "si" > %s< / span > < span class = "se" > \n< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " baseurl" < / span > < span class = "p" > ][< / span > < span class = "mi" > 0< / span > < span class = "p" > ]< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "ne" > RuntimeError< / span > < span class = "p" > (< / span > < span class = "s" > " Repo has no baseurl, metalink, or mirrorlist" < / span > < span class = "p" > )< / span >
< span class = "c" > # proxy is optional< / span >
< span class = "k" > if< / span > < span class = "s" > " proxy" < / span > < span class = "ow" > in< / span > < span class = "n" > repo< / span > < span class = "p" > :< / span >
< span class = "n" > repo_str< / span > < span class = "o" > +=< / span > < span class = "s" > " proxy = < / span > < span class = "si" > %s< / span > < span class = "se" > \n< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " proxy" < / span > < span class = "p" > ]< / span >
< span class = "n" > repo_str< / span > < span class = "o" > +=< / span > < span class = "s" > " sslverify = < / span > < span class = "si" > %s< / span > < span class = "se" > \n< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " sslverify" < / span > < span class = "p" > ]< / span >
< span class = "n" > repo_str< / span > < span class = "o" > +=< / span > < span class = "s" > " gpgcheck = < / span > < span class = "si" > %s< / span > < span class = "se" > \n< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " gpgcheck" < / span > < span class = "p" > ]< / span >
< span class = "k" > if< / span > < span class = "s" > " gpgkey" < / span > < span class = "ow" > in< / span > < span class = "n" > repo< / span > < span class = "p" > :< / span >
< span class = "n" > repo_str< / span > < span class = "o" > +=< / span > < span class = "s" > " gpgkey = < / span > < span class = "si" > %s< / span > < span class = "se" > \n< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "s" > " ," < / span > < span class = "o" > .< / span > < span class = "n" > join< / span > < span class = "p" > (< / span > < span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " gpgkey" < / span > < span class = "p" > ])< / span >
< span class = "k" > return< / span > < span class = "n" > repo_str< / span >
< / div >
< div class = "viewcode-block" id = "repo_to_source" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.repo_to_source" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > repo_to_source< / span > < span class = "p" > (< / span > < span class = "n" > repo< / span > < span class = "p" > ,< / span > < span class = "n" > system_source< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Return a Weldr Source dict created from the YumRepository< / span >
< span class = "sd" > :param repo: Yum Repository< / span >
< span class = "sd" > :type repo: yum.yumRepo.YumRepository< / span >
< span class = "sd" > :param system_source: True if this source is an immutable system source< / span >
< span class = "sd" > :type system_source: bool< / span >
< span class = "sd" > :returns: A dict with Weldr Source fields filled in< / span >
< span class = "sd" > :rtype: dict< / span >
< span class = "sd" > Example::< / span >
< span class = "sd" > {< / span >
< span class = "sd" > " check_gpg" : true,< / span >
< span class = "sd" > " check_ssl" : true,< / span >
< span class = "sd" > " gpgkey_url" : [< / span >
< span class = "sd" > " file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-28-x86_64" < / span >
< span class = "sd" > ],< / span >
< span class = "sd" > " name" : " fedora" ,< / span >
< span class = "sd" > " proxy" : " http://proxy.brianlane.com:8123" ,< / span >
< span class = "sd" > " system" : true< / span >
< span class = "sd" > " type" : " yum-metalink" ,< / span >
< span class = "sd" > " url" : " https://mirrors.fedoraproject.org/metalink?repo=fedora-28& arch=x86_64" < / span >
< span class = "sd" > }< / span >
< span class = "sd" > " " " < / span >
< span class = "n" > source< / span > < span class = "o" > =< / span > < span class = "p" > {< / span > < span class = "s" > " name" < / span > < span class = "p" > :< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > id< / span > < span class = "p" > ,< / span > < span class = "s" > " system" < / span > < span class = "p" > :< / span > < span class = "n" > system_source< / span > < span class = "p" > }< / span >
< span class = "k" > if< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > baseurl< / span > < span class = "p" > :< / span >
< span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " url" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > baseurl< / span > < span class = "p" > [< / span > < span class = "mi" > 0< / span > < span class = "p" > ]< / span >
< span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " type" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "s" > " yum-baseurl" < / span >
< span class = "k" > elif< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > metalink< / span > < span class = "p" > :< / span >
< span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " url" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > metalink< / span >
< span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " type" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "s" > " yum-metalink" < / span >
< span class = "k" > elif< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > mirrorlist< / span > < span class = "p" > :< / span >
< span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " url" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > mirrorlist< / span >
< span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " type" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "s" > " yum-mirrorlist" < / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "ne" > RuntimeError< / span > < span class = "p" > (< / span > < span class = "s" > " Repo has no baseurl, metalink, or mirrorlist" < / span > < span class = "p" > )< / span >
< span class = "c" > # proxy is optional< / span >
< span class = "k" > if< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > proxy< / span > < span class = "p" > :< / span >
< span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " proxy" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > proxy< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > sslverify< / span > < span class = "p" > :< / span >
< span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " check_ssl" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "bp" > False< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " check_ssl" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "bp" > True< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > gpgcheck< / span > < span class = "p" > :< / span >
< span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " check_gpg" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "bp" > False< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " check_gpg" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "bp" > True< / span >
< span class = "k" > if< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > gpgkey< / span > < span class = "p" > :< / span >
< span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " gpgkey_urls" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > gpgkey< / span >
< span class = "k" > return< / span > < span class = "n" > source< / span >
< / div >
< div class = "viewcode-block" id = "source_to_repo" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.source_to_repo" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > source_to_repo< / span > < span class = "p" > (< / span > < span class = "n" > source< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Return an add_enable_repo kwargs dict created from a source dict< / span >
< span class = "sd" > :param source: A Weldr source dict< / span >
< span class = "sd" > :type source: dict< / span >
< span class = "sd" > :returns: A yum YumRepository object< / span >
< span class = "sd" > :rtype: yum.yumRepo.YumRepository< / span >
< span class = "sd" > The dict it suitable for passing to yum' s add_enable_repo function< / span >
< span class = "sd" > after popping off baseurl and mirrorlist.< / span >
< span class = "sd" > Example::< / span >
< span class = "sd" > {< / span >
< span class = "sd" > " gpgcheck" : True,< / span >
< span class = "sd" > " sslverify" : True,< / span >
< span class = "sd" > " gpgkey" : [" file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-28-x86_64" ],< / span >
< span class = "sd" > " id" : " fedora" ,< / span >
< span class = "sd" > " proxy" : " http://proxy.brianlane.com:8123" ,< / span >
< span class = "sd" > " baseurl" : " https://mirrors.fedoraproject.org/metalink?repo=fedora-28& arch=x86_64" ,< / span >
< span class = "sd" > " metalink" : None,< / span >
< span class = "sd" > " mirrorlist" : None< / span >
< span class = "sd" > }< / span >
< span class = "sd" > " " " < / span >
< span class = "n" > repo< / span > < span class = "o" > =< / span > < span class = "p" > {< / span > < span class = "s" > " id" < / span > < span class = "p" > :< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " name" < / span > < span class = "p" > ]}< / span >
< span class = "c" > # This will allow errors to be raised so we can catch them< / span >
< span class = "c" > # without this they are logged, but the repo is silently disabled< / span >
< span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " skip_if_unavailable" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "bp" > False< / span >
< span class = "k" > if< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " type" < / span > < span class = "p" > ]< / span > < span class = "o" > ==< / span > < span class = "s" > " yum-baseurl" < / span > < span class = "p" > :< / span >
< span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " baseurl" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "p" > [< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " url" < / span > < span class = "p" > ]]< / span >
< span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " metalink" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span >
< span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " mirrorlist" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span >
< span class = "k" > elif< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " type" < / span > < span class = "p" > ]< / span > < span class = "o" > ==< / span > < span class = "s" > " yum-metalink" < / span > < span class = "p" > :< / span >
< span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " metalink" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " url" < / span > < span class = "p" > ]< / span >
< span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " baseurl" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "p" > []< / span >
< span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " mirrorlist" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span >
< span class = "k" > elif< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " type" < / span > < span class = "p" > ]< / span > < span class = "o" > ==< / span > < span class = "s" > " yum-mirrorlist" < / span > < span class = "p" > :< / span >
< span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " mirrorlist" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " url" < / span > < span class = "p" > ]< / span >
< span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " baseurl" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "p" > []< / span >
< span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " metalink" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "bp" > None< / span >
< span class = "k" > if< / span > < span class = "s" > " proxy" < / span > < span class = "ow" > in< / span > < span class = "n" > source< / span > < span class = "p" > :< / span >
< span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " proxy" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " proxy" < / span > < span class = "p" > ]< / span >
< span class = "k" > if< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " check_ssl" < / span > < span class = "p" > ]:< / span >
< span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " sslverify" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "bp" > True< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " sslverify" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "bp" > False< / span >
< span class = "k" > if< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " check_gpg" < / span > < span class = "p" > ]:< / span >
< span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " gpgcheck" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "bp" > True< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " gpgcheck" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "bp" > False< / span >
< span class = "k" > if< / span > < span class = "s" > " gpgkey_urls" < / span > < span class = "ow" > in< / span > < span class = "n" > source< / span > < span class = "p" > :< / span >
< span class = "n" > repo< / span > < span class = "p" > [< / span > < span class = "s" > " gpgkey" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s" > " gpgkey_urls" < / span > < span class = "p" > ]< / span >
< span class = "k" > return< / span > < span class = "n" > repo< / span >
< / div >
< div class = "viewcode-block" id = "get_source_ids" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.get_source_ids" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > get_source_ids< / span > < span class = "p" > (< / span > < span class = "n" > source_path< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Return a list of the source ids in a file< / span >
< span class = "sd" > :param source_path: Full path and filename of the source (yum repo) file< / span >
< span class = "sd" > :type source_path: str< / span >
< span class = "sd" > :returns: A list of source id strings< / span >
< span class = "sd" > :rtype: list of str< / span >
< span class = "sd" > " " " < / 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" > source_path< / span > < span class = "p" > ):< / span >
< span class = "k" > return< / span > < span class = "p" > []< / span >
< span class = "n" > cfg< / span > < span class = "o" > =< / span > < span class = "n" > ConfigParser< / span > < span class = "p" > ()< / span >
< span class = "n" > cfg< / span > < span class = "o" > .< / span > < span class = "n" > read< / span > < span class = "p" > (< / span > < span class = "n" > source_path< / span > < span class = "p" > )< / span >
< span class = "k" > return< / span > < span class = "n" > cfg< / span > < span class = "o" > .< / span > < span class = "n" > sections< / span > < span class = "p" > ()< / span >
< / div >
< div class = "viewcode-block" id = "get_repo_sources" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.get_repo_sources" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > get_repo_sources< / span > < span class = "p" > (< / span > < span class = "n" > source_glob< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Return a list of sources from a directory of yum repositories< / span >
< span class = "sd" > :param source_glob: A glob to use to match the source files, including full path< / span >
< span class = "sd" > :type source_glob: str< / span >
< span class = "sd" > :returns: A list of the source ids in all of the matching files< / span >
< span class = "sd" > :rtype: list of str< / span >
< span class = "sd" > " " " < / span >
< span class = "n" > sources< / span > < span class = "o" > =< / span > < span class = "p" > []< / span >
< span class = "k" > for< / span > < span class = "n" > f< / span > < span class = "ow" > in< / span > < span class = "n" > glob< / span > < span class = "p" > (< / span > < span class = "n" > source_glob< / span > < span class = "p" > ):< / span >
< span class = "n" > sources< / span > < span class = "o" > .< / span > < span class = "n" > extend< / span > < span class = "p" > (< / span > < span class = "n" > get_source_ids< / span > < span class = "p" > (< / span > < span class = "n" > f< / span > < span class = "p" > ))< / span >
< span class = "k" > return< / span > < span class = "n" > sources< / span >
< / div >
< div class = "viewcode-block" id = "delete_repo_source" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.delete_repo_source" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > delete_repo_source< / span > < span class = "p" > (< / span > < span class = "n" > source_glob< / span > < span class = "p" > ,< / span > < span class = "n" > source_name< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Delete a source from a repo file< / span >
< span class = "sd" > :param source_glob: A glob of the repo sources to search< / span >
< span class = "sd" > :type source_glob: str< / span >
< span class = "sd" > :returns: None< / span >
< span class = "sd" > :raises: ProjectsError if there was a problem< / span >
< span class = "sd" > A repo file may have multiple sources in it, delete only the selected source.< / span >
< span class = "sd" > If it is the last one in the file, delete the file.< / span >
< span class = "sd" > WARNING: This will delete ANY source, the caller needs to ensure that a system< / span >
< span class = "sd" > source_name isn' t passed to it.< / span >
< span class = "sd" > " " " < / span >
< span class = "n" > found< / span > < span class = "o" > =< / span > < span class = "bp" > False< / span >
< span class = "k" > for< / span > < span class = "n" > f< / span > < span class = "ow" > in< / span > < span class = "n" > glob< / span > < span class = "p" > (< / span > < span class = "n" > source_glob< / span > < span class = "p" > ):< / span >
< span class = "k" > try< / span > < span class = "p" > :< / span >
< span class = "n" > cfg< / span > < span class = "o" > =< / span > < span class = "n" > ConfigParser< / span > < span class = "p" > ()< / span >
< span class = "n" > cfg< / span > < span class = "o" > .< / span > < span class = "n" > read< / span > < span class = "p" > (< / span > < span class = "n" > f< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > source_name< / span > < span class = "ow" > in< / span > < span class = "n" > cfg< / span > < span class = "o" > .< / span > < span class = "n" > sections< / span > < span class = "p" > ():< / span >
< span class = "n" > found< / span > < span class = "o" > =< / span > < span class = "bp" > True< / span >
< span class = "n" > cfg< / span > < span class = "o" > .< / span > < span class = "n" > remove_section< / span > < span class = "p" > (< / span > < span class = "n" > source_name< / span > < span class = "p" > )< / span >
< span class = "c" > # If there are other sections, rewrite the file without the deleted one< / span >
< span class = "k" > if< / span > < span class = "nb" > len< / span > < span class = "p" > (< / span > < span class = "n" > cfg< / span > < span class = "o" > .< / span > < span class = "n" > sections< / span > < span class = "p" > ())< / span > < span class = "o" > > < / span > < span class = "mi" > 0< / span > < span class = "p" > :< / span >
< span class = "k" > with< / span > < span class = "nb" > open< / span > < span class = "p" > (< / span > < span class = "n" > f< / span > < span class = "p" > ,< / span > < span class = "s" > " w" < / span > < span class = "p" > )< / span > < span class = "k" > as< / span > < span class = "n" > cfg_file< / span > < span class = "p" > :< / span >
< span class = "n" > cfg< / span > < span class = "o" > .< / span > < span class = "n" > write< / span > < span class = "p" > (< / span > < span class = "n" > cfg_file< / span > < span class = "p" > )< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "c" > # No sections left, just delete the file< / span >
< span class = "n" > os< / span > < span class = "o" > .< / span > < span class = "n" > unlink< / span > < span class = "p" > (< / span > < span class = "n" > f< / span > < span class = "p" > )< / span >
< span class = "k" > except< / span > < span class = "ne" > Exception< / span > < span class = "k" > as< / span > < span class = "n" > e< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "n" > ProjectsError< / span > < span class = "p" > (< / span > < span class = "s" > " Problem deleting repo source < / span > < span class = "si" > %s< / span > < span class = "s" > : < / span > < span class = "si" > %s< / span > < span class = "s" > " < / span > < span class = "o" > %< / span > < span class = "p" > (< / span > < span class = "n" > source_name< / span > < span class = "p" > ,< / span > < span class = "nb" > str< / span > < span class = "p" > (< / span > < span class = "n" > e< / span > < span class = "p" > )))< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > found< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "n" > ProjectsError< / span > < span class = "p" > (< / span > < span class = "s" > " source < / span > < span class = "si" > %s< / span > < span class = "s" > not found" < / span > < span class = "o" > %< / span > < span class = "n" > source_name< / span > < span class = "p" > )< / span > < / div >
2018-03-15 21:04:29 +00:00
< / 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-09-06 21:14:02 +00:00
< li > < a href = "../../../index.html" > Lorax 19.7.22 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 >