2018-05-12 00:18:21 +00:00
<!DOCTYPE html>
<!-- [if IE 8]><html class="no - js lt - ie9" lang="en" > <![endif] -->
<!-- [if gt IE 8]><! --> < html class = "no-js" lang = "en" > <!-- <![endif] -->
< head >
< meta charset = "utf-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
2019-03-27 23:44:14 +00:00
< title > pylorax.api.projects — Lorax 31.1 documentation< / title >
2018-05-12 00:18:21 +00:00
2019-03-27 23:44:14 +00:00
< script type = "text/javascript" src = "../../../_static/js/modernizr.min.js" > < / script >
2018-05-12 00:18:21 +00:00
2019-03-27 23:44:14 +00:00
< script type = "text/javascript" id = "documentation_options" data-url_root = "../../../" src = "../../../_static/documentation_options.js" > < / 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 >
< script type = "text/javascript" src = "../../../_static/language_data.js" > < / script >
< script type = "text/javascript" src = "../../../_static/js/theme.js" > < / script >
2018-05-12 00:18:21 +00:00
2019-03-27 23:44:14 +00:00
2018-05-12 00:18:21 +00:00
2019-03-27 23:44:14 +00:00
2018-11-13 17:53:31 +00:00
< link rel = "stylesheet" href = "../../../_static/css/theme.css" type = "text/css" / >
2018-05-12 00:18:21 +00:00
< link rel = "stylesheet" href = "../../../_static/pygments.css" type = "text/css" / >
< link rel = "index" title = "Index" href = "../../../genindex.html" / >
< link rel = "search" title = "Search" href = "../../../search.html" / >
< / head >
< body class = "wy-body-for-nav" >
< div class = "wy-grid-for-nav" >
< nav data-toggle = "wy-nav-shift" class = "wy-nav-side" >
< div class = "wy-side-scroll" >
2019-03-27 23:44:14 +00:00
< div class = "wy-side-nav-search" >
2018-05-12 00:18:21 +00:00
< a href = "../../../index.html" class = "icon icon-home" > Lorax
< / a >
< div class = "version" >
2019-03-27 23:44:14 +00:00
31.1
2018-05-12 00:18:21 +00:00
< / div >
< div role = "search" >
< form id = "rtd-search-form" class = "wy-form" action = "../../../search.html" method = "get" >
< input type = "text" name = "q" placeholder = "Search docs" / >
< input type = "hidden" name = "check_keywords" value = "yes" / >
< input type = "hidden" name = "area" value = "default" / >
< / form >
< / div >
< / div >
< div class = "wy-menu wy-menu-vertical" data-spy = "affix" role = "navigation" aria-label = "main navigation" >
< ul >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../intro.html" > Introduction to Lorax< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../intro.html#before-lorax" > Before Lorax< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../lorax.html" > Lorax< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../livemedia-creator.html" > livemedia-creator< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../lorax-composer.html" > lorax-composer< / a > < / li >
2018-10-24 17:07:32 +00:00
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../composer-cli.html" > composer-cli< / a > < / li >
2018-05-12 00:18:21 +00:00
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../product-images.html" > Product and Updates Images< / a > < / li >
< li class = "toctree-l1" > < a class = "reference internal" href = "../../../modules.html" > src< / a > < / li >
< / ul >
< / div >
< / div >
< / nav >
< section data-toggle = "wy-nav-shift" class = "wy-nav-content-wrap" >
< nav class = "wy-nav-top" aria-label = "top navigation" >
< i data-toggle = "wy-nav-top" class = "fa fa-bars" > < / i >
< a href = "../../../index.html" > Lorax< / a >
< / nav >
< div class = "wy-nav-content" >
< div class = "rst-content" >
< div role = "navigation" aria-label = "breadcrumbs navigation" >
< ul class = "wy-breadcrumbs" >
< li > < a href = "../../../index.html" > Docs< / a > » < / li >
< li > < a href = "../../index.html" > Module code< / a > » < / li >
< li > < a href = "../../pylorax.html" > pylorax< / a > » < / li >
< li > pylorax.api.projects< / li >
< li class = "wy-breadcrumbs-aside" >
< / li >
< / ul >
< hr / >
< / div >
< div role = "main" class = "document" itemscope = "itemscope" itemtype = "http://schema.org/Article" >
< div itemprop = "articleBody" >
< h1 > Source code for pylorax.api.projects< / h1 > < div class = "highlight" > < pre >
< span > < / span > < span class = "c1" > #< / span >
< span class = "c1" > # Copyright (C) 2017 Red Hat, Inc.< / span >
< span class = "c1" > #< / span >
< span class = "c1" > # This program is free software; you can redistribute it and/or modify< / span >
< span class = "c1" > # it under the terms of the GNU General Public License as published by< / span >
< span class = "c1" > # the Free Software Foundation; either version 2 of the License, or< / span >
< span class = "c1" > # (at your option) any later version.< / span >
< span class = "c1" > #< / span >
< span class = "c1" > # This program is distributed in the hope that it will be useful,< / span >
< span class = "c1" > # but WITHOUT ANY WARRANTY; without even the implied warranty of< / span >
< span class = "c1" > # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the< / span >
< span class = "c1" > # GNU General Public License for more details.< / span >
< span class = "c1" > #< / span >
< span class = "c1" > # You should have received a copy of the GNU General Public License< / span >
< span class = "c1" > # along with this program. If not, see < http://www.gnu.org/licenses/> .< / span >
< span class = "c1" > #< / 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 = "s2" > " lorax-composer" < / span > < span class = "p" > )< / span >
2018-06-04 23:27:56 +00:00
< span class = "kn" > from< / span > < span class = "nn" > configparser< / span > < span class = "k" > import< / span > < span class = "n" > ConfigParser< / span >
2018-05-12 00:18:21 +00:00
< span class = "kn" > import< / span > < span class = "nn" > dnf< / span >
2018-06-04 23:27:56 +00:00
< span class = "kn" > from< / span > < span class = "nn" > glob< / span > < span class = "k" > import< / span > < span class = "n" > glob< / span >
2019-03-27 23:44:14 +00:00
< span class = "kn" > import< / span > < span class = "nn" > os< / span >
2018-05-12 00:18:21 +00:00
< span class = "kn" > import< / span > < span class = "nn" > time< / span >
2019-03-27 23:44:14 +00:00
< span class = "kn" > from< / span > < span class = "nn" > pylorax.api.bisect< / span > < span class = "k" > import< / span > < span class = "n" > insort_left< / span >
2018-05-12 00:18:21 +00:00
< span class = "n" > TIME_FORMAT< / span > < span class = "o" > =< / span > < span class = "s2" > " %Y-%m-< / span > < span class = "si" > %d< / span > < span class = "s2" > 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 = "s2" > " " < / span >
< span class = "k" > return< / span > < span class = "n" > entry< / span > < / div >
< div class = "viewcode-block" id = "pkg_to_project" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.pkg_to_project" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > pkg_to_project< / span > < span class = "p" > (< / span > < span class = "n" > pkg< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Extract the details from a hawkey.Package object< / span >
< span class = "sd" > :param pkgs: hawkey.Package object with package details< / span >
< span class = "sd" > :type pkgs: hawkey.Package< / 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 = "s2" > " name" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > name< / span > < span class = "p" > ,< / span >
< span class = "s2" > " summary" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > summary< / span > < span class = "p" > ,< / span >
< span class = "s2" > " description" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > description< / span > < span class = "p" > ,< / span >
< span class = "s2" > " homepage" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > url< / span > < span class = "p" > ,< / span >
< span class = "s2" > " upstream_vcs" < / span > < span class = "p" > :< / span > < span class = "s2" > " UPSTREAM_VCS" < / span > < span class = "p" > }< / span > < / div >
2019-03-27 23:44:14 +00:00
< div class = "viewcode-block" id = "pkg_to_build" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.pkg_to_build" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > pkg_to_build< / span > < span class = "p" > (< / span > < span class = "n" > pkg< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Extract the build details from a hawkey.Package object< / span >
< span class = "sd" > :param pkg: hawkey.Package object with package details< / span >
< span class = "sd" > :type pkg: hawkey.Package< / span >
< span class = "sd" > :returns: A dict with the build details, 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" > Note that this only returns the build dict, it does not include the name, description, etc.< / span >
< span class = "sd" > " " " < / span >
< span class = "k" > return< / span > < span class = "p" > {< / span > < span class = "s2" > " epoch" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > epoch< / span > < span class = "p" > ,< / span >
< span class = "s2" > " release" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > release< / span > < span class = "p" > ,< / span >
< span class = "s2" > " arch" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > arch< / span > < span class = "p" > ,< / span >
< span class = "s2" > " build_time" < / span > < span class = "p" > :< / span > < span class = "n" > api_time< / span > < span class = "p" > (< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > buildtime< / span > < span class = "p" > ),< / span >
< span class = "s2" > " changelog" < / span > < span class = "p" > :< / span > < span class = "s2" > " CHANGELOG_NEEDED" < / span > < span class = "p" > ,< / span > < span class = "c1" > # XXX Not in hawkey.Package< / span >
< span class = "s2" > " build_config_ref" < / span > < span class = "p" > :< / span > < span class = "s2" > " BUILD_CONFIG_REF" < / span > < span class = "p" > ,< / span >
< span class = "s2" > " build_env_ref" < / span > < span class = "p" > :< / span > < span class = "s2" > " BUILD_ENV_REF" < / span > < span class = "p" > ,< / span >
< span class = "s2" > " metadata" < / span > < span class = "p" > :< / span > < span class = "p" > {},< / span >
< span class = "s2" > " source" < / span > < span class = "p" > :< / span > < span class = "p" > {< / span > < span class = "s2" > " license" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > license< / span > < span class = "p" > ,< / span >
< span class = "s2" > " version" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > version< / span > < span class = "p" > ,< / span >
< span class = "s2" > " source_ref" < / span > < span class = "p" > :< / span > < span class = "s2" > " SOURCE_REF" < / span > < span class = "p" > ,< / span >
< span class = "s2" > " metadata" < / span > < span class = "p" > :< / span > < span class = "p" > {}}}< / span > < / div >
2018-05-12 00:18:21 +00:00
< div class = "viewcode-block" id = "pkg_to_project_info" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.pkg_to_project_info" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > pkg_to_project_info< / span > < span class = "p" > (< / span > < span class = "n" > pkg< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Extract the details from a hawkey.Package object< / span >
< span class = "sd" > :param pkg: hawkey.Package object with package details< / span >
< span class = "sd" > :type pkg: hawkey.Package< / 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 >
< span class = "k" > return< / span > < span class = "p" > {< / span > < span class = "s2" > " name" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > name< / span > < span class = "p" > ,< / span >
< span class = "s2" > " summary" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > summary< / span > < span class = "p" > ,< / span >
< span class = "s2" > " description" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > description< / span > < span class = "p" > ,< / span >
< span class = "s2" > " homepage" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > url< / span > < span class = "p" > ,< / span >
< span class = "s2" > " upstream_vcs" < / span > < span class = "p" > :< / span > < span class = "s2" > " UPSTREAM_VCS" < / span > < span class = "p" > ,< / span >
2019-03-27 23:44:14 +00:00
< span class = "s2" > " builds" < / span > < span class = "p" > :< / span > < span class = "p" > [< / span > < span class = "n" > pkg_to_build< / span > < span class = "p" > (< / span > < span class = "n" > pkg< / span > < span class = "p" > )]}< / span > < / div >
2018-05-12 00:18:21 +00:00
< div class = "viewcode-block" id = "pkg_to_dep" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.pkg_to_dep" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > pkg_to_dep< / span > < span class = "p" > (< / span > < span class = "n" > pkg< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Extract the info from a hawkey.Package object< / span >
< span class = "sd" > :param pkg: A hawkey.Package object< / span >
< span class = "sd" > :type pkg: hawkey.Package< / 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 = "s2" > " name" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > name< / span > < span class = "p" > ,< / span >
< span class = "s2" > " epoch" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > epoch< / span > < span class = "p" > ,< / span >
< span class = "s2" > " version" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > version< / span > < span class = "p" > ,< / span >
< span class = "s2" > " release" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > release< / span > < span class = "p" > ,< / span >
< span class = "s2" > " arch" < / span > < span class = "p" > :< / span > < span class = "n" > pkg< / span > < span class = "o" > .< / span > < span class = "n" > arch< / span > < span class = "p" > }< / span > < / div >
< div class = "viewcode-block" id = "proj_to_module" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.proj_to_module" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > proj_to_module< / span > < span class = "p" > (< / span > < span class = "n" > proj< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Extract the name from a project_info dict< / span >
< span class = "sd" > :param pkg: dict with package details< / span >
< span class = "sd" > :type pkg: dict< / 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 = "s2" > " name" < / span > < span class = "p" > :< / span > < span class = "n" > proj< / span > < span class = "p" > [< / span > < span class = "s2" > " name" < / span > < span class = "p" > ],< / span >
< span class = "s2" > " group_type" < / span > < span class = "p" > :< / span > < span class = "s2" > " 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 >
< span class = "k" > if< / span > < span class = "n" > dep< / span > < span class = "p" > [< / span > < span class = "s2" > " epoch" < / span > < span class = "p" > ]< / span > < span class = "o" > ==< / span > < span class = "mi" > 0< / span > < span class = "p" > :< / span >
< span class = "k" > return< / span > < span class = "n" > dep< / span > < span class = "p" > [< / span > < span class = "s2" > " version" < / span > < span class = "p" > ]< / span > < span class = "o" > +< / span > < span class = "s2" > " -" < / span > < span class = "o" > +< / span > < span class = "n" > dep< / span > < span class = "p" > [< / span > < span class = "s2" > " release" < / span > < span class = "p" > ]< / span > < span class = "o" > +< / span > < span class = "s2" > " ." < / span > < span class = "o" > +< / span > < span class = "n" > dep< / span > < span class = "p" > [< / span > < span class = "s2" > " arch" < / span > < span class = "p" > ]< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< 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 = "s2" > " epoch" < / span > < span class = "p" > ])< / span > < span class = "o" > +< / span > < span class = "s2" > " :" < / span > < span class = "o" > +< / span > < span class = "n" > dep< / span > < span class = "p" > [< / span > < span class = "s2" > " version" < / span > < span class = "p" > ]< / span > < span class = "o" > +< / span > < span class = "s2" > " -" < / span > < span class = "o" > +< / span > < span class = "n" > dep< / span > < span class = "p" > [< / span > < span class = "s2" > " release" < / span > < span class = "p" > ]< / span > < span class = "o" > +< / span > < span class = "s2" > " ." < / span > < span class = "o" > +< / span > < span class = "n" > dep< / span > < span class = "p" > [< / span > < span class = "s2" > " arch" < / span > < span class = "p" > ]< / span > < / 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 = "s2" > " name" < / span > < span class = "p" > ]< / span > < span class = "o" > +< / span > < span class = "s2" > " -" < / 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" > dbo< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Return a list of projects< / span >
< span class = "sd" > :param dbo: dnf base object< / span >
< span class = "sd" > :type dbo: dnf.Base< / 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" > return< / span > < span class = "n" > projects_info< / span > < span class = "p" > (< / span > < span class = "n" > dbo< / span > < span class = "p" > ,< / span > < span class = "kc" > None< / 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" > dbo< / 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 dbo: dnf base object< / span >
< span class = "sd" > :type dbo: dnf.Base< / 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 pkg_to_project as well as epoch, version, release, etc.< / span >
< span class = "sd" > :rtype: list of dicts< / span >
< span class = "sd" > If project_names is None it will return the full list of available packages< / span >
< span class = "sd" > " " " < / span >
< span class = "k" > if< / span > < span class = "n" > project_names< / span > < span class = "p" > :< / span >
< span class = "n" > pkgs< / span > < span class = "o" > =< / span > < span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > sack< / span > < span class = "o" > .< / span > < span class = "n" > query< / span > < span class = "p" > ()< / span > < span class = "o" > .< / span > < span class = "n" > available< / span > < span class = "p" > ()< / span > < span class = "o" > .< / span > < span class = "n" > filter< / span > < span class = "p" > (< / span > < span class = "n" > name__glob< / span > < span class = "o" > =< / span > < span class = "n" > project_names< / span > < span class = "p" > )< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > pkgs< / span > < span class = "o" > =< / span > < span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > sack< / span > < span class = "o" > .< / span > < span class = "n" > query< / span > < span class = "p" > ()< / span > < span class = "o" > .< / span > < span class = "n" > available< / span > < span class = "p" > ()< / span >
2019-03-27 23:44:14 +00:00
< span class = "c1" > # iterate over pkgs< / span >
< span class = "c1" > # - if pkg.name isn' t in the results yet, add pkg_to_project_info in sorted position< / span >
< span class = "c1" > # - if pkg.name is already in results, get its builds. If the build for pkg is different< / span >
< span class = "c1" > # in any way (version, arch, etc.) add it to the entry' s builds list. If it is the same,< / span >
< span class = "c1" > # skip it.< / span >
< span class = "n" > results< / span > < span class = "o" > =< / span > < span class = "p" > []< / span >
< span class = "n" > results_names< / span > < span class = "o" > =< / span > < span class = "p" > {}< / span >
< span class = "k" > for< / span > < span class = "n" > p< / span > < span class = "ow" > in< / span > < span class = "n" > pkgs< / span > < span class = "p" > :< / span >
< span class = "k" > if< / span > < span class = "n" > p< / span > < span class = "o" > .< / span > < span class = "n" > name< / span > < span class = "o" > .< / span > < span class = "n" > lower< / span > < span class = "p" > ()< / span > < span class = "ow" > not< / span > < span class = "ow" > in< / span > < span class = "n" > results_names< / span > < span class = "p" > :< / span >
< span class = "n" > idx< / span > < span class = "o" > =< / span > < span class = "n" > insort_left< / span > < span class = "p" > (< / span > < span class = "n" > results< / span > < span class = "p" > ,< / span > < span class = "n" > pkg_to_project_info< / span > < span class = "p" > (< / span > < span class = "n" > p< / 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 = "s2" > " name" < / span > < span class = "p" > ]< / span > < span class = "o" > .< / span > < span class = "n" > lower< / span > < span class = "p" > ())< / span >
< span class = "n" > results_names< / span > < span class = "p" > [< / span > < span class = "n" > p< / span > < span class = "o" > .< / span > < span class = "n" > name< / span > < span class = "o" > .< / span > < span class = "n" > lower< / span > < span class = "p" > ()]< / span > < span class = "o" > =< / span > < span class = "n" > idx< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > build< / span > < span class = "o" > =< / span > < span class = "n" > pkg_to_build< / span > < span class = "p" > (< / span > < span class = "n" > p< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > build< / span > < span class = "ow" > not< / span > < span class = "ow" > in< / span > < span class = "n" > results< / span > < span class = "p" > [< / span > < span class = "n" > results_names< / span > < span class = "p" > [< / span > < span class = "n" > p< / span > < span class = "o" > .< / span > < span class = "n" > name< / span > < span class = "o" > .< / span > < span class = "n" > lower< / span > < span class = "p" > ()]][< / span > < span class = "s2" > " builds" < / span > < span class = "p" > ]:< / span >
< span class = "n" > results< / span > < span class = "p" > [< / span > < span class = "n" > results_names< / span > < span class = "p" > [< / span > < span class = "n" > p< / span > < span class = "o" > .< / span > < span class = "n" > name< / span > < span class = "o" > .< / span > < span class = "n" > lower< / span > < span class = "p" > ()]][< / span > < span class = "s2" > " builds" < / span > < span class = "p" > ]< / span > < span class = "o" > .< / span > < span class = "n" > append< / span > < span class = "p" > (< / span > < span class = "n" > build< / span > < span class = "p" > )< / span >
< span class = "k" > return< / span > < span class = "n" > results< / span > < / div >
2018-05-12 00:18:21 +00:00
2018-07-20 22:51:06 +00:00
< span class = "k" > def< / span > < span class = "nf" > _depsolve< / span > < span class = "p" > (< / span > < span class = "n" > dbo< / span > < span class = "p" > ,< / span > < span class = "n" > projects< / span > < span class = "p" > ,< / span > < span class = "n" > groups< / span > < span class = "p" > ):< / span >
2018-06-04 23:27:56 +00:00
< span class = "sd" > " " " Add projects to a new transaction< / span >
2018-05-12 00:18:21 +00:00
< span class = "sd" > :param dbo: dnf base object< / span >
< span class = "sd" > :type dbo: dnf.Base< / span >
2018-06-04 23:27:56 +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-07-20 22:51:06 +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-06-04 23:27:56 +00:00
< span class = "sd" > :returns: None< / span >
< span class = "sd" > :rtype: None< / span >
< span class = "sd" > :raises: ProjectsError if there was a problem installing something< / span >
2018-05-12 00:18:21 +00:00
< span class = "sd" > " " " < / span >
2018-10-04 23:55:20 +00:00
< span class = "c1" > # This resets the transaction and updates the cache.< / span >
< span class = "c1" > # It is important that the cache always be synchronized because Anaconda will grab its own copy< / span >
< span class = "c1" > # and if that is different the NEVRAs will not match and the build will fail.< / span >
2018-05-12 00:18:21 +00:00
< span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > reset< / span > < span class = "p" > (< / span > < span class = "n" > goal< / span > < span class = "o" > =< / span > < span class = "kc" > True< / span > < span class = "p" > )< / span >
2018-07-20 22:51:06 +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 = "k" > try< / span > < span class = "p" > :< / span >
< span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > group_install< / span > < span class = "p" > (< / span > < span class = "n" > name< / span > < span class = "p" > ,< / span > < span class = "p" > [< / span > < span class = "s2" > " mandatory" < / span > < span class = "p" > ,< / span > < span class = "s2" > " default" < / span > < span class = "p" > ])< / span >
< span class = "k" > except< / span > < span class = "n" > dnf< / span > < span class = "o" > .< / span > < span class = "n" > exceptions< / span > < span class = "o" > .< / span > < span class = "n" > MarkingError< / 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 = "s2" > " Group < / span > < span class = "si" > %s< / span > < span class = "s2" > " < / span > < span class = "o" > %< / span > < span class = "p" > (< / span > < span class = "n" > name< / span > < span class = "p" > ),< / span > < span class = "nb" > str< / span > < span class = "p" > (< / span > < span class = "n" > e< / span > < span class = "p" > )))< / span >
2018-06-04 23:27:56 +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 >
2018-10-24 17:07:32 +00:00
< span class = "c1" > # Find the best package matching the name + version glob< / span >
< span class = "c1" > # dnf can return multiple packages if it is in more than 1 repository< / span >
< span class = "n" > query< / span > < span class = "o" > =< / span > < span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > sack< / span > < span class = "o" > .< / span > < span class = "n" > query< / span > < span class = "p" > ()< / span > < span class = "o" > .< / span > < span class = "n" > filterm< / span > < span class = "p" > (< / span > < span class = "n" > provides__glob< / span > < span class = "o" > =< / span > < span class = "n" > name< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "n" > version< / span > < span class = "p" > :< / span >
< span class = "n" > query< / span > < span class = "o" > .< / span > < span class = "n" > filterm< / span > < span class = "p" > (< / span > < span class = "n" > version__glob< / span > < span class = "o" > =< / span > < span class = "n" > version< / span > < span class = "p" > )< / span >
< span class = "n" > query< / span > < span class = "o" > .< / span > < span class = "n" > filterm< / span > < span class = "p" > (< / span > < span class = "n" > latest< / span > < span class = "o" > =< / span > < span class = "mi" > 1< / span > < span class = "p" > )< / span >
< span class = "k" > if< / span > < span class = "ow" > not< / span > < span class = "n" > query< / 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 = "s2" > " < / span > < span class = "si" > %s< / span > < span class = "s2" > -< / span > < span class = "si" > %s< / span > < span class = "s2" > " < / 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 = "s2" > " No match" < / span > < span class = "p" > ))< / span >
< span class = "k" > continue< / span >
< span class = "n" > sltr< / span > < span class = "o" > =< / span > < span class = "n" > dnf< / span > < span class = "o" > .< / span > < span class = "n" > selector< / span > < span class = "o" > .< / span > < span class = "n" > Selector< / span > < span class = "p" > (< / span > < span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > sack< / span > < span class = "p" > )< / span > < span class = "o" > .< / span > < span class = "n" > set< / span > < span class = "p" > (< / span > < span class = "n" > pkg< / span > < span class = "o" > =< / span > < span class = "n" > query< / span > < span class = "p" > )< / span >
< span class = "c1" > # NOTE: dnf says in near future there will be a " goal" attribute of Base class< / span >
< span class = "c1" > # so yes, we' re using a ' private' attribute here on purpose and with permission.< / span >
< span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > _goal< / span > < span class = "o" > .< / span > < span class = "n" > install< / span > < span class = "p" > (< / span > < span class = "n" > select< / span > < span class = "o" > =< / span > < span class = "n" > sltr< / span > < span class = "p" > ,< / span > < span class = "n" > optional< / span > < span class = "o" > =< / span > < span class = "kc" > False< / span > < span class = "p" > )< / span >
2018-07-20 22:51:06 +00:00
< 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 = "s2" > " The following package(s) had problems: < / span > < span class = "si" > %s< / span > < span class = "s2" > " < / span > < span class = "o" > %< / span > < span class = "s2" > " ," < / span > < span class = "o" > .< / span > < span class = "n" > join< / span > < span class = "p" > ([< / span > < span class = "s2" > " < / span > < span class = "si" > %s< / span > < span class = "s2" > (< / span > < span class = "si" > %s< / span > < span class = "s2" > )" < / 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-06-04 23:27:56 +00:00
2018-07-20 22:51:06 +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" > dbo< / span > < span class = "p" > ,< / span > < span class = "n" > projects< / span > < span class = "p" > ,< / span > < span class = "n" > groups< / span > < span class = "p" > ):< / span >
2018-06-04 23:27:56 +00:00
< span class = "sd" > " " " Return the dependencies for a list of projects< / span >
< span class = "sd" > :param dbo: dnf base object< / span >
< span class = "sd" > :type dbo: dnf.Base< / span >
< span class = "sd" > :param projects: The projects to find the dependencies for< / span >
< span class = "sd" > :type projects: List of Strings< / span >
2018-07-20 22:51:06 +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-06-04 23:27:56 +00:00
< span class = "sd" > :returns: NEVRA' s of the project and its dependencies< / span >
< span class = "sd" > :rtype: list of dicts< / span >
< span class = "sd" > :raises: ProjectsError if there was a problem installing something< / span >
< span class = "sd" > " " " < / span >
2018-07-20 22:51:06 +00:00
< span class = "n" > _depsolve< / span > < span class = "p" > (< / span > < span class = "n" > dbo< / span > < span class = "p" > ,< / span > < span class = "n" > projects< / span > < span class = "p" > ,< / span > < span class = "n" > groups< / span > < span class = "p" > )< / span >
2018-05-12 00:18:21 +00:00
< span class = "k" > try< / span > < span class = "p" > :< / span >
< span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > resolve< / span > < span class = "p" > ()< / span >
< span class = "k" > except< / span > < span class = "n" > dnf< / span > < span class = "o" > .< / span > < span class = "n" > exceptions< / span > < span class = "o" > .< / span > < span class = "n" > DepsolveError< / span > < span class = "k" > as< / span > < span class = "n" > e< / span > < span class = "p" > :< / span >
2018-06-04 23:27:56 +00:00
< span class = "k" > raise< / span > < span class = "n" > ProjectsError< / span > < span class = "p" > (< / span > < span class = "s2" > " There was a problem depsolving < / span > < span class = "si" > %s< / span > < span class = "s2" > : < / span > < span class = "si" > %s< / span > < span class = "s2" > " < / 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-05-12 00:18:21 +00:00
< span class = "k" > if< / span > < span class = "nb" > len< / span > < span class = "p" > (< / span > < span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > transaction< / span > < span class = "p" > )< / span > < span class = "o" > ==< / span > < span class = "mi" > 0< / span > < span class = "p" > :< / span >
< span class = "k" > return< / 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" > pkg_to_dep< / span > < span class = "p" > ,< / span > < span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > transaction< / span > < span class = "o" > .< / span > < span class = "n" > install_set< / 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 = "s2" > " 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 = "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" > 6144< / 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 hawkey.Package 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" > dnf 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" > files< / 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" > installsize< / span >
< span class = "k" > return< / span > < span class = "n" > installed_size< / span > < / div >
2018-07-20 22:51:06 +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" > dbo< / 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 = "kc" > True< / span > < span class = "p" > ):< / span >
2018-05-12 00:18:21 +00:00
< span class = "sd" > " " " Return the dependencies and installed size for a list of projects< / span >
< span class = "sd" > :param dbo: dnf base object< / span >
< span class = "sd" > :type dbo: dnf.Base< / span >
< span class = "sd" > :param project_names: The projects to find the dependencies for< / span >
< span class = "sd" > :type project_names: List of Strings< / span >
2018-07-20 22:51:06 +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-05-12 00:18:21 +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-04 23:27:56 +00:00
< span class = "sd" > :raises: ProjectsError if there was a problem installing something< / span >
2018-05-12 00:18:21 +00:00
< span class = "sd" > " " " < / span >
2018-07-20 22:51:06 +00:00
< span class = "n" > _depsolve< / span > < span class = "p" > (< / span > < span class = "n" > dbo< / span > < span class = "p" > ,< / span > < span class = "n" > projects< / span > < span class = "p" > ,< / span > < span class = "n" > groups< / span > < span class = "p" > )< / span >
2018-05-12 00:18:21 +00:00
< span class = "k" > if< / span > < span class = "n" > with_core< / span > < span class = "p" > :< / span >
< span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > group_install< / span > < span class = "p" > (< / span > < span class = "s2" > " core" < / span > < span class = "p" > ,< / span > < span class = "p" > [< / span > < span class = "s1" > ' mandatory' < / span > < span class = "p" > ,< / span > < span class = "s1" > ' default' < / span > < span class = "p" > ,< / span > < span class = "s1" > ' optional' < / span > < span class = "p" > ])< / span >
< span class = "k" > try< / span > < span class = "p" > :< / span >
< span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > resolve< / span > < span class = "p" > ()< / span >
< span class = "k" > except< / span > < span class = "n" > dnf< / span > < span class = "o" > .< / span > < span class = "n" > exceptions< / span > < span class = "o" > .< / span > < span class = "n" > DepsolveError< / span > < span class = "k" > as< / span > < span class = "n" > e< / span > < span class = "p" > :< / span >
2018-06-04 23:27:56 +00:00
< span class = "k" > raise< / span > < span class = "n" > ProjectsError< / span > < span class = "p" > (< / span > < span class = "s2" > " There was a problem depsolving < / span > < span class = "si" > %s< / span > < span class = "s2" > : < / span > < span class = "si" > %s< / span > < span class = "s2" > " < / 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-05-12 00:18:21 +00:00
< span class = "k" > if< / span > < span class = "nb" > len< / span > < span class = "p" > (< / span > < span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > transaction< / span > < span class = "p" > )< / span > < span class = "o" > ==< / span > < span class = "mi" > 0< / span > < span class = "p" > :< / span >
< span class = "k" > return< / span > < span class = "p" > (< / span > < span class = "mi" > 0< / span > < span class = "p" > ,< / 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" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > transaction< / span > < span class = "o" > .< / span > < span class = "n" > install_set< / 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" > pkg_to_dep< / span > < span class = "p" > ,< / span > < span class = "n" > dbo< / span > < span class = "o" > .< / span > < span class = "n" > transaction< / span > < span class = "o" > .< / span > < span class = "n" > install_set< / 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 = "s2" > " name" < / span > < span class = "p" > ]< / span > < span class = "o" > .< / span > < span class = "n" > lower< / 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 > < / 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" > dbo< / 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 dbo: dnf base object< / span >
< span class = "sd" > :type dbo: dnf.Base< / 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 = "c1" > # TODO - Figure out what to do with this for Fedora ' modules' < / span >
2019-03-27 23:44:14 +00:00
< span class = "k" > return< / span > < span class = "nb" > list< / span > < span class = "p" > (< / span > < span class = "nb" > map< / span > < span class = "p" > (< / span > < span class = "n" > proj_to_module< / span > < span class = "p" > ,< / span > < span class = "n" > projects_info< / span > < span class = "p" > (< / span > < span class = "n" > dbo< / span > < span class = "p" > ,< / span > < span class = "n" > module_names< / span > < span class = "p" > )))< / span > < / div >
2018-05-12 00:18:21 +00:00
< 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" > dbo< / 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 dbo: dnf base object< / span >
< span class = "sd" > :type dbo: dnf.Base< / 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 = "n" > modules< / span > < span class = "o" > =< / span > < span class = "n" > projects_info< / span > < span class = "p" > (< / span > < span class = "n" > dbo< / span > < span class = "p" > ,< / span > < span class = "n" > module_names< / span > < span class = "p" > )< / span >
< span class = "c1" > # 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-07-20 22:51:06 +00:00
< span class = "n" > module< / span > < span class = "p" > [< / span > < span class = "s2" > " dependencies" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "n" > projects_depsolve< / span > < span class = "p" > (< / span > < span class = "n" > dbo< / span > < span class = "p" > ,< / span > < span class = "p" > [(< / span > < span class = "n" > module< / span > < span class = "p" > [< / span > < span class = "s2" > " name" < / span > < span class = "p" > ],< / span > < span class = "s2" > " *.*" < / span > < span class = "p" > )],< / span > < span class = "p" > [])< / span >
2018-05-12 00:18:21 +00:00
< span class = "k" > return< / span > < span class = "n" > modules< / span > < / div >
2018-06-04 23:27:56 +00:00
< div class = "viewcode-block" id = "dnf_repo_to_file_repo" > < a class = "viewcode-back" href = "../../../pylorax.api.html#pylorax.api.projects.dnf_repo_to_file_repo" > [docs]< / a > < span class = "k" > def< / span > < span class = "nf" > dnf_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 DNF Repo object suitable for writing to a .repo file< / span >
< span class = "sd" > :param repo: DNF Repository< / span >
< span class = "sd" > :type repo: dnf.RepoDict< / span >
< span class = "sd" > :returns: A string< / span >
< span class = "sd" > :rtype: str< / span >
< span class = "sd" > The DNF Repo.dump() function does not produce a string that can be used as a dnf .repo file,< / span >
< span class = "sd" > it ouputs baseurl and gpgkey as python lists which DNF cannot read. So do this manually with< / span >
< span class = "sd" > only the attributes we care about.< / span >
< span class = "sd" > " " " < / span >
2018-10-24 17:07:32 +00:00
< span class = "n" > repo_str< / span > < span class = "o" > =< / span > < span class = "s2" > " [< / span > < span class = "si" > %s< / span > < span class = "s2" > ]< / span > < span class = "se" > \n< / span > < span class = "s2" > name = < / span > < span class = "si" > %s< / span > < span class = "se" > \n< / span > < span class = "s2" > " < / span > < span class = "o" > %< / 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 = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > name< / span > < span class = "p" > )< / span >
2018-06-04 23:27:56 +00:00
< span class = "k" > if< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > metalink< / span > < span class = "p" > :< / span >
< span class = "n" > repo_str< / span > < span class = "o" > +=< / span > < span class = "s2" > " metalink = < / span > < span class = "si" > %s< / span > < span class = "se" > \n< / span > < span class = "s2" > " < / span > < span class = "o" > %< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > 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" > repo_str< / span > < span class = "o" > +=< / span > < span class = "s2" > " mirrorlist = < / span > < span class = "si" > %s< / span > < span class = "se" > \n< / span > < span class = "s2" > " < / span > < span class = "o" > %< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > mirrorlist< / span >
< span class = "k" > elif< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > baseurl< / span > < span class = "p" > :< / span >
< span class = "n" > repo_str< / span > < span class = "o" > +=< / span > < span class = "s2" > " baseurl = < / span > < span class = "si" > %s< / span > < span class = "se" > \n< / span > < span class = "s2" > " < / 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 = "k" > else< / span > < span class = "p" > :< / span >
< span class = "k" > raise< / span > < span class = "ne" > RuntimeError< / span > < span class = "p" > (< / span > < span class = "s2" > " Repo has no baseurl, metalink, or mirrorlist" < / span > < span class = "p" > )< / span >
< span class = "c1" > # 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" > repo_str< / span > < span class = "o" > +=< / span > < span class = "s2" > " proxy = < / span > < span class = "si" > %s< / span > < span class = "se" > \n< / span > < span class = "s2" > " < / span > < span class = "o" > %< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > proxy< / span >
< span class = "n" > repo_str< / span > < span class = "o" > +=< / span > < span class = "s2" > " sslverify = < / span > < span class = "si" > %s< / span > < span class = "se" > \n< / span > < span class = "s2" > " < / span > < span class = "o" > %< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > sslverify< / span >
< span class = "n" > repo_str< / span > < span class = "o" > +=< / span > < span class = "s2" > " gpgcheck = < / span > < span class = "si" > %s< / span > < span class = "se" > \n< / span > < span class = "s2" > " < / span > < span class = "o" > %< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > gpgcheck< / 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" > repo_str< / span > < span class = "o" > +=< / span > < span class = "s2" > " gpgkey = < / span > < span class = "si" > %s< / span > < span class = "se" > \n< / span > < span class = "s2" > " < / span > < span class = "o" > %< / span > < span class = "s2" > " ," < / span > < span class = "o" > .< / span > < span class = "n" > join< / span > < span class = "p" > (< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > 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 DNF Repository< / span >
< span class = "sd" > :param repo: DNF Repository< / span >
< span class = "sd" > :type repo: dnf.RepoDict< / 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 = "s2" > " 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 = "s2" > " 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 = "s2" > " 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 = "s2" > " type" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "s2" > " 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 = "s2" > " 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 = "s2" > " type" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "s2" > " 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 = "s2" > " 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 = "s2" > " type" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "s2" > " 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 = "s2" > " Repo has no baseurl, metalink, or mirrorlist" < / span > < span class = "p" > )< / span >
< span class = "c1" > # 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 = "s2" > " 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 = "s2" > " check_ssl" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "kc" > False< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s2" > " check_ssl" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "kc" > 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 = "s2" > " check_gpg" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "kc" > False< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s2" > " check_gpg" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "kc" > 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 >
2018-10-24 17:07:32 +00:00
< span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s2" > " gpgkey_urls" < / span > < span class = "p" > ]< / span > < span class = "o" > =< / span > < span class = "nb" > list< / span > < span class = "p" > (< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > gpgkey< / span > < span class = "p" > )< / span >
2018-06-04 23:27:56 +00:00
< 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 = "n" > dnf_conf< / span > < span class = "p" > ):< / span >
< span class = "sd" > " " " Return a dnf Repo object 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 dnf Repo object< / span >
< span class = "sd" > :rtype: dnf.Repo< / 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_urls" : [< / 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" > repo< / span > < span class = "o" > =< / span > < span class = "n" > dnf< / span > < span class = "o" > .< / span > < span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > Repo< / span > < span class = "p" > (< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s2" > " name" < / span > < span class = "p" > ],< / span > < span class = "n" > dnf_conf< / span > < span class = "p" > )< / span >
< span class = "c1" > # This will allow errors to be raised so we can catch them< / span >
< span class = "c1" > # without this they are logged, but the repo is silently disabled< / span >
< span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > skip_if_unavailable< / span > < span class = "o" > =< / span > < span class = "kc" > False< / span >
< span class = "k" > if< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s2" > " type" < / span > < span class = "p" > ]< / span > < span class = "o" > ==< / span > < span class = "s2" > " yum-baseurl" < / span > < span class = "p" > :< / span >
< span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > baseurl< / span > < span class = "o" > =< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s2" > " url" < / span > < span class = "p" > ]< / span >
< span class = "k" > elif< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s2" > " type" < / span > < span class = "p" > ]< / span > < span class = "o" > ==< / span > < span class = "s2" > " yum-metalink" < / span > < span class = "p" > :< / span >
< span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > metalink< / span > < span class = "o" > =< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s2" > " url" < / span > < span class = "p" > ]< / span >
< span class = "k" > elif< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s2" > " type" < / span > < span class = "p" > ]< / span > < span class = "o" > ==< / span > < span class = "s2" > " yum-mirrorlist" < / span > < span class = "p" > :< / span >
< span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > mirrorlist< / span > < span class = "o" > =< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s2" > " url" < / span > < span class = "p" > ]< / span >
< span class = "k" > if< / span > < span class = "s2" > " proxy" < / span > < span class = "ow" > in< / span > < span class = "n" > source< / span > < span class = "p" > :< / span >
< span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > proxy< / span > < span class = "o" > =< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s2" > " proxy" < / span > < span class = "p" > ]< / span >
< span class = "k" > if< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s2" > " check_ssl" < / span > < span class = "p" > ]:< / span >
< span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > sslverify< / span > < span class = "o" > =< / span > < span class = "kc" > True< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > sslverify< / span > < span class = "o" > =< / span > < span class = "kc" > False< / span >
< span class = "k" > if< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s2" > " check_gpg" < / span > < span class = "p" > ]:< / span >
< span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > gpgcheck< / span > < span class = "o" > =< / span > < span class = "kc" > True< / span >
< span class = "k" > else< / span > < span class = "p" > :< / span >
< span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > gpgcheck< / span > < span class = "o" > =< / span > < span class = "kc" > False< / span >
< span class = "k" > if< / span > < span class = "s2" > " gpgkey_urls" < / span > < span class = "ow" > in< / span > < span class = "n" > source< / span > < span class = "p" > :< / span >
2018-10-24 17:07:32 +00:00
< span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > gpgkey< / span > < span class = "o" > =< / span > < span class = "nb" > tuple< / span > < span class = "p" > (< / span > < span class = "n" > source< / span > < span class = "p" > [< / span > < span class = "s2" > " gpgkey_urls" < / span > < span class = "p" > ])< / span >
2018-06-04 23:27:56 +00:00
< span class = "n" > repo< / span > < span class = "o" > .< / span > < span class = "n" > enable< / 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 = "kc" > 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 = "kc" > 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 = "c1" > # 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 = "s2" > " 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 = "c1" > # 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 = "s2" > " Problem deleting repo source < / span > < span class = "si" > %s< / span > < span class = "s2" > : < / span > < span class = "si" > %s< / span > < span class = "s2" > " < / 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 = "s2" > " source < / span > < span class = "si" > %s< / span > < span class = "s2" > not found" < / span > < span class = "o" > %< / span > < span class = "n" > source_name< / span > < span class = "p" > )< / span > < / div >
2018-05-12 00:18:21 +00:00
< / pre > < / div >
< / div >
< / div >
< footer >
< hr / >
< div role = "contentinfo" >
< p >
2018-11-13 17:53:31 +00:00
© Copyright 2018, Red Hat, Inc.
2018-05-12 00:18:21 +00:00
< / p >
< / div >
Built with < a href = "http://sphinx-doc.org/" > Sphinx< / a > using a < a href = "https://github.com/rtfd/sphinx_rtd_theme" > theme< / a > provided by < a href = "https://readthedocs.org" > Read the Docs< / a > .
< / footer >
< / div >
< / div >
< / section >
< / div >
< script type = "text/javascript" >
jQuery(function () {
2018-06-04 23:27:56 +00:00
SphinxRtdTheme.Navigation.enable(true);
2018-05-12 00:18:21 +00:00
});
2019-03-27 23:44:14 +00:00
< / script >
2018-05-12 00:18:21 +00:00
< / body >
< / html >