blob: f110cac3e9046caeb9811c1581b995625bf1a65b [file] [log] [blame]
Tim Peters182b5ac2004-07-18 06:16:08 +00001"""Checkversions - recursively search a directory (default: sys.prefix)
Guido van Rossum52910371997-12-23 18:43:55 +00002for _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 Rossum52910371997-12-23 18:43:55 +00008import 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):
Martin v. Löwis23b44a32003-10-24 20:09:23 +000026 if CHECKNAME in files:
27 fullname = os.path.join(dir, CHECKNAME)
28 try:
Neal Norwitz01688022007-08-12 00:43:29 +000029 exec(open(fullname).read())
Martin v. Löwis23b44a32003-10-24 20:09:23 +000030 except:
Collin Winter6afaeb72007-08-03 17:06:41 +000031 print('** Exception in', fullname)
Tim Peters182b5ac2004-07-18 06:16:08 +000032
Guido van Rossum52910371997-12-23 18:43:55 +000033def walk1tree(tree):
Alexandre Vassalotti4e6531e2008-05-09 20:00:17 +000034 os.walk(tree, check1dir, None)
Martin v. Löwis23b44a32003-10-24 20:09:23 +000035
Guido van Rossum52910371997-12-23 18:43:55 +000036def main():
Martin v. Löwis23b44a32003-10-24 20:09:23 +000037 global VERBOSE
38 try:
39 options, arguments = getopt.getopt(sys.argv[1:], 'v:')
40 except getopt.error:
Collin Winter6afaeb72007-08-03 17:06:41 +000041 print(USAGE)
Martin v. Löwis23b44a32003-10-24 20:09:23 +000042 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
Guido van Rossum52910371997-12-23 18:43:55 +000051if __name__ == '__main__':
Martin v. Löwis23b44a32003-10-24 20:09:23 +000052 main()