/Tools/versioncheck/checkversions.py

http://unladen-swallow.googlecode.com/ · Python · 52 lines · 41 code · 8 blank · 3 comment · 9 complexity · 9da3c2cd92715bcbef861fb304470737 MD5 · raw file

  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. import os
  5. import getopt
  6. import sys
  7. import pyversioncheck
  8. CHECKNAME="_checkversion.py"
  9. VERBOSE=1
  10. USAGE="""Usage: checkversions [-v verboselevel] [dir ...]
  11. Recursively examine a tree (default: sys.prefix) and for each package
  12. with a _checkversion.py file compare the installed version against the current
  13. version.
  14. Values for verboselevel:
  15. 0 - Minimal output, one line per package
  16. 1 - Also print descriptions for outdated packages (default)
  17. 2 - Print information on each URL checked
  18. 3 - Check every URL for packages with multiple locations"""
  19. def check1dir(dummy, dir, files):
  20. if CHECKNAME in files:
  21. fullname = os.path.join(dir, CHECKNAME)
  22. try:
  23. execfile(fullname)
  24. except:
  25. print '** Exception in', fullname
  26. def walk1tree(tree):
  27. os.path.walk(tree, check1dir, None)
  28. def main():
  29. global VERBOSE
  30. try:
  31. options, arguments = getopt.getopt(sys.argv[1:], 'v:')
  32. except getopt.error:
  33. print USAGE
  34. sys.exit(1)
  35. for o, a in options:
  36. if o == '-v':
  37. VERBOSE = int(a)
  38. if not arguments:
  39. arguments = [sys.prefix]
  40. for dir in arguments:
  41. walk1tree(dir)
  42. if __name__ == '__main__':
  43. main()