annotate Tools/scripts/copytime.py @ 66978:aed2bbafa550 3.1

Blocked revisions 87324 via svnmerge ........ r87324 | r.david.murray | 2010-12-16 14:08:51 -0500 (Thu, 16 Dec 2010) | 9 lines #10719: restore messages generated on invalid compileall args Before the introduction of filename arguments to compileall it gave semi useful messages about not being able to 'list' names that weren't valid directories. This fix restores that behavior. In addition to the test for this case, the patch also adds a test for the default behavior of compileall when no arguments are provided, and fixes a bug in one of the previously added tests. ........
author R. David Murray <rdmurray@bitdance.com>
date Thu, 16 Dec 2010 19:10:16 +0000
parents 893a4dc17a91
children fcfe324663a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4573
73758db2f464 /usr/local/bin/python -> /usr/bin/env python
Guido van Rossum <guido@python.org>
parents: 1269
diff changeset
1 #! /usr/bin/env python
500
7f3faafd83ed Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
7f3faafd83ed Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 # Copy one file's atime and mtime to another
7f3faafd83ed Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
7f3faafd83ed Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 import sys
758
bfc655074523 posix -> os
Guido van Rossum <guido@python.org>
parents: 500
diff changeset
6 import os
500
7f3faafd83ed Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
7 from stat import ST_ATIME, ST_MTIME # Really constants 7 and 8
7f3faafd83ed Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
8
7f3faafd83ed Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 def main():
47100
893a4dc17a91 Ran 2to3 over scripts directory.
Georg Brandl <georg@python.org>
parents: 33074
diff changeset
10 if len(sys.argv) != 3:
15930
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
11 sys.stderr.write('usage: copytime source destination\n')
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
12 sys.exit(2)
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
13 file1, file2 = sys.argv[1], sys.argv[2]
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
14 try:
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
15 stat1 = os.stat(file1)
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
16 except os.error:
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
17 sys.stderr.write(file1 + ': cannot stat\n')
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
18 sys.exit(1)
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
19 try:
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
20 os.utime(file2, (stat1[ST_ATIME], stat1[ST_MTIME]))
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
21 except os.error:
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
22 sys.stderr.write(file2 + ': cannot change time\n')
14a27acc755a Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 4573
diff changeset
23 sys.exit(2)
500
7f3faafd83ed Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
24
33074
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 15930
diff changeset
25 if __name__ == '__main__':
981fff7363b9 [Patch #1005491 ] use __name__ == '__main__' in scripts
Andrew M. Kuchling <amk@amk.ca>
parents: 15930
diff changeset
26 main()