Using python to get a list of repositories, including RHEL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Forgive my ignorance: I'm a long time Debian/Ubuntu user and admin, so I'm not up on all the things everyone might take to be normal.

My goal is to use a python script to get all a systems repositories in a data structure (list,dict,whatever). I've gotten most of the way there with the below which is able to get all repositories in /etc/yum.repos.d/*.repo. However, I can't find any reference to how to also make python3-dnf get the RHEL repositories as well... even though it is clearly capable of doing so (see below). 

Any pointers would be greatly appreciated.

<code>
#!/usr/bin/env python3
import dnf
base = dnf.Base()
base.read_all_repos()
base.fill_sack()
base.fill_sack_from_repos_in_cache()

# This prints all non RHEL repositories ONLY
for repo in base.repos.all():
  #print(repo.dump())
  print(repo.id)

# This returns an empty list
print(base.repos.get_matching('rhel'))
</code>

Yet... when I use the CLI I do get the rhel repos.
# dnf repolist rhel* | awk '{print $1}'|grep rhel                                      
rhel-x86_64-appstream-8
rhel-x86_64-baseos-8
rhel-x86_64-codeready-builder-8
rhel-x86_64-supplementary-8

Here is what happens when you run the script above.
No rhel repos are returned.
# ~/t.py
elrepo
epel
[]  # empty list when using get_matching("rhel")

Cheers,

Phil
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux