equal
deleted
inserted
replaced
1067 |
1067 |
1068 def testpid(pid): |
1068 def testpid(pid): |
1069 '''return False if pid dead, True if running or not known''' |
1069 '''return False if pid dead, True if running or not known''' |
1070 return True |
1070 return True |
1071 |
1071 |
1072 def set_flags(f, flags): |
1072 def set_flags(f, l, x): |
1073 pass |
1073 pass |
1074 |
1074 |
1075 def set_binary(fd): |
1075 def set_binary(fd): |
1076 # When run without console, pipes may expose invalid |
1076 # When run without console, pipes may expose invalid |
1077 # fileno(), usually set to -1. |
1077 # fileno(), usually set to -1. |
1214 |
1214 |
1215 def is_exec(f): |
1215 def is_exec(f): |
1216 """check whether a file is executable""" |
1216 """check whether a file is executable""" |
1217 return (os.lstat(f).st_mode & 0100 != 0) |
1217 return (os.lstat(f).st_mode & 0100 != 0) |
1218 |
1218 |
1219 def set_flags(f, flags): |
1219 def set_flags(f, l, x): |
1220 s = os.lstat(f).st_mode |
1220 s = os.lstat(f).st_mode |
1221 x = "x" in flags |
|
1222 l = "l" in flags |
|
1223 if l: |
1221 if l: |
1224 if not stat.S_ISLNK(s): |
1222 if not stat.S_ISLNK(s): |
1225 # switch file to link |
1223 # switch file to link |
1226 data = file(f).read() |
1224 data = file(f).read() |
1227 os.unlink(f) |
1225 os.unlink(f) |
1228 os.symlink(data, f) |
1226 try: |
|
1227 os.symlink(data, f) |
|
1228 except: |
|
1229 # failed to make a link, rewrite file |
|
1230 file(f, "w").write(data) |
1229 # no chmod needed at this point |
1231 # no chmod needed at this point |
1230 return |
1232 return |
1231 if stat.S_ISLNK(s): |
1233 if stat.S_ISLNK(s): |
1232 # switch link to file |
1234 # switch link to file |
1233 data = os.readlink(f) |
1235 data = os.readlink(f) |