Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(727)

Side by Side Diff: tools/observatory_tool.py

Issue 2741803003: Print a helpful error message when observatory_tool.py encounters an error (Closed)
Patch Set: Undo latest change Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a 3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file. 4 # BSD-style license that can be found in the LICENSE file.
5 """Helper for building and deploying Observatory""" 5 """Helper for building and deploying Observatory"""
6 6
7 import argparse 7 import argparse
8 import os 8 import os
9 import platform 9 import platform
10 import shutil 10 import shutil
(...skipping 21 matching lines...) Expand all
32 'ShadowDOM.*', 32 'ShadowDOM.*',
33 'webcomponents.*', 33 'webcomponents.*',
34 'webcomponents-lite.js', 34 'webcomponents-lite.js',
35 'unittest*', 35 'unittest*',
36 '*_buildLogs*', 36 '*_buildLogs*',
37 '*.log', 37 '*.log',
38 '*~') 38 '*~')
39 39
40 usage = """observatory_tool.py [options]""" 40 usage = """observatory_tool.py [options]"""
41 41
42 def DisplayBootstrapWarning():
43 print """\
44
45 WARNING: Your system cannot run the checked-in Dart SDK. Using the
46 bootstrap Dart executable will make debug builds slow.
47 Please see the Wiki for instructions on replacing the checked-in Dart SDK.
48
49 https://github.com/dart-lang/sdk/wiki/The-checked-in-SDK-in-tools
50
51 To use the dart_bootstrap binary please update the PubCommand function
52 in the tools/observatory_tool.py script.
53
54 """
55
56 def DisplayFailureMessage():
57 print """\
58
59 ERROR: Observatory failed to build. What should you do?
60
61 1. Revert to a working revision of the Dart VM
62 2. Contact zra@, johnmccutchan@, dart-vm-team@
63 3. File a bug: https://github.com/dart-lang/sdk/issues/new
64
65 """
66
42 # Run |command|. If its return code is 0, return 0 and swallow its output. 67 # Run |command|. If its return code is 0, return 0 and swallow its output.
43 # If its return code is non-zero, emit its output unless |always_silent| is 68 # If its return code is non-zero, emit its output unless |always_silent| is
44 # True, and return the return code. 69 # True, and return the return code.
45 def RunCommand(command, always_silent=False): 70 def RunCommand(command, always_silent=False):
46 try: 71 try:
47 # Dart IO respects the following environment variables to configure the 72 # Dart IO respects the following environment variables to configure the
48 # HttpClient proxy: https://api.dartlang.org/stable/1.22.1/dart-io/HttpClien t/findProxyFromEnvironment.html 73 # HttpClient proxy: https://api.dartlang.org/stable/1.22.1/dart-io/HttpClien t/findProxyFromEnvironment.html
49 # We strip these to avoid problems with pub build and transformers. 74 # We strip these to avoid problems with pub build and transformers.
50 no_http_proxy_env = os.environ.copy() 75 no_http_proxy_env = os.environ.copy()
51 no_http_proxy_env.pop('http_proxy', None) 76 no_http_proxy_env.pop('http_proxy', None)
52 no_http_proxy_env.pop('HTTP_PROXY', None) 77 no_http_proxy_env.pop('HTTP_PROXY', None)
53 no_http_proxy_env.pop('https_proxy', None) 78 no_http_proxy_env.pop('https_proxy', None)
54 no_http_proxy_env.pop('HTTPS_PROXY', None) 79 no_http_proxy_env.pop('HTTPS_PROXY', None)
55 subprocess.check_output(command, 80 subprocess.check_output(command,
56 stderr=subprocess.STDOUT, 81 stderr=subprocess.STDOUT,
57 env=no_http_proxy_env) 82 env=no_http_proxy_env)
58 return 0 83 return 0
59 except subprocess.CalledProcessError as e: 84 except subprocess.CalledProcessError as e:
60 if not always_silent: 85 if not always_silent:
61 print ("Command failed: " + ' '.join(command) + "\n" + 86 print ("Command failed: " + ' '.join(command) + "\n" +
62 "output: " + e.output) 87 "output: " + e.output)
88 DisplayFailureMessage()
63 return e.returncode 89 return e.returncode
64 90
65 def CreateTimestampFile(options): 91 def CreateTimestampFile(options):
66 if options.stamp != '': 92 if options.stamp != '':
67 dir_name = os.path.dirname(options.stamp) 93 dir_name = os.path.dirname(options.stamp)
68 if dir_name != '': 94 if dir_name != '':
69 if not os.path.exists(dir_name): 95 if not os.path.exists(dir_name):
70 os.mkdir(dir_name) 96 os.mkdir(dir_name)
71 open(options.stamp, 'w').close() 97 open(options.stamp, 'w').close()
72 98
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 except OSError as e: 157 except OSError as e:
132 pass 158 pass
133 options.pub_snapshot = None 159 options.pub_snapshot = None
134 160
135 # We need a dart executable. 161 # We need a dart executable.
136 return (options.dart_executable is not None) 162 return (options.dart_executable is not None)
137 163
138 def ChangeDirectory(directory): 164 def ChangeDirectory(directory):
139 os.chdir(directory); 165 os.chdir(directory);
140 166
141 def DisplayBootstrapWarning():
142 print """\
143
144
145 WARNING: Your system cannot run the checked-in Dart SDK. Using the
146 bootstrap Dart executable will make debug builds slow.
147 Please see the Wiki for instructions on replacing the checked-in Dart SDK.
148
149 https://github.com/dart-lang/sdk/wiki/The-checked-in-SDK-in-tools
150
151 To use the dart_bootstrap binary please update the PubCommand function
152 in the tools/observatory_tool.py script.
153
154 """
155
156 def PubCommand(dart_executable, 167 def PubCommand(dart_executable,
157 pub_executable, 168 pub_executable,
158 pub_snapshot, 169 pub_snapshot,
159 command, 170 command,
160 silent): 171 silent):
161 if pub_executable is not None: 172 if pub_executable is not None:
162 executable = [pub_executable] 173 executable = [pub_executable]
163 elif pub_snapshot is not None: 174 elif pub_snapshot is not None:
164 executable = [utils.CheckedInSdkExecutable(), pub_snapshot] 175 executable = [utils.CheckedInSdkExecutable(), pub_snapshot]
165 else: 176 else:
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 if (options.dart_executable != None): 246 if (options.dart_executable != None):
236 options.dart_executable = os.path.abspath(options.dart_executable) 247 options.dart_executable = os.path.abspath(options.dart_executable)
237 if (options.pub_executable != None): 248 if (options.pub_executable != None):
238 options.pub_executable = os.path.abspath(options.pub_executable) 249 options.pub_executable = os.path.abspath(options.pub_executable)
239 if (options.pub_snapshot != None): 250 if (options.pub_snapshot != None):
240 options.pub_snapshot = os.path.abspath(options.pub_snapshot) 251 options.pub_snapshot = os.path.abspath(options.pub_snapshot)
241 if (options.stamp != ''): 252 if (options.stamp != ''):
242 options.stamp = os.path.abspath(options.stamp) 253 options.stamp = os.path.abspath(options.stamp)
243 if len(args) == 1: 254 if len(args) == 1:
244 args[0] = os.path.abspath(args[0]) 255 args[0] = os.path.abspath(args[0])
245 # Pub must be run from the project's root directory. 256 try:
246 ChangeDirectory(options.directory) 257 # Pub must be run from the project's root directory.
247 result = ExecuteCommand(options, args) 258 ChangeDirectory(options.directory)
248 if result == 0: 259 result = ExecuteCommand(options, args)
249 CreateTimestampFile(options) 260 if result == 0:
250 return result 261 CreateTimestampFile(options)
262 return result
263 except:
264 DisplayFailureMessage()
251 265
252 266
253 if __name__ == '__main__': 267 if __name__ == '__main__':
254 sys.exit(main()); 268 sys.exit(main());
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698