| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Utility functions used by the bisect tool. | 5 """Utility functions used by the bisect tool. |
| 6 | 6 |
| 7 This includes functions related to checking out the depot and outputting | 7 This includes functions related to checking out the depot and outputting |
| 8 annotations for the Buildbot waterfall. | 8 annotations for the Buildbot waterfall. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 proc = subprocess.Popen(command, shell=shell, stdout=subprocess.PIPE) | 499 proc = subprocess.Popen(command, shell=shell, stdout=subprocess.PIPE) |
| 500 (output, _) = proc.communicate() | 500 (output, _) = proc.communicate() |
| 501 | 501 |
| 502 if cwd: | 502 if cwd: |
| 503 os.chdir(original_cwd) | 503 os.chdir(original_cwd) |
| 504 | 504 |
| 505 return (output, proc.returncode) | 505 return (output, proc.returncode) |
| 506 | 506 |
| 507 | 507 |
| 508 def IsStringInt(string_to_check): | 508 def IsStringInt(string_to_check): |
| 509 """Checks whether or not the given string can be converted to a integer. | 509 """Checks whether or not the given string can be converted to an int.""" |
| 510 | |
| 511 Args: | |
| 512 string_to_check: Input string to check if it can be converted to an int. | |
| 513 | |
| 514 Returns: | |
| 515 True if the string can be converted to an int. | |
| 516 """ | |
| 517 try: | 510 try: |
| 518 int(string_to_check) | 511 int(string_to_check) |
| 519 return True | 512 return True |
| 520 except ValueError: | 513 except ValueError: |
| 521 return False | 514 return False |
| 522 | 515 |
| 523 | 516 |
| 524 def IsStringFloat(string_to_check): | 517 def IsStringFloat(string_to_check): |
| 525 """Checks whether or not the given string can be converted to a floating | 518 """Checks whether or not the given string can be converted to a float.""" |
| 526 point number. | |
| 527 | |
| 528 Args: | |
| 529 string_to_check: Input string to check if it can be converted to a float. | |
| 530 | |
| 531 Returns: | |
| 532 True if the string can be converted to a float. | |
| 533 """ | |
| 534 try: | 519 try: |
| 535 float(string_to_check) | 520 float(string_to_check) |
| 536 return True | 521 return True |
| 537 except ValueError: | 522 except ValueError: |
| 538 return False | 523 return False |
| 539 | 524 |
| 540 | 525 |
| 541 def IsWindowsHost(): | 526 def IsWindowsHost(): |
| 542 """Checks whether or not the script is running on Windows. | |
| 543 | |
| 544 Returns: | |
| 545 True if running on Windows. | |
| 546 """ | |
| 547 return sys.platform == 'cygwin' or sys.platform.startswith('win') | 527 return sys.platform == 'cygwin' or sys.platform.startswith('win') |
| 548 | 528 |
| 549 | 529 |
| 550 def Is64BitWindows(): | 530 def Is64BitWindows(): |
| 551 """Returns whether or not Windows is a 64-bit version. | 531 """Checks whether or not Windows is a 64-bit version.""" |
| 552 | 532 platform = os.environ.get('PROCESSOR_ARCHITEW6432') |
| 553 Returns: | 533 if not platform: |
| 554 True if Windows is 64-bit, False if 32-bit. | 534 # Must not be running in WoW64, so PROCESSOR_ARCHITECTURE is correct. |
| 555 """ | 535 platform = os.environ.get('PROCESSOR_ARCHITECTURE') |
| 556 platform = os.environ['PROCESSOR_ARCHITECTURE'] | 536 return platform and platform in ['AMD64', 'I64'] |
| 557 try: | |
| 558 platform = os.environ['PROCESSOR_ARCHITEW6432'] | |
| 559 except KeyError: | |
| 560 # Must not be running in WoW64, so PROCESSOR_ARCHITECTURE is correct | |
| 561 pass | |
| 562 | |
| 563 return platform in ['AMD64', 'I64'] | |
| 564 | 537 |
| 565 | 538 |
| 566 def IsLinuxHost(): | 539 def IsLinuxHost(): |
| 567 """Checks whether or not the script is running on Linux. | |
| 568 | |
| 569 Returns: | |
| 570 True if running on Linux. | |
| 571 """ | |
| 572 return sys.platform.startswith('linux') | 540 return sys.platform.startswith('linux') |
| 573 | 541 |
| 574 | 542 |
| 575 def IsMacHost(): | 543 def IsMacHost(): |
| 576 """Checks whether or not the script is running on Mac. | |
| 577 | |
| 578 Returns: | |
| 579 True if running on Mac. | |
| 580 """ | |
| 581 return sys.platform.startswith('darwin') | 544 return sys.platform.startswith('darwin') |
| OLD | NEW |