| 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 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 # Try to guess the host architecture. | 37 # Try to guess the host architecture. |
| 38 def GuessArchitecture(): | 38 def GuessArchitecture(): |
| 39 id = platform.machine() | 39 id = platform.machine() |
| 40 if id.startswith('arm'): | 40 if id.startswith('arm'): |
| 41 return 'arm' | 41 return 'arm' |
| 42 elif (not id) or (not re.match('(x|i[3-6])86', id) is None): | 42 elif (not id) or (not re.match('(x|i[3-6])86', id) is None): |
| 43 return 'ia32' | 43 return 'ia32' |
| 44 elif id == 'i86pc': | 44 elif id == 'i86pc': |
| 45 return 'ia32' | 45 return 'ia32' |
| 46 elif '64' in id: |
| 47 return 'x64' |
| 46 else: | 48 else: |
| 47 return None | 49 return None |
| 48 | 50 |
| 49 | 51 |
| 50 # Try to guess the number of cpus on this machine. | 52 # Try to guess the number of cpus on this machine. |
| 51 def GuessCpus(): | 53 def GuessCpus(): |
| 52 if os.path.exists("/proc/cpuinfo"): | 54 if os.path.exists("/proc/cpuinfo"): |
| 53 return int(commands.getoutput("grep -E '^processor' /proc/cpuinfo | wc -l")) | 55 return int(commands.getoutput("grep -E '^processor' /proc/cpuinfo | wc -l")) |
| 54 if os.path.exists("/usr/bin/hostinfo"): | 56 if os.path.exists("/usr/bin/hostinfo"): |
| 55 return int(commands.getoutput('/usr/bin/hostinfo | grep "processors are logi
cally available." | awk "{ print \$1 }"')) | 57 return int(commands.getoutput('/usr/bin/hostinfo | grep "processors are logi
cally available." | awk "{ print \$1 }"')) |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 def __init__(self, value): | 257 def __init__(self, value): |
| 256 self.value = value | 258 self.value = value |
| 257 | 259 |
| 258 def __str__(self): | 260 def __str__(self): |
| 259 return repr(self.value) | 261 return repr(self.value) |
| 260 | 262 |
| 261 | 263 |
| 262 if __name__ == "__main__": | 264 if __name__ == "__main__": |
| 263 import sys | 265 import sys |
| 264 Main(sys.argv) | 266 Main(sys.argv) |
| OLD | NEW |