| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 4 # for details. All rights reserved. Use of this source code is governed by a | 4 # for details. All rights reserved. Use of this source code is governed by a |
| 5 # BSD-style license that can be found in the LICENSE file. | 5 # BSD-style license that can be found in the LICENSE file. |
| 6 | 6 |
| 7 import glob | 7 import glob |
| 8 import gsutil | 8 import gsutil |
| 9 import imp | 9 import imp |
| 10 import optparse | 10 import optparse |
| 11 import os | 11 import os |
| 12 import re | 12 import re |
| 13 import shutil | 13 import shutil |
| 14 import stat | 14 import stat |
| 15 import subprocess | 15 import subprocess |
| 16 import sys | 16 import sys |
| 17 import tempfile | 17 import tempfile |
| 18 import zipfile | 18 import zipfile |
| 19 import ziputils | 19 import ziputils |
| 20 | 20 |
| 21 from os.path import join | 21 from os.path import join |
| 22 | 22 |
| 23 BUILD_OS = None | 23 BUILD_OS = None |
| 24 DART_PATH = None | 24 DART_PATH = None |
| 25 TOOLS_PATH = None | 25 TOOLS_PATH = None |
| 26 | 26 |
| 27 GSU_API_DOCS_PATH = None | |
| 28 GSU_API_DOCS_BUCKET = 'gs://dartlang-api-docs' | |
| 29 | |
| 30 CHANNEL = None | 27 CHANNEL = None |
| 31 PLUGINS_BUILD = None | 28 PLUGINS_BUILD = None |
| 32 REVISION = None | 29 REVISION = None |
| 33 SYSTEM = None | 30 SYSTEM = None |
| 34 | 31 |
| 35 NO_UPLOAD = None | 32 NO_UPLOAD = None |
| 36 | 33 |
| 37 DART_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..')) | 34 DART_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..')) |
| 38 utils = imp.load_source('utils', os.path.join(DART_DIR, 'tools', 'utils.py')) | 35 utils = imp.load_source('utils', os.path.join(DART_DIR, 'tools', 'utils.py')) |
| 39 bot_utils = imp.load_source('bot_utils', | 36 bot_utils = imp.load_source('bot_utils', |
| (...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 def CreateZipWindows(directory, targetFile): | 1178 def CreateZipWindows(directory, targetFile): |
| 1182 """zip the given directory into the file - win32 specific""" | 1179 """zip the given directory into the file - win32 specific""" |
| 1183 EnsureDirectoryExists(targetFile) | 1180 EnsureDirectoryExists(targetFile) |
| 1184 FileDelete(targetFile) | 1181 FileDelete(targetFile) |
| 1185 ExecuteCommand([join(DART_PATH, 'third_party', '7zip', '7za'), 'a', '-tzip', | 1182 ExecuteCommand([join(DART_PATH, 'third_party', '7zip', '7za'), 'a', '-tzip', |
| 1186 targetFile, | 1183 targetFile, |
| 1187 os.path.basename(directory)], | 1184 os.path.basename(directory)], |
| 1188 os.path.dirname(directory)) | 1185 os.path.dirname(directory)) |
| 1189 | 1186 |
| 1190 | 1187 |
| 1191 def UploadDirectory(filesToUpload, gs_dir): | 1188 def UploadApiDocs(dirName): |
| 1192 Gsutil(['-m', 'cp', '-a', 'public-read', '-r'] + filesToUpload + [gs_dir]) | 1189 apidocs_namer = bot_utils.GCSNamerApiDocs(CHANNEL) |
| 1190 apidocs_destination_gcsdir = apidocs_namer.docs_dirpath(REVISION) |
| 1191 apidocs_destination_latestfile = apidocs_namer.docs_latestpath(REVISION) |
| 1193 | 1192 |
| 1193 # Delete the old revision specific apidocs directory if present. |
| 1194 Gsutil(['-m', 'rm', '-R', '-f', apidocs_destination_gcsdir]) |
| 1194 | 1195 |
| 1195 def UploadApiDocs(dirName): | 1196 # Upload everything inside the built apidocs directory. |
| 1196 # create file in dartlang-api-docs/REVISION/index.html | 1197 Gsutil(['-m', 'cp', '-R', '-a', 'public-read', dirName, |
| 1197 # this lets us do the recursive copy in the next step | 1198 apidocs_destination_gcsdir]) |
| 1198 | 1199 |
| 1199 localIndexFile = join(dirName, 'index.html') | 1200 # Update latest.txt to contain the newest revision. |
| 1200 destIndexFile = GSU_API_DOCS_PATH + '/index.html' | 1201 with utils.TempDir('latest_file') as temp_dir: |
| 1202 latest_file = join(temp_dir, 'latest.txt') |
| 1203 with open(latest_file, 'w') as f: |
| 1204 f.write('%s' % REVISION) |
| 1201 | 1205 |
| 1202 Gsutil(['cp', '-a', 'public-read', localIndexFile, destIndexFile]) | 1206 Gsutil(['cp', '-a', 'public-read', latest_file, |
| 1203 | 1207 apidocs_destination_latestfile]) |
| 1204 # copy -R api_docs into dartlang-api-docs/REVISION | |
| 1205 filesToUpload = glob.glob(join(dirName, '*')) | |
| 1206 Gsutil(['-m', 'cp', '-q', '-a', 'public-read', '-r'] + | |
| 1207 filesToUpload + [GSU_API_DOCS_PATH]) | |
| 1208 | |
| 1209 destLatestRevFile = GSU_API_DOCS_BUCKET + '/latest.txt' | |
| 1210 localLatestRevFilename = join(dirName, 'latest.txt') | |
| 1211 with open(localLatestRevFilename, 'w+') as f: | |
| 1212 f.write(REVISION) | |
| 1213 | |
| 1214 # overwrite dartlang-api-docs/latest.txt to contain REVISION | |
| 1215 Gsutil(['cp', '-a', 'public-read', localLatestRevFilename, | |
| 1216 destLatestRevFile]) | |
| 1217 | 1208 |
| 1218 | 1209 |
| 1219 def Gsutil(cmd): | 1210 def Gsutil(cmd): |
| 1220 gsutilTool = join(DART_PATH, 'third_party', 'gsutil', 'gsutil') | 1211 gsutilTool = join(DART_PATH, 'third_party', 'gsutil', 'gsutil') |
| 1221 ExecuteCommand([sys.executable, gsutilTool] + cmd) | 1212 ExecuteCommand([sys.executable, gsutilTool] + cmd) |
| 1222 | 1213 |
| 1223 | 1214 |
| 1224 def EnsureDirectoryExists(f): | 1215 def EnsureDirectoryExists(f): |
| 1225 d = os.path.dirname(f) | 1216 d = os.path.dirname(f) |
| 1226 if not os.path.exists(d): | 1217 if not os.path.exists(d): |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1241 """delete the given file - do not re-throw any exceptions that occur""" | 1232 """delete the given file - do not re-throw any exceptions that occur""" |
| 1242 if os.path.exists(f): | 1233 if os.path.exists(f): |
| 1243 try: | 1234 try: |
| 1244 os.remove(f) | 1235 os.remove(f) |
| 1245 except OSError: | 1236 except OSError: |
| 1246 print 'error deleting %s' % f | 1237 print 'error deleting %s' % f |
| 1247 | 1238 |
| 1248 | 1239 |
| 1249 if __name__ == '__main__': | 1240 if __name__ == '__main__': |
| 1250 sys.exit(main()) | 1241 sys.exit(main()) |
| OLD | NEW |