PageRenderTime 746ms CodeModel.GetById 594ms app.highlight 3ms RepoModel.GetById 147ms app.codeStats 1ms

/Tools/versioncheck/checkversions.py

http://unladen-swallow.googlecode.com/
Python | 52 lines | 45 code | 4 blank | 3 comment | 0 complexity | 9da3c2cd92715bcbef861fb304470737 MD5 | raw file
 1"""Checkversions - recursively search a directory (default: sys.prefix)
 2for _checkversion.py files, and run each of them. This will tell you of
 3new versions available for any packages you have installed."""
 4
 5import os
 6import getopt
 7import sys
 8import pyversioncheck
 9
10CHECKNAME="_checkversion.py"
11
12VERBOSE=1
13
14USAGE="""Usage: checkversions [-v verboselevel] [dir ...]
15Recursively examine a tree (default: sys.prefix) and for each package
16with a _checkversion.py file compare the installed version against the current
17version.
18
19Values for verboselevel:
200 - Minimal output, one line per package
211 - Also print descriptions for outdated packages (default)
222 - Print information on each URL checked
233 - Check every URL for packages with multiple locations"""
24
25def check1dir(dummy, dir, files):
26    if CHECKNAME in files:
27        fullname = os.path.join(dir, CHECKNAME)
28        try:
29            execfile(fullname)
30        except:
31            print '** Exception in', fullname
32
33def walk1tree(tree):
34    os.path.walk(tree, check1dir, None)
35
36def main():
37    global VERBOSE
38    try:
39        options, arguments = getopt.getopt(sys.argv[1:], 'v:')
40    except getopt.error:
41        print USAGE
42        sys.exit(1)
43    for o, a in options:
44        if o == '-v':
45            VERBOSE = int(a)
46    if not arguments:
47        arguments = [sys.prefix]
48    for dir in arguments:
49        walk1tree(dir)
50
51if __name__ == '__main__':
52    main()