equal
deleted
inserted
replaced
15 if f not in seen: |
15 if f not in seen: |
16 seen[f] = 1 |
16 seen[f] = 1 |
17 yield f |
17 yield f |
18 |
18 |
19 class CommandError(Exception): pass |
19 class CommandError(Exception): pass |
20 |
|
21 def explain_exit(code): |
|
22 """return a 2-tuple (desc, code) describing a process's status""" |
|
23 if os.WIFEXITED(code): |
|
24 val = os.WEXITSTATUS(code) |
|
25 return "exited with status %d" % val, val |
|
26 elif os.WIFSIGNALED(code): |
|
27 val = os.WTERMSIG(code) |
|
28 return "killed by signal %d" % val, val |
|
29 elif os.WIFSTOPPED(code): |
|
30 val = os.WSTOPSIG(code) |
|
31 return "stopped by signal %d" % val, val |
|
32 raise ValueError("invalid exit code") |
|
33 |
20 |
34 def always(fn): return True |
21 def always(fn): return True |
35 def never(fn): return False |
22 def never(fn): return False |
36 |
23 |
37 def globre(pat, head = '^', tail = '$'): |
24 def globre(pat, head = '^', tail = '$'): |
164 return path.replace("\\", "/") |
151 return path.replace("\\", "/") |
165 |
152 |
166 makelock = _makelock_file |
153 makelock = _makelock_file |
167 readlock = _readlock_file |
154 readlock = _readlock_file |
168 |
155 |
|
156 def explain_exit(code): |
|
157 return "exited with status %d" % code, code |
|
158 |
169 else: |
159 else: |
170 nulldev = '/dev/null' |
160 nulldev = '/dev/null' |
171 |
161 |
172 def is_exec(f, last): |
162 def is_exec(f, last): |
173 return (os.stat(f).st_mode & 0100 != 0) |
163 return (os.stat(f).st_mode & 0100 != 0) |
203 except OSError, why: |
193 except OSError, why: |
204 if why.errno == errno.EINVAL: |
194 if why.errno == errno.EINVAL: |
205 return _readlock_file(pathname) |
195 return _readlock_file(pathname) |
206 else: |
196 else: |
207 raise |
197 raise |
|
198 |
|
199 def explain_exit(code): |
|
200 """return a 2-tuple (desc, code) describing a process's status""" |
|
201 if os.WIFEXITED(code): |
|
202 val = os.WEXITSTATUS(code) |
|
203 return "exited with status %d" % val, val |
|
204 elif os.WIFSIGNALED(code): |
|
205 val = os.WTERMSIG(code) |
|
206 return "killed by signal %d" % val, val |
|
207 elif os.WIFSTOPPED(code): |
|
208 val = os.STOPSIG(code) |
|
209 return "stopped by signal %d" % val, val |
|
210 raise ValueError("invalid exit code") |