Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2014, 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 |
| 11 import re | 11 import re |
| 12 import shutil | 12 import shutil |
| 13 import subprocess | 13 import subprocess |
| 14 import sys | |
| 15 import tempfile | 14 import tempfile |
| 16 | 15 |
| 17 class Version(object): | 16 class Version(object): |
| 18 def __init__(self, channel, major, minor, patch, prerelease, | 17 def __init__(self, channel, major, minor, patch, prerelease, |
| 19 prerelease_patch): | 18 prerelease_patch): |
| 20 self.channel = channel | 19 self.channel = channel |
| 21 self.major = major | 20 self.major = major |
| 22 self.minor = minor | 21 self.minor = minor |
| 23 self.patch = patch | 22 self.patch = patch |
| 24 self.prerelease = prerelease | 23 self.prerelease = prerelease |
| 25 self.prerelease_patch = prerelease_patch | 24 self.prerelease_patch = prerelease_patch |
| 26 | 25 |
| 27 # Try to guess the host operating system. | 26 # Try to guess the host operating system. |
| 28 def GuessOS(): | 27 def GuessOS(): |
| 29 id = platform.system() | 28 os_id = platform.system() |
| 30 if id == "Linux": | 29 if os_id == "Linux": |
| 31 return "linux" | 30 return "linux" |
| 32 elif id == "Darwin": | 31 elif os_id == "Darwin": |
| 33 return "macos" | 32 return "macos" |
| 34 elif id == "Windows" or id == "Microsoft": | 33 elif os_id == "Windows" or os_id == "Microsoft": |
| 35 # On Windows Vista platform.system() can return "Microsoft" with some | 34 # On Windows Vista platform.system() can return "Microsoft" with some |
| 36 # versions of Python, see http://bugs.python.org/issue1082 for details. | 35 # versions of Python, see http://bugs.python.org/issue1082 for details. |
| 37 return "win32" | 36 return "win32" |
| 38 elif id == 'FreeBSD': | 37 elif os_id == 'FreeBSD': |
| 39 return 'freebsd' | 38 return 'freebsd' |
| 40 elif id == 'OpenBSD': | 39 elif os_id == 'OpenBSD': |
| 41 return 'openbsd' | 40 return 'openbsd' |
| 42 elif id == 'SunOS': | 41 elif os_id == 'SunOS': |
| 43 return 'solaris' | 42 return 'solaris' |
| 44 else: | 43 else: |
| 45 return None | 44 return None |
| 46 | 45 |
| 47 | 46 |
| 48 # Try to guess the host architecture. | 47 # Try to guess the host architecture. |
| 49 def GuessArchitecture(): | 48 def GuessArchitecture(): |
| 50 id = platform.machine() | 49 os_id = platform.machine() |
| 51 if id.startswith('arm'): | 50 if os_id.startswith('arm'): |
| 52 return 'arm' | 51 return 'arm' |
| 53 elif id.startswith('aarch64'): | 52 elif os_id.startswith('aarch64'): |
| 54 return 'arm64' | 53 return 'arm64' |
| 55 elif id.startswith('mips'): | 54 elif os_id.startswith('mips'): |
| 56 return 'mips' | 55 return 'mips' |
| 57 elif (not id) or (not re.match('(x|i[3-6])86', id) is None): | 56 elif (not os_id) or (not re.match('(x|i[3-6])86', os_id) is None): |
| 58 return 'ia32' | 57 return 'ia32' |
| 59 elif id == 'i86pc': | 58 elif os_id == 'i86pc': |
| 60 return 'ia32' | 59 return 'ia32' |
| 61 elif '64' in id: | 60 elif '64' in os_id: |
| 62 return 'x64' | 61 return 'x64' |
| 63 else: | 62 else: |
| 64 guess_os = GuessOS() | 63 guess_os = GuessOS() |
| 65 print "Warning: Guessing architecture %s based on os %s\n" % (id, guess_os) | 64 print "Warning: Guessing architecture %s based on os %s\n" % (os_id, guess_o s) |
| 66 if guess_os == 'win32': | 65 if guess_os == 'win32': |
| 67 return 'ia32' | 66 return 'ia32' |
| 68 return None | 67 return None |
| 69 | 68 |
| 70 | 69 |
| 71 # Try to guess the number of cpus on this machine. | 70 # Try to guess the number of cpus on this machine. |
| 72 def GuessCpus(): | 71 def GuessCpus(): |
| 73 if os.path.exists("/proc/cpuinfo"): | 72 if os.path.exists("/proc/cpuinfo"): |
| 74 return int(commands.getoutput("grep -E '^processor' /proc/cpuinfo | wc -l")) | 73 return int(commands.getoutput("grep -E '^processor' /proc/cpuinfo | wc -l")) |
| 75 if os.path.exists("/usr/bin/hostinfo"): | 74 if os.path.exists("/usr/bin/hostinfo"): |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 90 wow6432Node = '' | 89 wow6432Node = '' |
| 91 return r'SOFTWARE\%s%s' % (wow6432Node, name) | 90 return r'SOFTWARE\%s%s' % (wow6432Node, name) |
| 92 | 91 |
| 93 # Try to guess Visual Studio location when buiding on Windows. | 92 # Try to guess Visual Studio location when buiding on Windows. |
| 94 def GuessVisualStudioPath(): | 93 def GuessVisualStudioPath(): |
| 95 defaultPath = r"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7" \ | 94 defaultPath = r"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7" \ |
| 96 r"\IDE" | 95 r"\IDE" |
| 97 defaultExecutable = "devenv.com" | 96 defaultExecutable = "devenv.com" |
| 98 | 97 |
| 99 if not IsWindows(): | 98 if not IsWindows(): |
| 100 return (defaultPath, defaultExecutable) | 99 return defaultPath, defaultExecutable |
| 101 | 100 |
| 102 keyNamesAndExecutables = [ | 101 keyNamesAndExecutables = [ |
| 103 # Pair for non-Express editions. | 102 # Pair for non-Express editions. |
| 104 (GetWindowsRegistryKeyName(r'Microsoft\VisualStudio'), 'devenv.com'), | 103 (GetWindowsRegistryKeyName(r'Microsoft\VisualStudio'), 'devenv.com'), |
| 105 # Pair for 2012 Express edition. | 104 # Pair for 2012 Express edition. |
| 106 (GetWindowsRegistryKeyName(r'Microsoft\VSWinExpress'), 'VSWinExpress.exe'), | 105 (GetWindowsRegistryKeyName(r'Microsoft\VSWinExpress'), 'VSWinExpress.exe'), |
| 107 # Pair for pre-2012 Express editions. | 106 # Pair for pre-2012 Express editions. |
| 108 (GetWindowsRegistryKeyName(r'Microsoft\VCExpress'), 'VCExpress.exe')] | 107 (GetWindowsRegistryKeyName(r'Microsoft\VCExpress'), 'VCExpress.exe')] |
| 109 | 108 |
| 110 bestGuess = (0.0, (defaultPath, defaultExecutable)) | 109 bestGuess = (0.0, (defaultPath, defaultExecutable)) |
| 111 | 110 |
| 112 import _winreg | 111 import _winreg |
| 113 for (keyName, executable) in keyNamesAndExecutables: | 112 for (keyName, executable) in keyNamesAndExecutables: |
| 114 try: | 113 try: |
| 115 key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, keyName) | 114 key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, keyName) |
| 116 except WindowsError: | 115 except WindowsError: |
| 117 # Can't find this key - moving on the next one. | 116 # Can't find this key - moving on the next one. |
| 118 continue | 117 continue |
| 119 | 118 |
| 120 try: | 119 try: |
| 121 subkeyCounter = 0 | 120 subkeyCounter = 0 |
| 122 while True: | 121 while True: |
| 123 try: | 122 try: |
| 124 subkeyName = _winreg.EnumKey(key, subkeyCounter) | 123 subkeyName = _winreg.EnumKey(key, subkeyCounter) |
| 125 subkeyCounter = subkeyCounter + 1 | 124 subkeyCounter += 1 |
| 126 except WindowsError: | 125 except WindowsError: |
| 127 # Reached end of enumeration. Moving on the next key. | 126 # Reached end of enumeration. Moving on the next key. |
| 128 break | 127 break |
| 129 | 128 |
| 130 match = re.match(r'^\d+\.\d+$', subkeyName) | 129 match = re.match(r'^\d+\.\d+$', subkeyName) |
| 131 if match: | 130 if match: |
| 132 with _winreg.OpenKey(key, subkeyName) as subkey: | 131 with _winreg.OpenKey(key, subkeyName) as subkey: |
| 133 try: | 132 try: |
| 134 (installDir, registrytype) = _winreg.QueryValueEx(subkey, | 133 (installDir, registrytype) = _winreg.QueryValueEx(subkey, |
| 135 'InstallDir') | 134 'InstallDir') |
| 136 except WindowsError: | 135 except WindowsError: |
| 137 # Can't find value under the key - continue to the next key. | 136 # Can't find value under the key - continue to the next key. |
| 138 continue | 137 continue |
| 139 isExpress = executable != 'devenv.com' | 138 isExpress = executable != 'devenv.com' |
| 140 if not isExpress and subkeyName == '10.0': | 139 if not isExpress and subkeyName == '10.0': |
| 141 # Stop search since if we found non-Express VS2010 version | 140 # Stop search since if we found non-Express VS2010 version |
| 142 # installed, which is preferred version. | 141 # installed, which is preferred version. |
| 143 return (installDir, executable) | 142 return installDir, executable |
| 144 else: | 143 else: |
| 145 version = float(subkeyName) | 144 version = float(subkeyName) |
| 146 # We prefer higher version of Visual Studio and given equal | 145 # We prefer higher version of Visual Studio and given equal |
| 147 # version numbers we prefer non-Express edition. | 146 # version numbers we prefer non-Express edition. |
| 148 if version > bestGuess[0]: | 147 if version > bestGuess[0]: |
| 149 bestGuess = (version, (installDir, executable)) | 148 bestGuess = (version, (installDir, executable)) |
| 150 finally: | 149 finally: |
| 151 _winreg.CloseKey(key) | 150 _winreg.CloseKey(key) |
| 152 return bestGuess[1] | 151 return bestGuess[1] |
| 153 | 152 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 165 if '#' in line: | 164 if '#' in line: |
| 166 line = line[:line.find('#')] | 165 line = line[:line.find('#')] |
| 167 line = line.strip() | 166 line = line.strip() |
| 168 if len(line) == 0: | 167 if len(line) == 0: |
| 169 continue | 168 continue |
| 170 result.append(line) | 169 result.append(line) |
| 171 return result | 170 return result |
| 172 | 171 |
| 173 # Filters out all arguments until the next '--' argument | 172 # Filters out all arguments until the next '--' argument |
| 174 # occurs. | 173 # occurs. |
| 175 def ListArgCallback(option, opt_str, value, parser): | 174 def ListArgCallback(option, value, parser): |
| 176 if value is None: | 175 if value is None: |
| 177 value = [] | 176 value = [] |
| 178 | 177 |
| 179 for arg in parser.rargs: | 178 for arg in parser.rargs: |
| 180 if arg[:2].startswith('--'): | 179 if arg[:2].startswith('--'): |
| 181 break | 180 break |
| 182 value.append(arg) | 181 value.append(arg) |
| 183 | 182 |
| 184 del parser.rargs[:len(value)] | 183 del parser.rargs[:len(value)] |
| 185 setattr(parser.values, option.dest, value) | 184 setattr(parser.values, option.dest, value) |
| 186 | 185 |
| 187 | 186 |
| 188 # Filters out all argument until the first non '-' or the | 187 # Filters out all argument until the first non '-' or the |
| 189 # '--' argument occurs. | 188 # '--' argument occurs. |
| 190 def ListDartArgCallback(option, opt_str, value, parser): | 189 def ListDartArgCallback(option, value, parser): |
| 191 if value is None: | 190 if value is None: |
| 192 value = [] | 191 value = [] |
| 193 | 192 |
| 194 for arg in parser.rargs: | 193 for arg in parser.rargs: |
| 195 if arg[:2].startswith('--') or arg[0] != '-': | 194 if arg[:2].startswith('--') or arg[0] != '-': |
| 196 break | 195 break |
| 197 value.append(arg) | 196 value.append(arg) |
| 198 | 197 |
| 199 del parser.rargs[:len(value)] | 198 del parser.rargs[:len(value)] |
| 200 setattr(parser.values, option.dest, value) | 199 setattr(parser.values, option.dest, value) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 return '%s%s%s' % (GetBuildMode(mode), conf_os.title(), arch.upper()) | 246 return '%s%s%s' % (GetBuildMode(mode), conf_os.title(), arch.upper()) |
| 248 else: | 247 else: |
| 249 # Ask for a cross build if the host and target architectures don't match. | 248 # Ask for a cross build if the host and target architectures don't match. |
| 250 host_arch = ARCH_GUESS | 249 host_arch = ARCH_GUESS |
| 251 cross_build = '' | 250 cross_build = '' |
| 252 if GetArchFamily(host_arch) != GetArchFamily(arch): | 251 if GetArchFamily(host_arch) != GetArchFamily(arch): |
| 253 print "GetBuildConf: Cross-build of %s on %s\n" % (arch, host_arch) | 252 print "GetBuildConf: Cross-build of %s on %s\n" % (arch, host_arch) |
| 254 cross_build = 'X' | 253 cross_build = 'X' |
| 255 return '%s%s%s' % (GetBuildMode(mode), cross_build, arch.upper()) | 254 return '%s%s%s' % (GetBuildMode(mode), cross_build, arch.upper()) |
| 256 | 255 |
| 257 def GetBuildDir(host_os, target_os): | 256 def GetBuildDir(host_os): |
|
ricow1
2014/06/24 07:41:56
did you grep for this in the whole dart repo?
| |
| 258 return BUILD_ROOT[host_os] | 257 return BUILD_ROOT[host_os] |
| 259 | 258 |
| 260 def GetBuildRoot(host_os, mode=None, arch=None, target_os=None): | 259 def GetBuildRoot(host_os, mode=None, arch=None): |
| 261 build_root = GetBuildDir(host_os, target_os) | 260 build_root = GetBuildDir(host_os) |
| 262 if mode: | 261 if mode: |
| 263 build_root = os.path.join(build_root, GetBuildConf(mode, arch)) | 262 build_root = os.path.join(build_root, GetBuildConf(mode, arch)) |
| 264 return build_root | 263 return build_root |
| 265 | 264 |
| 266 def GetBaseDir(): | 265 def GetBaseDir(): |
| 267 return BASE_DIR | 266 return BASE_DIR |
| 268 | 267 |
| 269 def GetShortVersion(): | 268 def GetShortVersion(): |
| 270 version = ReadVersionFile() | 269 version = ReadVersionFile() |
| 271 return ('%s.%s.%s.%s.%s' % ( | 270 return ('%s.%s.%s.%s.%s' % ( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 version = ReadVersionFile() | 307 version = ReadVersionFile() |
| 309 return version.channel | 308 return version.channel |
| 310 | 309 |
| 311 def GetUserName(): | 310 def GetUserName(): |
| 312 key = 'USER' | 311 key = 'USER' |
| 313 if sys.platform == 'win32': | 312 if sys.platform == 'win32': |
| 314 key = 'USERNAME' | 313 key = 'USERNAME' |
| 315 return os.environ.get(key, '') | 314 return os.environ.get(key, '') |
| 316 | 315 |
| 317 def ReadVersionFile(): | 316 def ReadVersionFile(): |
| 318 def match_against(pattern, content): | 317 def match_against(pattern, file_content): |
| 319 match = re.search(pattern, content, flags=re.MULTILINE) | 318 match = re.search(pattern, file_content, flags=re.MULTILINE) |
| 320 if match: | 319 if match: |
| 321 return match.group(1) | 320 return match.group(1) |
| 322 return None | 321 return None |
| 323 | 322 |
| 324 version_file = os.path.join(DART_DIR, 'tools', 'VERSION') | 323 version_file = os.path.join(DART_DIR, 'tools', 'VERSION') |
| 325 try: | 324 try: |
| 326 fd = open(version_file) | 325 fd = open(version_file) |
| 327 content = fd.read() | 326 content = fd.read() |
| 328 fd.close() | 327 fd.close() |
| 329 except: | 328 except: |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 403 def ParseSvnInfoOutput(output): | 402 def ParseSvnInfoOutput(output): |
| 404 revision_match = re.search('Last Changed Rev: (\d+)', output) | 403 revision_match = re.search('Last Changed Rev: (\d+)', output) |
| 405 if revision_match: | 404 if revision_match: |
| 406 return revision_match.group(1) | 405 return revision_match.group(1) |
| 407 return None | 406 return None |
| 408 | 407 |
| 409 def RewritePathSeparator(path, workspace): | 408 def RewritePathSeparator(path, workspace): |
| 410 # Paths in test files are always specified using '/' | 409 # Paths in test files are always specified using '/' |
| 411 # as the path separator. Replace with the actual | 410 # as the path separator. Replace with the actual |
| 412 # path separator before use. | 411 # path separator before use. |
| 413 if ('/' in path): | 412 if '/' in path: |
| 414 split_path = path.split('/') | 413 split_path = path.split('/') |
| 415 path = os.sep.join(split_path) | 414 path = os.sep.join(split_path) |
| 416 path = os.path.join(workspace, path) | 415 path = os.path.join(workspace, path) |
| 417 if not os.path.exists(path): | 416 if not os.path.exists(path): |
| 418 raise Exception(path) | 417 raise Exception(path) |
| 419 return path | 418 return path |
| 420 | 419 |
| 421 | 420 |
| 422 def ParseTestOptions(pattern, source, workspace): | 421 def ParseTestOptions(pattern, source, workspace): |
| 423 match = pattern.search(source) | 422 match = pattern.search(source) |
| 424 if match: | 423 if match: |
| 425 return [RewritePathSeparator(o, workspace) for o in match.group(1).split(' ' )] | 424 return [RewritePathSeparator(o, workspace) for o in match.group(1).split(' ' )] |
| 426 else: | 425 else: |
| 427 return None | 426 return None |
| 428 | 427 |
| 429 | 428 |
| 430 def ParseTestOptionsMultiple(pattern, source, workspace): | 429 def ParseTestOptionsMultiple(pattern, source, workspace): |
| 431 matches = pattern.findall(source) | 430 matches = pattern.findall(source) |
| 432 if matches: | 431 if matches: |
| 433 result = [] | 432 result = [] |
| 434 for match in matches: | 433 for match in matches: |
| 435 if len(match) > 0: | 434 if len(match) > 0: |
| 436 result.append( | 435 result.append( |
| 437 [RewritePathSeparator(o, workspace) for o in match.split(' ')]); | 436 [RewritePathSeparator(o, workspace) for o in match.split(' ')]) |
| 438 else: | 437 else: |
| 439 result.append([]) | 438 result.append([]) |
| 440 return result | 439 return result |
| 441 else: | 440 else: |
| 442 return None | 441 return None |
| 443 | 442 |
| 444 | 443 |
| 445 def ConfigureJava(): | 444 def ConfigureJava(): |
| 446 java_home = '/usr/libexec/java_home' | 445 java_home = '/usr/libexec/java_home' |
| 447 if os.path.exists(java_home): | 446 if os.path.exists(java_home): |
| 448 proc = subprocess.Popen([java_home, '-v', '1.6+'], | 447 proc = subprocess.Popen([java_home, '-v', '1.6+'], |
| 449 stdout=subprocess.PIPE, | 448 stdout=subprocess.PIPE, |
| 450 stderr=subprocess.PIPE) | 449 stderr=subprocess.PIPE) |
| 451 (stdout, stderr) = proc.communicate() | 450 (stdout, stderr) = proc.communicate() |
| 452 if proc.wait() != 0: | 451 if proc.wait() != 0: |
| 453 return None | 452 return None |
| 454 new = stdout.strip() | 453 new = stdout.strip() |
| 455 current = os.getenv('JAVA_HOME', default=new) | 454 current = os.getenv('JAVA_HOME', new) |
| 456 if current != new: | 455 if current != new: |
| 457 sys.stderr.write('Please set JAVA_HOME to %s\n' % new) | 456 sys.stderr.write('Please set JAVA_HOME to %s\n' % new) |
| 458 os.putenv('JAVA_HOME', new) | 457 os.putenv('JAVA_HOME', new) |
| 459 | 458 |
| 460 | 459 |
| 461 def Daemonize(): | 460 def Daemonize(): |
| 462 """ | 461 """ |
| 463 Create a detached background process (daemon). Returns True for | 462 Create a detached background process (daemon). Returns True for |
| 464 the daemon, False for the parent process. | 463 the daemon, False for the parent process. |
| 465 See: http://www.faqs.org/faqs/unix-faq/programmer/faq/ | 464 See: http://www.faqs.org/faqs/unix-faq/programmer/faq/ |
| 466 "1.7 How do I get my program to act like a daemon?" | 465 "1.7 How do I get my program to act like a daemon?" |
| 467 """ | 466 """ |
| 468 if os.fork() > 0: | 467 if os.fork() > 0: |
| 469 return False | 468 return False |
| 470 os.setsid() | 469 os.setsid() |
| 471 if os.fork() > 0: | 470 if os.fork() > 0: |
| 472 os._exit(0) | 471 exit(0) |
| 473 raise | 472 raise |
| 474 return True | 473 return True |
| 475 | 474 |
| 476 | 475 |
| 477 def PrintError(str): | 476 def PrintError(string): |
| 478 """Writes and flushes a string to stderr.""" | 477 """Writes and flushes a string to stderr.""" |
| 479 sys.stderr.write(str) | 478 sys.stderr.write(string) |
| 480 sys.stderr.write('\n') | 479 sys.stderr.write('\n') |
| 481 | 480 |
| 482 | 481 |
| 483 def CheckedUnlink(name): | 482 def CheckedUnlink(name): |
| 484 """Unlink a file without throwing an exception.""" | 483 """Unlink a file without throwing an exception.""" |
| 485 try: | 484 try: |
| 486 os.unlink(name) | 485 os.unlink(name) |
| 487 except OSError, e: | 486 except OSError, e: |
| 488 PrintError("os.unlink() " + str(e)) | 487 PrintError("os.unlink() " + str(e)) |
| 489 | 488 |
| 490 | 489 |
| 491 def Main(argv): | 490 def Main(): |
| 492 print "GuessOS() -> ", GuessOS() | 491 print "GuessOS() -> ", GuessOS() |
| 493 print "GuessArchitecture() -> ", GuessArchitecture() | 492 print "GuessArchitecture() -> ", GuessArchitecture() |
| 494 print "GuessCpus() -> ", GuessCpus() | 493 print "GuessCpus() -> ", GuessCpus() |
| 495 print "IsWindows() -> ", IsWindows() | 494 print "IsWindows() -> ", IsWindows() |
| 496 print "GuessVisualStudioPath() -> ", GuessVisualStudioPath() | 495 print "GuessVisualStudioPath() -> ", GuessVisualStudioPath() |
| 497 | 496 |
| 498 | 497 |
| 499 class Error(Exception): | 498 class Error(Exception): |
| 500 pass | 499 pass |
| 501 | 500 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 529 | 528 |
| 530 | 529 |
| 531 def ExecuteCommand(cmd): | 530 def ExecuteCommand(cmd): |
| 532 """Execute a command in a subprocess.""" | 531 """Execute a command in a subprocess.""" |
| 533 print 'Executing: ' + ' '.join(cmd) | 532 print 'Executing: ' + ' '.join(cmd) |
| 534 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, | 533 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
| 535 shell=IsWindows()) | 534 shell=IsWindows()) |
| 536 output = pipe.communicate() | 535 output = pipe.communicate() |
| 537 if pipe.returncode != 0: | 536 if pipe.returncode != 0: |
| 538 raise Exception('Execution failed: ' + str(output)) | 537 raise Exception('Execution failed: ' + str(output)) |
| 539 return (pipe.returncode, output) | 538 return pipe.returncode, output |
| 540 | 539 |
| 541 | 540 |
| 542 def DartBinary(): | 541 def DartBinary(): |
| 543 tools_dir = os.path.dirname(os.path.realpath(__file__)) | 542 tools_dir = os.path.dirname(os.path.realpath(__file__)) |
| 544 dart_binary_prefix = os.path.join(tools_dir, 'testing', 'bin') | 543 dart_binary_prefix = os.path.join(tools_dir, 'testing', 'bin') |
| 545 if IsWindows(): | 544 if IsWindows(): |
| 546 return os.path.join(dart_binary_prefix, 'windows', 'dart.exe') | 545 return os.path.join(dart_binary_prefix, 'windows', 'dart.exe') |
| 547 else: | 546 else: |
| 548 arch = GuessArchitecture() | 547 arch = GuessArchitecture() |
| 549 system = GuessOS() | 548 system = GuessOS() |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 583 print "Enter directory = ", self._working_directory | 582 print "Enter directory = ", self._working_directory |
| 584 os.chdir(self._working_directory) | 583 os.chdir(self._working_directory) |
| 585 | 584 |
| 586 def __exit__(self, *_): | 585 def __exit__(self, *_): |
| 587 print "Enter directory = ", self._old_cwd | 586 print "Enter directory = ", self._old_cwd |
| 588 os.chdir(self._old_cwd) | 587 os.chdir(self._old_cwd) |
| 589 | 588 |
| 590 | 589 |
| 591 if __name__ == "__main__": | 590 if __name__ == "__main__": |
| 592 import sys | 591 import sys |
| 593 Main(sys.argv) | 592 Main() |
| OLD | NEW |