Merged release21-maint changes.
[python/dscho.git] / Tools / versioncheck / checkversions.py
blob2420611a708d007f56dfec6a41559ba9037956e8
1 """Checkversions - recursively search a directory (default: sys.prefix)
2 for _checkversion.py files, and run each of them. This will tell you of
3 new versions available for any packages you have installed."""
5 import os
6 import getopt
7 import sys
8 import string
9 import pyversioncheck
11 CHECKNAME="_checkversion.py"
13 VERBOSE=1
15 USAGE="""Usage: checkversions [-v verboselevel] [dir ...]
16 Recursively examine a tree (default: sys.prefix) and for each package
17 with a _checkversion.py file compare the installed version against the current
18 version.
20 Values for verboselevel:
21 0 - Minimal output, one line per package
22 1 - Also print descriptions for outdated packages (default)
23 2 - Print information on each URL checked
24 3 - Check every URL for packages with multiple locations"""
26 def check1dir(dummy, dir, files):
27 if CHECKNAME in files:
28 fullname = os.path.join(dir, CHECKNAME)
29 try:
30 execfile(fullname)
31 except:
32 print '** Exception in', fullname
34 def walk1tree(tree):
35 os.path.walk(tree, check1dir, None)
37 def main():
38 global VERBOSE
39 try:
40 options, arguments = getopt.getopt(sys.argv[1:], 'v:')
41 except getopt.error:
42 print USAGE
43 sys.exit(1)
44 for o, a in options:
45 if o == '-v':
46 VERBOSE = string.atoi(a)
47 if not arguments:
48 arguments = [sys.prefix]
49 for dir in arguments:
50 walk1tree(dir)
52 if __name__ == '__main__':
53 main()