From 9f221b0b0a12c38f7c274d1f0bd1dccf9861e69c Mon Sep 17 00:00:00 2001 From: Pat Riehecky Date: Apr 18 2017 19:09:10 +0000 Subject: Better error messages --- diff --git a/docs/data_from_updateinfo_xml.py b/docs/data_from_updateinfo_xml.py index 184fe21..c78e1b7 100755 --- a/docs/data_from_updateinfo_xml.py +++ b/docs/data_from_updateinfo_xml.py @@ -246,8 +246,11 @@ if __name__ == '__main__': THISCOLL = ARGS.collection THISCOLLNAME = ARGS.collectionreleasename else: - THISCOLL = what_collection_has_package(SOURCE[THISID], PACKAGENAME)[0] - THISCOLLNAME = SOURCE[THISID].collections[THISCOLL].release_name + try: + THISCOLL = what_collection_has_package(SOURCE[THISID], PACKAGENAME)[0] + THISCOLLNAME = SOURCE[THISID].collections[THISCOLL].release_name + except IndexError: + raise IndexError('Could not find collection for ' + str(PACKAGENAME) + ' in ' + str(THISID), file=sys.stderr) if THISCOLL not in MYUPDATEINFO[THISID].collections: if ARGS.debug: diff --git a/docs/show_missing_updates.py b/docs/show_missing_updates.py new file mode 100755 index 0000000..504b5e0 --- /dev/null +++ b/docs/show_missing_updates.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python +#PYTHON_ARGCOMPLETE_OK +#pylint: disable=line-too-long +''' + Read in the repodata from an existing yum repo and its existing + updateinfo.xml file. + + Basically this extracts the information from the yum repo and list + packages without an update id. +''' +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Version 0.1 by Pat Riehecky for Scientific Linux + +# for python3 compat +from __future__ import unicode_literals +from __future__ import absolute_import +from __future__ import print_function + +from updateinfo.updateinfo import Updateinfo +from updateinfo.helpers.repo import get_xml_from_repo, get_package_list_from_repo + +if __name__ == '__main__': + import textwrap, pprint + from argparse import ArgumentParser + + PARSER = ArgumentParser(description=textwrap.dedent(__doc__)) + + PARSER.add_argument('--repobase', help='Where is the repo located?') + + ARGS = PARSER.parse_args() + + MYUPDATEINFO = Updateinfo() + TXT = get_xml_from_repo(ARGS.repobase, mdtype='updateinfo') + MYUPDATEINFO.xml = TXT + + LISTED_PACKAGES = set(MYUPDATEINFO.packages) + REPO_PACKAGES = set(get_package_list_from_repo(ARGS.repobase)) + + UNLISTED_PACKAGES = REPO_PACKAGES.difference(LISTED_PACKAGES) + + pprint.pprint(UNLISTED_PACKAGES) + diff --git a/updateinfo/helpers/repo.py b/updateinfo/helpers/repo.py index f517de8..ddacd79 100644 --- a/updateinfo/helpers/repo.py +++ b/updateinfo/helpers/repo.py @@ -176,7 +176,7 @@ def get_package_list_from_repo(repobase): for element in primaryxml_obj: for child in element: if child.tag == common_ns + 'location': - rpm_list.add(child.attrib['href']) + rpm_list.add(os.path.basename(child.attrib['href'])) return tuple(rpm_list)