Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
7cd94b8a
Commit
7cd94b8a
authored
Oct 19, 2010
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Issue10140 - Tools/scripts/pathfix.py: add option to preserve timestamps
parent
e474309b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
3 deletions
+18
-3
Tools/scripts/pathfix.py
Tools/scripts/pathfix.py
+18
-3
No files found.
Tools/scripts/pathfix.py
View file @
7cd94b8a
...
...
@@ -30,20 +30,24 @@ dbg = err
rep
=
sys
.
stdout
.
write
new_interpreter
=
None
preserve_timestamps
=
False
def
main
():
global
new_interpreter
usage
=
(
'usage: %s -i /interpreter file-or-directory ...
\
n
'
%
global
preserve_timestamps
usage
=
(
'usage: %s -i /interpreter -p file-or-directory ...
\
n
'
%
sys
.
argv
[
0
])
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'i:'
)
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'i:
p
'
)
except
getopt
.
error
as
msg
:
err
(
msg
+
'
\
n
'
)
err
(
str
(
msg
)
+
'
\
n
'
)
err
(
usage
)
sys
.
exit
(
2
)
for
o
,
a
in
opts
:
if
o
==
'-i'
:
new_interpreter
=
a
.
encode
()
if
o
==
'-p'
:
preserve_timestamps
=
True
if
not
new_interpreter
or
not
new_interpreter
.
startswith
(
b'/'
)
or
\
not
args
:
err
(
'-i option or file-or-directory missing
\
n
'
)
...
...
@@ -119,9 +123,13 @@ def fix(filename):
# Finishing touch -- move files
mtime = None
atime = None
# First copy the file'
s
mode
to
the
temp
file
try
:
statbuf
=
os
.
stat
(
filename
)
mtime
=
statbuf
.
st_mtime
atime
=
statbuf
.
st_atime
os
.
chmod
(
tempname
,
statbuf
[
ST_MODE
]
&
0o7777
)
except
os
.
error
as
msg
:
err
(
'%s: warning: chmod failed (%r)
\
n
'
%
(
tempname
,
msg
))
...
...
@@ -136,6 +144,13 @@ def fix(filename):
except
os
.
error
as
msg
:
err
(
'%s: rename failed (%r)
\
n
'
%
(
filename
,
msg
))
return
1
if
preserve_timestamps
:
if
atime
and
mtime
:
try
:
os
.
utime
(
filename
,
(
atime
,
mtime
))
except
os
.
error
as
msg
:
err
(
'%s: reset of timestamp failed (%r)
\
n
'
%
(
filename
,
msg
))
return
1
# Return succes
return
0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment