annotate Tools/versioncheck/checkversions.py @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents c3a096bfbd6b
children 46625e6122e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30772
diff changeset
1 """Checkversions - recursively search a directory (default: sys.prefix)
6935
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 for _checkversion.py files, and run each of them. This will tell you of
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 new versions available for any packages you have installed."""
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 import os
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 import getopt
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 import sys
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 import pyversioncheck
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 CHECKNAME="_checkversion.py"
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 VERBOSE=1
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
13
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 USAGE="""Usage: checkversions [-v verboselevel] [dir ...]
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
15 Recursively examine a tree (default: sys.prefix) and for each package
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 with a _checkversion.py file compare the installed version against the current
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 version.
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
18
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 Values for verboselevel:
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 0 - Minimal output, one line per package
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 1 - Also print descriptions for outdated packages (default)
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 2 - Print information on each URL checked
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 3 - Check every URL for packages with multiple locations"""
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
24
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 def check1dir(dummy, dir, files):
30772
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
26 if CHECKNAME in files:
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
27 fullname = os.path.join(dir, CHECKNAME)
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
28 try:
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
29 execfile(fullname)
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
30 except:
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
31 print '** Exception in', fullname
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 30772
diff changeset
32
6935
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 def walk1tree(tree):
30772
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
34 os.path.walk(tree, check1dir, None)
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
35
6935
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 def main():
30772
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
37 global VERBOSE
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
38 try:
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
39 options, arguments = getopt.getopt(sys.argv[1:], 'v:')
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
40 except getopt.error:
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
41 print USAGE
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
42 sys.exit(1)
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
43 for o, a in options:
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
44 if o == '-v':
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
45 VERBOSE = int(a)
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
46 if not arguments:
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
47 arguments = [sys.prefix]
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
48 for dir in arguments:
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
49 walk1tree(dir)
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
50
6935
6b6ef909238e Adding Jack Jansen's version checking utility.
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 if __name__ == '__main__':
30772
897afcacba00 Patch #812378: Normalize white space.
Martin v. Löwis <martin@v.loewis.de>
parents: 25219
diff changeset
52 main()