| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Steps to archive dartium, content_shell, and chromedriver from buildbots. | 7 """Steps to archive dartium, content_shell, and chromedriver from buildbots. |
| 8 | 8 |
| 9 Imported by buildbot_annotated_steps.py and multivm_archive.py | 9 Imported by buildbot_annotated_steps.py and multivm_archive.py |
| 10 """ | 10 """ |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 return status | 190 return status |
| 191 print 'Uploaded: ' + output | 191 print 'Uploaded: ' + output |
| 192 | 192 |
| 193 # Set ACL. | 193 # Set ACL. |
| 194 if ACL is not None: | 194 if ACL is not None: |
| 195 cmd = [GSUTIL, 'setacl', ACL, target] | 195 cmd = [GSUTIL, 'setacl', ACL, target] |
| 196 (status, output) = ExecuteCommand(cmd) | 196 (status, output) = ExecuteCommand(cmd) |
| 197 return status | 197 return status |
| 198 | 198 |
| 199 | 199 |
| 200 def UploadFile(local_path, remote_path, create_md5sum=False): | 200 def UploadFile(local_path, remote_path, checksum_files=False): |
| 201 # Copy it to the new unified gs://dart-archive bucket | 201 # Copy it to the new unified gs://dart-archive bucket |
| 202 gsutil = bot_utils.GSUtil() | 202 gsutil = bot_utils.GSUtil() |
| 203 gsutil.upload(local_path, remote_path, public=True) | 203 gsutil.upload(local_path, remote_path, public=True) |
| 204 if create_md5sum: | 204 if checksum_files: |
| 205 # 'local_path' may have a different filename than 'remote_path'. So we need | 205 # 'local_path' may have a different filename than 'remote_path'. So we need |
| 206 # to make sure the *.md5sum file contains the correct name. | 206 # to make sure the *.md5sum file contains the correct name. |
| 207 assert '/' in remote_path and not remote_path.endswith('/') | 207 assert '/' in remote_path and not remote_path.endswith('/') |
| 208 mangled_filename = remote_path[remote_path.rfind('/') + 1:] | 208 mangled_filename = remote_path[remote_path.rfind('/') + 1:] |
| 209 local_md5sum = bot_utils.CreateChecksumFile(local_path, mangled_filename) | 209 local_md5sum = bot_utils.CreateMD5ChecksumFile(local_path, |
| 210 mangled_filename) |
| 210 gsutil.upload(local_md5sum, remote_path + '.md5sum', public=True) | 211 gsutil.upload(local_md5sum, remote_path + '.md5sum', public=True) |
| 211 | 212 local_sha256 = bot_utils.CreateSha256ChecksumFile(local_path, |
| 213 mangled_filename) |
| 214 gsutil.upload(local_sha256, remote_path + '.sha256sum', public=True) |
| 212 | 215 |
| 213 def ExecuteCommand(cmd): | 216 def ExecuteCommand(cmd): |
| 214 """Execute a command in a subprocess. | 217 """Execute a command in a subprocess. |
| 215 """ | 218 """ |
| 216 print 'Executing: ' + ' '.join(cmd) | 219 print 'Executing: ' + ' '.join(cmd) |
| 217 try: | 220 try: |
| 218 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 221 pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 219 (output, error) = pipe.communicate() | 222 (output, error) = pipe.communicate() |
| 220 if pipe.returncode != 0: | 223 if pipe.returncode != 0: |
| 221 print 'Execution failed: ' + str(error) | 224 print 'Execution failed: ' + str(error) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 def RemoveArchives(archives): | 267 def RemoveArchives(archives): |
| 265 """Remove the list of archives in Google storage. | 268 """Remove the list of archives in Google storage. |
| 266 """ | 269 """ |
| 267 for archive in archives: | 270 for archive in archives: |
| 268 if archive.find(GS_SITE) == 0: | 271 if archive.find(GS_SITE) == 0: |
| 269 cmd = [GSUTIL, 'rm', archive.rstrip()] | 272 cmd = [GSUTIL, 'rm', archive.rstrip()] |
| 270 (status, _) = ExecuteCommand(cmd) | 273 (status, _) = ExecuteCommand(cmd) |
| 271 if status != 0: | 274 if status != 0: |
| 272 return status | 275 return status |
| 273 return 0 | 276 return 0 |
| OLD | NEW |