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

Side by Side Diff: tools/observatory_tool.py

Issue 2738983002: Sanity check that 'localhost' can be resolved before building Observatory (Closed)
Patch Set: 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
11 import socket
11 import subprocess 12 import subprocess
12 import sys 13 import sys
13 import utils 14 import utils
14 15
15 SCRIPT_DIR = os.path.dirname(sys.argv[0]) 16 SCRIPT_DIR = os.path.dirname(sys.argv[0])
16 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..')) 17 DART_ROOT = os.path.realpath(os.path.join(SCRIPT_DIR, '..'))
17 PUB_PATH = os.path.join(DART_ROOT, 'third_party', 'pkg', 18 PUB_PATH = os.path.join(DART_ROOT, 'third_party', 'pkg',
18 'pub', 'bin', 'pub.dart') 19 'pub', 'bin', 'pub.dart')
19 IGNORE_PATTERNS = shutil.ignore_patterns( 20 IGNORE_PATTERNS = shutil.ignore_patterns(
20 '*.map', 21 '*.map',
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 options.silent) 211 options.silent)
211 elif (cmd == 'deploy'): 212 elif (cmd == 'deploy'):
212 Deploy('build', 'deployed') 213 Deploy('build', 'deployed')
213 elif (cmd == 'rewrite'): 214 elif (cmd == 'rewrite'):
214 RewritePubSpec(args[0], args[1], args[2], args[3]) 215 RewritePubSpec(args[0], args[1], args[2], args[3])
215 else: 216 else:
216 print >> sys.stderr, ('ERROR: command "%s" not supported') % (cmd) 217 print >> sys.stderr, ('ERROR: command "%s" not supported') % (cmd)
217 return -1; 218 return -1;
218 219
219 def main(): 220 def main():
221 # Sanity check that localhost can be resolved.
222 try:
223 socket.gethostbyname('localhost')
224 except:
225 print("The hostname 'localhost' could not be resolved. Please fix your"
226 "/etc/hosts file and try again")
227 return -1
220 # Parse the options. 228 # Parse the options.
221 parser = BuildArguments() 229 parser = BuildArguments()
222 (options, args) = parser.parse_known_args() 230 (options, args) = parser.parse_known_args()
223 if not ProcessOptions(options, args): 231 if not ProcessOptions(options, args):
224 parser.print_help() 232 parser.print_help()
225 return 1 233 return 1
226 # Calculate absolute paths before changing directory. 234 # Calculate absolute paths before changing directory.
227 if (options.dart_executable != None): 235 if (options.dart_executable != None):
228 options.dart_executable = os.path.abspath(options.dart_executable) 236 options.dart_executable = os.path.abspath(options.dart_executable)
229 if (options.pub_executable != None): 237 if (options.pub_executable != None):
230 options.pub_executable = os.path.abspath(options.pub_executable) 238 options.pub_executable = os.path.abspath(options.pub_executable)
231 if (options.pub_snapshot != None): 239 if (options.pub_snapshot != None):
232 options.pub_snapshot = os.path.abspath(options.pub_snapshot) 240 options.pub_snapshot = os.path.abspath(options.pub_snapshot)
233 if (options.stamp != ''): 241 if (options.stamp != ''):
234 options.stamp = os.path.abspath(options.stamp) 242 options.stamp = os.path.abspath(options.stamp)
235 if len(args) == 1: 243 if len(args) == 1:
236 args[0] = os.path.abspath(args[0]) 244 args[0] = os.path.abspath(args[0])
237 # Pub must be run from the project's root directory. 245 # Pub must be run from the project's root directory.
238 ChangeDirectory(options.directory) 246 ChangeDirectory(options.directory)
239 result = ExecuteCommand(options, args) 247 result = ExecuteCommand(options, args)
240 if result == 0: 248 if result == 0:
241 CreateTimestampFile(options) 249 CreateTimestampFile(options)
242 return result 250 return result
243 251
244 252
245 if __name__ == '__main__': 253 if __name__ == '__main__':
246 sys.exit(main()); 254 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