python-2.5.2/win32/Tools/versioncheck/checkversions.py
changeset 0 ae805ac0140d
equal deleted inserted replaced
-1:000000000000 0:ae805ac0140d
       
     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."""
       
     4 
       
     5 import os
       
     6 import getopt
       
     7 import sys
       
     8 import pyversioncheck
       
     9 
       
    10 CHECKNAME="_checkversion.py"
       
    11 
       
    12 VERBOSE=1
       
    13 
       
    14 USAGE="""Usage: checkversions [-v verboselevel] [dir ...]
       
    15 Recursively examine a tree (default: sys.prefix) and for each package
       
    16 with a _checkversion.py file compare the installed version against the current
       
    17 version.
       
    18 
       
    19 Values for verboselevel:
       
    20 0 - Minimal output, one line per package
       
    21 1 - Also print descriptions for outdated packages (default)
       
    22 2 - Print information on each URL checked
       
    23 3 - Check every URL for packages with multiple locations"""
       
    24 
       
    25 def 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 
       
    33 def walk1tree(tree):
       
    34     os.path.walk(tree, check1dir, None)
       
    35 
       
    36 def 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 
       
    51 if __name__ == '__main__':
       
    52     main()