File: randomInst.py

package info (click to toggle)
update-manager 0.68.debian-7
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 6,796 kB
  • ctags: 814
  • sloc: python: 5,646; xml: 1,571; sh: 433; makefile: 356; ansic: 264
file content (20 lines) | stat: -rwxr-xr-x 547 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/python

import sys
import apt
from random import choice

cache = apt.Cache()
for i in range(int(sys.argv[1])):
    while True:
        pkgname = choice(cache.keys())
        if cache[pkgname].isInstalled:
            continue
        try:
            print "Trying to install: '%s'" % pkgname
            cache[pkgname].markInstall()
        except SystemError, e:
            print "Failed to install '%s' (%s)" % (pkgname,e)
            continue
        break
cache.commit(apt.progress.FetchProgress(), apt.progess.InstallProgress())