blob: 2420611a708d007f56dfec6a41559ba9037956e8 [file] [log] [blame]
Guido van Rossum52910371997-12-23 18:43:55 +00001"""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
Guido van Rossum9d98c911997-12-31 15:46:56 +00008import string
Guido van Rossum52910371997-12-23 18:43:55 +00009import pyversioncheck
10
11CHECKNAME="_checkversion.py"
12
13VERBOSE=1
14
15USAGE="""Usage: checkversions [-v verboselevel] [dir ...]
16Recursively examine a tree (default: sys.prefix) and for each package
17with a _checkversion.py file compare the installed version against the current
18version.
19
20Values for verboselevel:
210 - Minimal output, one line per package
221 - Also print descriptions for outdated packages (default)
232 - Print information on each URL checked
243 - Check every URL for packages with multiple locations"""
25
26def 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
33
34def walk1tree(tree):
35 os.path.walk(tree, check1dir, None)
36
37def 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)
51
52if __name__ == '__main__':
53 main()
54
55