OLD | NEW |
1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 # This file contains a set of utilities functions used by other Python-based | 5 # This file contains a set of utilities functions used by other Python-based |
6 # scripts. | 6 # scripts. |
7 | 7 |
8 import commands | 8 import commands |
9 import os | 9 import os |
10 import platform | 10 import platform |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 if os.fork() > 0: | 190 if os.fork() > 0: |
191 return False | 191 return False |
192 os.setsid() | 192 os.setsid() |
193 if os.fork() > 0: | 193 if os.fork() > 0: |
194 os._exit(0) | 194 os._exit(0) |
195 raise | 195 raise |
196 return True | 196 return True |
197 | 197 |
198 | 198 |
199 def PrintError(str): | 199 def PrintError(str): |
| 200 """Writes and flushes a string to stderr.""" |
200 sys.stderr.write(str) | 201 sys.stderr.write(str) |
201 sys.stderr.write('\n') | 202 sys.stderr.write('\n') |
202 | 203 |
203 | 204 |
| 205 def CheckedUnlink(name): |
| 206 """Unlink a file without throwing an exception.""" |
| 207 try: |
| 208 os.unlink(name) |
| 209 except OSError, e: |
| 210 PrintError("os.unlink() " + str(e)) |
| 211 |
| 212 |
204 def Main(argv): | 213 def Main(argv): |
205 print "GuessOS() -> ", GuessOS() | 214 print "GuessOS() -> ", GuessOS() |
206 print "GuessArchitecture() -> ", GuessArchitecture() | 215 print "GuessArchitecture() -> ", GuessArchitecture() |
207 print "GuessCpus() -> ", GuessCpus() | 216 print "GuessCpus() -> ", GuessCpus() |
208 print "IsWindows() -> ", IsWindows() | 217 print "IsWindows() -> ", IsWindows() |
209 | 218 |
210 | 219 |
211 class Error(Exception): | 220 class Error(Exception): |
212 pass | 221 pass |
213 | 222 |
214 | 223 |
215 class ToolError(Exception): | 224 class ToolError(Exception): |
216 """Deprecated exception, use Error instead.""" | 225 """Deprecated exception, use Error instead.""" |
217 | 226 |
218 def __init__(self, value): | 227 def __init__(self, value): |
219 self.value = value | 228 self.value = value |
220 | 229 |
221 def __str__(self): | 230 def __str__(self): |
222 return repr(self.value) | 231 return repr(self.value) |
223 | 232 |
224 | 233 |
225 if __name__ == "__main__": | 234 if __name__ == "__main__": |
226 import sys | 235 import sys |
227 Main(sys.argv) | 236 Main(sys.argv) |
OLD | NEW |