| OLD | NEW |
| 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 11 matching lines...) Expand all Loading... |
| 22 '*.scriptUrls', | 22 '*.scriptUrls', |
| 23 '*.precompiled.js', | 23 '*.precompiled.js', |
| 24 'main.*', | 24 'main.*', |
| 25 'unittest*', | 25 'unittest*', |
| 26 '*_buildLogs*', | 26 '*_buildLogs*', |
| 27 '*.log', | 27 '*.log', |
| 28 '*~') | 28 '*~') |
| 29 | 29 |
| 30 usage = """observatory_tool.py [options]""" | 30 usage = """observatory_tool.py [options]""" |
| 31 | 31 |
| 32 def CreateTimestampFile(options): |
| 33 if options.stamp != '': |
| 34 dir_name = os.path.dirname(options.stamp) |
| 35 if dir_name != '': |
| 36 if not os.path.exists(dir_name): |
| 37 os.mkdir(dir_name) |
| 38 open(options.stamp, 'w').close() |
| 39 |
| 32 def BuildArguments(): | 40 def BuildArguments(): |
| 33 result = argparse.ArgumentParser(usage=usage) | 41 result = argparse.ArgumentParser(usage=usage) |
| 34 result.add_argument("--package-root", help="package root", default=None) | 42 result.add_argument("--package-root", help="package root", default=None) |
| 35 result.add_argument("--dart-executable", help="dart executable", default=None) | 43 result.add_argument("--dart-executable", help="dart executable", default=None) |
| 36 result.add_argument("--pub-executable", help="pub executable", default=None) | 44 result.add_argument("--pub-executable", help="pub executable", default=None) |
| 37 result.add_argument("--directory", help="observatory root", default=None) | 45 result.add_argument("--directory", help="observatory root", default=None) |
| 38 result.add_argument("--command", help="[get, build, deploy]", default=None) | 46 result.add_argument("--command", help="[get, build, deploy]", default=None) |
| 39 result.add_argument("--silent", help="silence all output", default=None) | 47 result.add_argument("--silent", help="silence all output", default=None) |
| 40 result.add_argument("--sdk", help="Use prebuilt sdk", default=None) | 48 result.add_argument("--sdk", help="Use prebuilt sdk", default=None) |
| 49 result.add_argument("--stamp", help="Write a stamp file", default='') |
| 41 return result | 50 return result |
| 42 | 51 |
| 43 def ProcessOptions(options, args): | 52 def ProcessOptions(options, args): |
| 44 # Fix broken boolean parsing in argparse, where False ends up being True. | 53 # Fix broken boolean parsing in argparse, where False ends up being True. |
| 45 if (options.silent is not None) and (options.silent == "True"): | 54 if (options.silent is not None) and (options.silent == "True"): |
| 46 options.silent = True | 55 options.silent = True |
| 47 elif (options.silent is None) or (options.silent == "False"): | 56 elif (options.silent is None) or (options.silent == "False"): |
| 48 options.silent = False | 57 options.silent = False |
| 49 else: | 58 else: |
| 50 print "--silent expects 'True' or 'False' argument." | 59 print "--silent expects 'True' or 'False' argument." |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 if (options.dart_executable != None): | 207 if (options.dart_executable != None): |
| 199 options.dart_executable = os.path.abspath(options.dart_executable) | 208 options.dart_executable = os.path.abspath(options.dart_executable) |
| 200 if (options.pub_executable != None): | 209 if (options.pub_executable != None): |
| 201 options.pub_executable = os.path.abspath(options.pub_executable) | 210 options.pub_executable = os.path.abspath(options.pub_executable) |
| 202 if (options.pub_snapshot != None): | 211 if (options.pub_snapshot != None): |
| 203 options.pub_snapshot = os.path.abspath(options.pub_snapshot) | 212 options.pub_snapshot = os.path.abspath(options.pub_snapshot) |
| 204 if len(args) == 1: | 213 if len(args) == 1: |
| 205 args[0] = os.path.abspath(args[0]) | 214 args[0] = os.path.abspath(args[0]) |
| 206 # Pub must be run from the project's root directory. | 215 # Pub must be run from the project's root directory. |
| 207 ChangeDirectory(options.directory) | 216 ChangeDirectory(options.directory) |
| 208 return ExecuteCommand(options, args) | 217 result = ExecuteCommand(options, args) |
| 218 if result == 0: |
| 219 CreateTimestampFile(options) |
| 220 return result |
| 221 |
| 209 | 222 |
| 210 if __name__ == '__main__': | 223 if __name__ == '__main__': |
| 211 sys.exit(main()); | 224 sys.exit(main()); |
| OLD | NEW |