[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Python and rpm (bis)
- From: josh lucas <lucas collab net>
- To: rpm-list redhat com
- Subject: Re: Python and rpm (bis)
- Date: 14 Nov 2001 14:56:39 -0800
On Wed, 2001-11-14 at 10:45, Matthias Saou wrote:
> Hi again... I'm still in my rpm and python mess, and still searching for
> help!
> Does anyone know how to simply get a given tag from an rpm file? This is a
> very basic operation, but I can't figure it out :-( I discovered that all
> tags had associated values, that there were in fact very few functions in
> the rpm python module, but since there are no docs, descriptions or
> anything, and that I'm still not really familiar with python... I'm stuck!
>
> [dude@python dude]$ python
> Python 1.5.2 (#1, Jul 5 2001, 03:02:19) [GCC 2.96 20000731 (Red Hat Linux
> 7.1 2 on linux-i386
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import rpm
> >>> print rpm.__doc__
> None
> >>> dir (rpm.headerFromPackage)
> ['__doc__', '__name__', '__self__']
> >>> print rpm.headerFromPackage.__doc__
> None
>
>
> (As you can see, not much explanations...)
>
>
> >>> filename = "/ftp/freshrpms/enigma/apg/apg-1.2.13-fr1.i386.rpm"
> >>> print rpm.headerFromPackage(filename, rpm.RPMTAG_ARCH)
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> TypeError: function requires exactly 1 argument; 2 given
> >>> print rpm.headerFromPackage(filename)
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> TypeError: illegal argument type for built-in operation
> >>> print rpm.headerFromPackage(rpm.RPMTAG_ARCH)
> Segmentation fault
>
>
> (Nope, that mustn't be what I'm supposed to feed that function... still I
> don't thing that python is supposed to segfault for that!!!)
>
> Help, pointers, examples, supportive messages and condolences are all very
> welcome :-/
> (well, no, not condolences... please!)
>
I've been using the rpm python bindings a bit lately but I'm still far
from fully knowledgable about them...
That being said, here's some sample code which might get you on your
way:
f = os.open(rpmfile,os.O_RDONLY)
(header,isSource) = rpm.headerFromPackage(f)
output = "%s %s %s %s\n" % (header[rpm.RPMTAG_NAME],
header[rpm.RPMTAG_VERSION],
header[rpm.RPMTAG_RELEASE],
header[rpm.RPMTAG_ARCH])
josh
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[]