Need an example program that implements rpm -pql via import rpm

geremy condra debatem1 at gmail.com
Thu Mar 3 23:11:53 EST 2011


On Thu, Mar 3, 2011 at 7:24 PM, Steven W. Orr <steveo at syslang.net> wrote:
> I look everywhere but I couldn't find anything. Could someone please point
> me to a small example program that does an import rpm, takes an rpm file as
> an argument and gets the list of files contained in the file, the same as if
> I had used the commandline
>
> rpm -pql foo-1.23-4.i586.rpm
>
> Much appreciated.

#! /usr/bin/env python

import sys
import commands

if __name__ == "__main__":
    rpm = sys.argv[1]
    print commands.getoutput("rpm -pql %s" % rpm)


Input validation and help text left as an exercise for the reader.

Geremy Condra



More information about the Python-list mailing list