| 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 shutil | 9 import shutil |
| 10 import subprocess | 10 import subprocess |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 '--dart-executable=' + dart_executable, | 89 '--dart-executable=' + dart_executable, |
| 90 'build', | 90 'build', |
| 91 '--output', | 91 '--output', |
| 92 output_dir], | 92 output_dir], |
| 93 stdout=silent_sink if silent else None, | 93 stdout=silent_sink if silent else None, |
| 94 stderr=silent_sink if silent else None,) | 94 stderr=silent_sink if silent else None,) |
| 95 | 95 |
| 96 def Deploy(input_dir, output_dir): | 96 def Deploy(input_dir, output_dir): |
| 97 shutil.rmtree(output_dir) | 97 shutil.rmtree(output_dir) |
| 98 shutil.copytree(input_dir, output_dir, ignore=IGNORE_PATTERNS) | 98 shutil.copytree(input_dir, output_dir, ignore=IGNORE_PATTERNS) |
| 99 index_file = os.path.join(output_dir, 'web', 'index.html') |
| 100 os.utime(index_file, None) |
| 99 return 0 | 101 return 0 |
| 100 | 102 |
| 101 def RewritePubSpec(input_path, output_path, search, replace): | 103 def RewritePubSpec(input_path, output_path, search, replace): |
| 102 with open(input_path, 'rb') as input_file: | 104 with open(input_path, 'rb') as input_file: |
| 103 input_data = input_file.read() | 105 input_data = input_file.read() |
| 104 input_data = input_data.replace(search, replace) | 106 input_data = input_data.replace(search, replace) |
| 105 with open(output_path, 'wb+') as output_file: | 107 with open(output_path, 'wb+') as output_file: |
| 106 output_file.write(input_data) | 108 output_file.write(input_data) |
| 107 | 109 |
| 108 def ExecuteCommand(options, args): | 110 def ExecuteCommand(options, args): |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 if (options.pub_executable != None): | 145 if (options.pub_executable != None): |
| 144 options.pub_executable = os.path.abspath(options.pub_executable) | 146 options.pub_executable = os.path.abspath(options.pub_executable) |
| 145 if len(args) == 1: | 147 if len(args) == 1: |
| 146 args[0] = os.path.abspath(args[0]) | 148 args[0] = os.path.abspath(args[0]) |
| 147 # Pub must be run from the project's root directory. | 149 # Pub must be run from the project's root directory. |
| 148 ChangeDirectory(options.directory) | 150 ChangeDirectory(options.directory) |
| 149 return ExecuteCommand(options, args) | 151 return ExecuteCommand(options, args) |
| 150 | 152 |
| 151 if __name__ == '__main__': | 153 if __name__ == '__main__': |
| 152 sys.exit(main()); | 154 sys.exit(main()); |
| OLD | NEW |