home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 April / PCWorld_2001-04_cd.bin / Software / TemaCD / webclean / !!!python!!! / BeOpen-Python-2.0.exe / CHECKVERSIONS.PY < prev    next >
Encoding:
Python Source  |  2000-09-28  |  1.4 KB  |  56 lines

  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 string
  9. import pyversioncheck
  10.  
  11. CHECKNAME="_checkversion.py"
  12.  
  13. VERBOSE=1
  14.  
  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.
  19.  
  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"""
  25.  
  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
  33.             
  34. def walk1tree(tree):
  35.     os.path.walk(tree, check1dir, None)
  36.     
  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)
  51.         
  52. if __name__ == '__main__':
  53.     main()
  54.         
  55.     
  56.