Re: need some help!
Panu Matilainen <[email protected]> Tue, 22 Mar 2005 10:49:16 +0200 (EET)
| Newsgroups | gmane.linux.redhat.rpm.python |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 22 Mar 2005, Basem Narmok wrote:
> Hi all,
> I had a small script that worked for a while, but now days on rhel4 it
> doesn't !!
>
> consider this:
>
> mi=ts.dbMatch("name","foo")
> for hdr in mi: #*THE PROBLEM HERE!*
> print "%s-%s-%s" % (hdr[name], hdr[version], hdr[release])
>
> the script just doesn't go in the for loop!! what is the problem?
There's no package "foo" installed? This certainly works for me on rhel 4
and others:
---
#!/usr/bin/python
import rpm
import sys
ts = rpm.TransactionSet()
mi=ts.dbMatch("name",sys.argv[1])
for hdr in mi:
print "%s-%s-%s" % (hdr["name"], hdr["version"], hdr["release"])
---
[pmatilai@localhost ~]$ ./pytest.py kernel
kernel-2.6.9-5.0.3.EL
- Panu -