| 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' | |
| 48 else: | 46 else: |
| 49 return None | 47 return None |
| 50 | 48 |
| 51 | 49 |
| 52 # Try to guess the number of cpus on this machine. | 50 # Try to guess the number of cpus on this machine. |
| 53 def GuessCpus(): | 51 def GuessCpus(): |
| 54 if os.path.exists("/proc/cpuinfo"): | 52 if os.path.exists("/proc/cpuinfo"): |
| 55 return int(commands.getoutput("grep -E '^processor' /proc/cpuinfo | wc -l")) | 53 return int(commands.getoutput("grep -E '^processor' /proc/cpuinfo | wc -l")) |
| 56 if os.path.exists("/usr/bin/hostinfo"): | 54 if os.path.exists("/usr/bin/hostinfo"): |
| 57 return int(commands.getoutput('/usr/bin/hostinfo | grep "processors are logi
cally available." | awk "{ print \$1 }"')) | 55 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... |
| 257 def __init__(self, value): | 255 def __init__(self, value): |
| 258 self.value = value | 256 self.value = value |
| 259 | 257 |
| 260 def __str__(self): | 258 def __str__(self): |
| 261 return repr(self.value) | 259 return repr(self.value) |
| 262 | 260 |
| 263 | 261 |
| 264 if __name__ == "__main__": | 262 if __name__ == "__main__": |
| 265 import sys | 263 import sys |
| 266 Main(sys.argv) | 264 Main(sys.argv) |
| OLD | NEW |