On Fri, Jul 04, 2003 at 10:06:04AM -0700, Andi Payn wrote:
> I wrote a quick python hack to look for any current packages that obsolete any
> other current package. I've included it at the end of this email.
> Unfortunately, I think it would take just about forever for me to run it
> (~5000 urpmf calls). Anyone who can run it faster, I'll be your best friend
> and love you forever and ever and all that stuff....
>
> You'll probably have to change line 6 (where I set urpmflags to select the
> right media), but that's about it. Oh, and ignore the tmpnam warnings;
> there's no other good alternative without python-expect or -pexpect. Just
> don't run two copies at once.
You are looking for os.popen and friends.
> Also, I have a few questions:
>
> 1. Is there a faster way to do this than running urpmf ~5000 times?
I've attached my version. Your version is still running, so I don't know
if it works correctly. Please compare it with the output of your version.
Don't forget to change the --media.
[..]
> 4. Would anyone besides me want a python-URPM? (This would obviously take some
> time, but I'd be happy to look into it.)
Might be nice.
> 5. Is there actually no python-expect or python-pexpect? Would anyone besides
> me want it? (This would take a few minutes.)
Searched for something like that last week. I found the following:
http://sourceforge.net/projects/pexpect/
> 6. While I'm at it, does anyone want any other python packages? For my own
> use, I've packaged up
> python-{rational,cRat,fpconst,indices,xoltar,xzip,Itpl,logging} and would be
> happy to share them (or, for that matter, describe them) if there's any
> potential interest. I'd be happy to similarly package up any common python
> modules....
More Python packages are always welcome here.
--
Regards,
Olav
#!/usr/bin/env python
import sys
import os
obsoletes = []
provides = {}
(child_stdin, child_stdout) = os.popen2(["urpmf", "", "--media", "cooker,contrib",
"--provides", "--obsoletes"])
child_stdin.close()
while (1):
line = child_stdout.readline()
if not line: break
ptv = line.strip().split(':')
if len(ptv) == 3:
package, tag, virtual = ptv
if tag == 'obsoletes':
obsoletes.append([virtual, package])
elif tag == 'provides':
if not provides.has_key(virtual):
provides[virtual] = []
provides[virtual].append(package)
for obsolete in obsoletes:
virtual, pkgo = obsolete
if provides.has_key(virtual):
for pkgp in provides[virtual]:
if pkgp != pkgo:
print "%s obsoletes %s, provided by %s" % (pkgo, virtual, pkgp)