| 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 25 matching lines...) Expand all Loading... |
| 36 result.add_argument("--directory", help="observatory root", default=None) | 36 result.add_argument("--directory", help="observatory root", default=None) |
| 37 result.add_argument("--command", help="[get, build, deploy]", default=None) | 37 result.add_argument("--command", help="[get, build, deploy]", default=None) |
| 38 result.add_argument("--silent", help="silence all output", default=False) | 38 result.add_argument("--silent", help="silence all output", default=False) |
| 39 result.add_argument("--sdk", help="Use prebuilt sdk", default=False) | 39 result.add_argument("--sdk", help="Use prebuilt sdk", default=False) |
| 40 return result | 40 return result |
| 41 | 41 |
| 42 def ProcessOptions(options, args): | 42 def ProcessOptions(options, args): |
| 43 # Required options. | 43 # Required options. |
| 44 if (options.command == None) or (options.directory == None): | 44 if (options.command == None) or (options.directory == None): |
| 45 return False | 45 return False |
| 46 # If we have a pub executable, we are running from the dart-sdk. | |
| 47 if (options.pub_executable != None): | |
| 48 return True | |
| 49 if (options.sdk != None): | 46 if (options.sdk != None): |
| 50 # Use the checked in pub executable by default. | 47 # Use the checked in pub executable by default. |
| 51 options.pub_executable = utils.CheckedInPubPath() | 48 options.pub_executable = utils.CheckedInPubPath() |
| 52 return True | 49 # If we have a working pub executable, we are running from the dart-sdk. |
| 53 # Otherwise, we need a dart executable and a package root. | 50 if (options.pub_executable != None): |
| 51 try: |
| 52 if utils.CheckedInSdkFixExecutable() and 0 == subprocess.call( |
| 53 [options.pub_executable, '--version']): |
| 54 return True |
| 55 except OSError as e: |
| 56 pass |
| 57 # The pub executable didn't work, use the backup procedure. |
| 58 options.pub_executable = None |
| 59 # We need a dart executable and a package root. |
| 54 return ((options.package_root != None) and | 60 return ((options.package_root != None) and |
| 55 (options.dart_executable != None)) | 61 (options.dart_executable != None)) |
| 56 | 62 |
| 57 def ChangeDirectory(directory): | 63 def ChangeDirectory(directory): |
| 58 os.chdir(directory); | 64 os.chdir(directory); |
| 59 | 65 |
| 60 def PubGet(dart_executable, pub_executable, pkg_root, silent): | 66 def PubGet(dart_executable, pub_executable, pkg_root, silent): |
| 61 # Always remove pubspec.lock before running 'pub get'. | 67 # Always remove pubspec.lock before running 'pub get'. |
| 62 try: | 68 try: |
| 63 os.remove('pubspec.lock'); | 69 os.remove('pubspec.lock'); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 options.dart_executable = os.path.abspath(options.dart_executable) | 157 options.dart_executable = os.path.abspath(options.dart_executable) |
| 152 if (options.pub_executable != None): | 158 if (options.pub_executable != None): |
| 153 options.pub_executable = os.path.abspath(options.pub_executable) | 159 options.pub_executable = os.path.abspath(options.pub_executable) |
| 154 if len(args) == 1: | 160 if len(args) == 1: |
| 155 args[0] = os.path.abspath(args[0]) | 161 args[0] = os.path.abspath(args[0]) |
| 156 # Pub must be run from the project's root directory. | 162 # Pub must be run from the project's root directory. |
| 157 ChangeDirectory(options.directory) | 163 ChangeDirectory(options.directory) |
| 158 return ExecuteCommand(options, args) | 164 return ExecuteCommand(options, args) |
| 159 | 165 |
| 160 if __name__ == '__main__': | 166 if __name__ == '__main__': |
| 161 sys.exit(main()); | 167 sys.exit(main()); |
| OLD | NEW |