ยปCore Development>Code coverage>Tools/scripts/copytime.py

Python code coverage for Tools/scripts/copytime.py

#countcontent
1n/a#! /usr/bin/env python3
2n/a
3n/a# Copy one file's atime and mtime to another
4n/a
5n/aimport sys
6n/aimport os
7n/afrom stat import ST_ATIME, ST_MTIME # Really constants 7 and 8
8n/a
9n/adef main():
10n/a if len(sys.argv) != 3:
11n/a sys.stderr.write('usage: copytime source destination\n')
12n/a sys.exit(2)
13n/a file1, file2 = sys.argv[1], sys.argv[2]
14n/a try:
15n/a stat1 = os.stat(file1)
16n/a except OSError:
17n/a sys.stderr.write(file1 + ': cannot stat\n')
18n/a sys.exit(1)
19n/a try:
20n/a os.utime(file2, (stat1[ST_ATIME], stat1[ST_MTIME]))
21n/a except OSError:
22n/a sys.stderr.write(file2 + ': cannot change time\n')
23n/a sys.exit(2)
24n/a
25n/aif __name__ == '__main__':
26n/a main()