Description of problem: I am trying to write a small code to query packages. ========================== import dnf db = dnf.Base() db.read_all_repos() sack=db.fill_sack() q = db.sack.query() a = q.available() a = a.filter(name="hunspell") for pkg in a: print(pkg.name) ==================================== When run above code as a root user, gave me traceback $ sudo python dnf-srch.py Traceback (most recent call last): File "dnf-srch.py", line 5, in <module> sack=db.fill_sack() File "/usr/lib/python2.7/site-packages/dnf/base.py", line 207, in fill_sack self._add_repo_to_sack(r.id) File "/usr/lib/python2.7/site-packages/dnf/base.py", line 107, in _add_repo_to_sack repo.load() File "/usr/lib/python2.7/site-packages/dnf/repo.py", line 615, in load raise dnf.exceptions.RepoError(self._exc2msg(e)) dnf.exceptions.RepoError: Failed to synchronize cache for repo 'fedora': Cannot prepare internal mirrorlist: file repomd.xml was not found in metalink Version-Release number of selected component (if applicable): dnf-0.5.2-1.fc20.noarch dnf-plugins-core-0.0.8-2.fc20.noarch python3-dnf-0.5.2-1.fc20.noarch How reproducible: always Steps to Reproduce: 1. 2. 3. Actual results: Expected results: Additional info:
Will look at this.
you need to add db.conf.releasever = None just before db.read_all_repos() and it will work as root
still not working after implementing above in code. The code sleeps forever when run as root. I then after 2 min interrupted code and trace back is ^CTraceback (most recent call last): File "dnf-srch.py", line 6, in <module> sack=db.fill_sack() File "/usr/lib/python2.7/site-packages/dnf/base.py", line 207, in fill_sack self._add_repo_to_sack(r.id) File "/usr/lib/python2.7/site-packages/dnf/base.py", line 107, in _add_repo_to_sack repo.load() File "/usr/lib/python2.7/site-packages/dnf/repo.py", line 605, in load self._handle_load(handle) File "/usr/lib/python2.7/site-packages/dnf/repo.py", line 398, in _handle_load result = handle.perform() File "/usr/lib64/python2.7/site-packages/librepo/__init__.py", line 1322, in perform _librepo.Handle.perform(self, result) KeyboardInterrupt I run modified code thrice and it sleeps forever.
You have to wait a little longer, if dnf does a full cache refresh, it take around 4-5 min. You can check my dnf API samples here: https://github.com/timlau/dnf-apiex
Looks like now this modified code runs well today. Maybe today when I start the system, dnf got the full cache refresh when I did "dnf update" Tim, Thanks. I will check your samples.
> dnf.exceptions.RepoError: Failed to synchronize cache for repo 'fedora': > Cannot prepare internal mirrorlist: file repomd.xml was not found in metalink commit 1ecf1de improves the exception error message so the real problem is easier to spot. we still have to improve or document the releasever setting.
b3e8703 adds documentation that explains that substitutions need to be set prior to loading repositores.
dnf-plugins-core-0.1.1-2.fc20, dnf-0.5.3-1.fc20, hawkey-0.4.17-1.fc20 has been submitted as an update for Fedora 20. https://admin.fedoraproject.org/updates/dnf-0.5.3-1.fc20,hawkey-0.4.17-1.fc20,dnf-plugins-core-0.1.1-2.fc20
Package dnf-plugins-core-0.1.1-2.fc20, dnf-0.5.3-1.fc20, hawkey-0.4.17-1.fc20: * should fix your issue, * was pushed to the Fedora 20 testing repository, * should be available at your local mirror within two days. Update it with: # su -c 'yum update --enablerepo=updates-testing dnf-plugins-core-0.1.1-2.fc20 dnf-0.5.3-1.fc20 hawkey-0.4.17-1.fc20' as soon as you are able to. Please go to the following url: https://admin.fedoraproject.org/updates/FEDORA-2014-8167/dnf-0.5.3-1.fc20,hawkey-0.4.17-1.fc20,dnf-plugins-core-0.1.1-2.fc20 then log in and leave karma (feedback).
dnf-plugins-core-0.1.1-2.fc20, dnf-0.5.3-1.fc20, hawkey-0.4.17-1.fc20 has been pushed to the Fedora 20 stable repository. If problems still persist, please make note of it in this bug report.
I just tried to run the code given in initial comment again and found this is not fixed yet. Traceback (most recent call last): File "simple-dnf-srch.py", line 5, in <module> sack=db.fill_sack() File "/usr/lib/python2.7/site-packages/dnf/base.py", line 203, in fill_sack self._add_repo_to_sack(r.id) File "/usr/lib/python2.7/site-packages/dnf/base.py", line 102, in _add_repo_to_sack repo.load() File "/usr/lib/python2.7/site-packages/dnf/repo.py", line 643, in load raise dnf.exceptions.RepoError(msg) dnf.exceptions.RepoError: Failed to synchronize cache for repo 'fedora' from 'https://mirrors.fedoraproject.org/metalink?repo=fedora-$releasever&arch=x86_64': Cannot prepare internal mirrorlist: file repomd.xml was not found in metalink
Thanks Ales. This http://akozumpl.github.io/dnf/api_conf.html#dnf.conf.Conf.substitutions helped me.