Chromium Code Reviews| Index: tools/observatory_tool.py |
| diff --git a/tools/observatory_tool.py b/tools/observatory_tool.py |
| index 68fcd86d9f2537b97f3959c7048e05b8baf0c807..5b1c7c58d6f56f6bf24e5f7e5f9673e7dc10f8f0 100755 |
| --- a/tools/observatory_tool.py |
| +++ b/tools/observatory_tool.py |
| @@ -41,41 +41,46 @@ def BuildArguments(): |
| return result |
| def ProcessOptions(options, args): |
| - # Required options. |
| - if options.command is None or options.directory is None: |
| - return False |
| - |
| - # Set a default value for pub_snapshot. |
| - options.pub_snapshot = None |
| - |
| - # If we have a working pub executable, try and use that. |
| - # TODO(whesse): Drop the pub-executable option if it isn't used. |
| - if options.pub_executable is not None: |
| - try: |
| - if 0 == subprocess.call([options.pub_executable, '--version']): |
| - return True |
| - except OSError as e: |
| - pass |
| - options.pub_executable = None |
| - |
| - if options.sdk is not None and utils.CheckedInSdkCheckExecutable(): |
| - # Use the checked in pub executable. |
| - options.pub_snapshot = os.path.join(utils.CheckedInSdkPath(), |
| - 'bin', |
| - 'snapshots', |
| - 'pub.dart.snapshot'); |
| - try: |
| - if 0 == subprocess.call([utils.CheckedInSdkExecutable(), |
| - options.pub_snapshot, |
| - '--version']): |
| - return True |
| - except OSError as e: |
| - pass |
| - options.pub_snapshot = None |
| - |
| - # We need a dart executable and a package root. |
| - return (options.package_root is not None and |
| - options.dart_executable is not None) |
| + with open(os.devnull, 'wb') as silent_sink: |
| + # Required options. |
| + if options.command is None or options.directory is None: |
| + return False |
| + |
| + # Set a default value for pub_snapshot. |
| + options.pub_snapshot = None |
| + |
| + # If we have a working pub executable, try and use that. |
| + # TODO(whesse): Drop the pub-executable option if it isn't used. |
| + if options.pub_executable is not None: |
| + try: |
| + if 0 == subprocess.call([options.pub_executable, '--version'], |
| + stdout=silent_sink, |
| + stderr=silent_sink): |
| + return True |
| + except OSError as e: |
| + pass |
| + options.pub_executable = None |
| + |
| + if options.sdk is not None and utils.CheckedInSdkCheckExecutable(): |
| + # Use the checked in pub executable. |
| + options.pub_snapshot = os.path.join(utils.CheckedInSdkPath(), |
| + 'bin', |
| + 'snapshots', |
| + 'pub.dart.snapshot'); |
| + try: |
| + if 0 == subprocess.call([utils.CheckedInSdkExecutable(), |
| + options.pub_snapshot, |
| + '--version'], |
| + stdout=silent_sink, |
| + stderr=silent_sink): |
| + return True |
| + except OSError as e: |
| + pass |
| + options.pub_snapshot = None |
| + |
| + # We need a dart executable and a package root. |
| + return (options.package_root is not None and |
| + options.dart_executable is not None) |
|
Bob Nystrom
2015/09/29 16:06:57
Drive-by! Instead of making an explicit null sink,
|
| def ChangeDirectory(directory): |
| os.chdir(directory); |