Show More
@@ -84,6 +84,21 b' def setflags(f, l, x):' | |||||
84 | # Turn off all +x bits |
|
84 | # Turn off all +x bits | |
85 | os.chmod(f, s & 0666) |
|
85 | os.chmod(f, s & 0666) | |
86 |
|
86 | |||
|
87 | def copymode(src, dst, mode=None): | |||
|
88 | '''Copy the file mode from the file at path src to dst. | |||
|
89 | If src doesn't exist, we're using mode instead. If mode is None, we're | |||
|
90 | using umask.''' | |||
|
91 | try: | |||
|
92 | st_mode = os.lstat(src).st_mode & 0777 | |||
|
93 | except OSError, inst: | |||
|
94 | if inst.errno != errno.ENOENT: | |||
|
95 | raise | |||
|
96 | st_mode = mode | |||
|
97 | if st_mode is None: | |||
|
98 | st_mode = ~umask | |||
|
99 | st_mode &= 0666 | |||
|
100 | os.chmod(dst, st_mode) | |||
|
101 | ||||
87 | def checkexec(path): |
|
102 | def checkexec(path): | |
88 | """ |
|
103 | """ | |
89 | Check whether the given path is on a filesystem with UNIX-like exec flags |
|
104 | Check whether the given path is on a filesystem with UNIX-like exec flags |
@@ -27,6 +27,7 b' else:' | |||||
27 | cachestat = platform.cachestat |
|
27 | cachestat = platform.cachestat | |
28 | checkexec = platform.checkexec |
|
28 | checkexec = platform.checkexec | |
29 | checklink = platform.checklink |
|
29 | checklink = platform.checklink | |
|
30 | copymode = platform.copymode | |||
30 | executablepath = platform.executablepath |
|
31 | executablepath = platform.executablepath | |
31 | expandglobs = platform.expandglobs |
|
32 | expandglobs = platform.expandglobs | |
32 | explainexit = platform.explainexit |
|
33 | explainexit = platform.explainexit | |
@@ -701,21 +702,6 b' def gui():' | |||||
701 | else: |
|
702 | else: | |
702 | return os.name == "nt" or os.environ.get("DISPLAY") |
|
703 | return os.name == "nt" or os.environ.get("DISPLAY") | |
703 |
|
704 | |||
704 | def copymode(src, dst, mode=None): |
|
|||
705 | '''Copy the file mode from the file at path src to dst. |
|
|||
706 | If src doesn't exist, we're using mode instead. If mode is None, we're |
|
|||
707 | using umask.''' |
|
|||
708 | try: |
|
|||
709 | st_mode = os.lstat(src).st_mode & 0777 |
|
|||
710 | except OSError, inst: |
|
|||
711 | if inst.errno != errno.ENOENT: |
|
|||
712 | raise |
|
|||
713 | st_mode = mode |
|
|||
714 | if st_mode is None: |
|
|||
715 | st_mode = ~umask |
|
|||
716 | st_mode &= 0666 |
|
|||
717 | os.chmod(dst, st_mode) |
|
|||
718 |
|
||||
719 | def mktempcopy(name, emptyok=False, createmode=None): |
|
705 | def mktempcopy(name, emptyok=False, createmode=None): | |
720 | """Create a temporary file with the same contents from name |
|
706 | """Create a temporary file with the same contents from name | |
721 |
|
707 |
General Comments 0
You need to be logged in to leave comments.
Login now