File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66#
77# Options -[amc] select atime, mtime (default) or ctime as age.
88
9- import sys , posix , time
9+ import sys , os , time
1010import string
1111from stat import *
1212
1313# Use lstat() to stat files if it exists, else stat()
1414try :
15- statfunc = posix .lstat
16- except NameError :
17- statfunc = posix .stat
15+ statfunc = os .lstat
16+ except AttributeError :
17+ statfunc = os .stat
1818
1919# Parse options
2020if sys .argv [1 ] == '-m' :
4242for file in sys .argv [1 :]:
4343 try :
4444 st = statfunc (file )
45- except posix .error , msg :
45+ except os .error , msg :
4646 sys .stderr .write ('can\' t stat ' + `file` + ': ' + `msg` + '\n ' )
4747 status = 1
4848 st = ()
Original file line number Diff line number Diff line change 11# Check that all ".pyc" files exist and are up-to-date
2- # Uses module 'posix '
2+ # Uses module 'os '
33
44import sys
5- import posix
6- import path
5+ import os
76from stat import ST_MTIME
87
98def main ():
@@ -24,19 +23,19 @@ def main():
2423 print 'Using MAGIC word' , `MAGIC`
2524 for dirname in sys .path :
2625 try :
27- names = posix .listdir (dirname )
28- except posix .error :
26+ names = os .listdir (dirname )
27+ except os .error :
2928 print 'Cannot list directory' , `dirname`
3029 continue
3130 if not silent :
3231 print 'Checking' , `dirname` , '...'
3332 names .sort ()
3433 for name in names :
3534 if name [- 3 :] == '.py' :
36- name = path .join (dirname , name )
35+ name = os . path .join (dirname , name )
3736 try :
38- st = posix .stat (name )
39- except posix .error :
37+ st = os .stat (name )
38+ except os .error :
4039 print 'Cannot stat' , `name`
4140 continue
4241 if verbose :
Original file line number Diff line number Diff line change 33# Copy one file's atime and mtime to another
44
55import sys
6- import posix
6+ import os
77from stat import ST_ATIME , ST_MTIME # Really constants 7 and 8
88
99def main ():
@@ -12,13 +12,13 @@ def main():
1212 sys .exit (2 )
1313 file1 , file2 = sys .argv [1 ], sys .argv [2 ]
1414 try :
15- stat1 = posix .stat (file1 )
16- except posix .error :
15+ stat1 = os .stat (file1 )
16+ except os .error :
1717 sys .stderr .write (file1 + ': cannot stat\n ' )
1818 sys .exit (1 )
1919 try :
20- posix .utime (file2 , (stat1 [ST_ATIME ], stat1 [ST_MTIME ]))
21- except posix .error :
20+ os .utime (file2 , (stat1 [ST_ATIME ], stat1 [ST_MTIME ]))
21+ except os .error :
2222 sys .stderr .write (file2 + ': cannot change time\n ' )
2323 sys .exit (2 )
2424
You can’t perform that action at this time.
0 commit comments