Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | 5 import os |
| 6 import re | 6 import re |
| 7 import sys | 7 import sys |
| 8 | 8 |
| 9 | 9 |
| 10 def LoadSupport(input_api): | 10 def LoadSupport(input_api): |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 if not os.path.exists(file_path): | 75 if not os.path.exists(file_path): |
| 76 results.append(output_api.PresubmitError( | 76 results.append(output_api.PresubmitError( |
| 77 'Hash file exists, but file not found: %s' % hash_path)) | 77 'Hash file exists, but file not found: %s' % hash_path)) |
| 78 continue | 78 continue |
| 79 if cloud_storage.CalculateHash(file_path) != file_hash: | 79 if cloud_storage.CalculateHash(file_path) != file_hash: |
| 80 results.append(output_api.PresubmitError( | 80 results.append(output_api.PresubmitError( |
| 81 'Hash file does not match file\'s actual hash: %s' % hash_path)) | 81 'Hash file does not match file\'s actual hash: %s' % hash_path)) |
| 82 continue | 82 continue |
| 83 | 83 |
| 84 try: | 84 try: |
| 85 bucket_input = raw_input('Uploading to Cloud Storage: %s\n' | 85 bucket_input = raw_input( |
|
tonyg
2014/09/10 00:15:01
Just a thought, but it looks like we could auto-ge
dtu
2014/09/12 02:39:15
Done.
| |
| 86 'Is this file [P]ublic or Google-[i]nternal?' | 86 'Uploading to Cloud Storage: %s\n' |
| 87 % file_path).lower() | 87 'Which bucket should this go in? (public, partner, internal) ' |
| 88 if 'public'.startswith(bucket_input): | 88 % file_path).lower() |
| 89 if bucket_input == 'public': | |
| 89 bucket = cloud_storage.PUBLIC_BUCKET | 90 bucket = cloud_storage.PUBLIC_BUCKET |
| 90 elif ('internal'.startswith(bucket_input) or | 91 elif bucket_input == 'partner': |
| 91 'google-internal'.startswith(bucket_input)): | 92 bucket = cloud_storage.PARTNER_BUCKET |
| 93 elif bucket_input == 'internal': | |
| 92 bucket = cloud_storage.INTERNAL_BUCKET | 94 bucket = cloud_storage.INTERNAL_BUCKET |
| 93 else: | 95 else: |
| 94 results.append(output_api.PresubmitError( | 96 results.append(output_api.PresubmitError( |
| 95 'Response was neither "public" nor "internal": %s' % bucket_input)) | 97 '"%s" was not "public," "partner," or "internal"' % bucket_input)) |
| 96 return results | 98 return results |
| 97 | 99 |
| 98 cloud_storage.Insert(bucket, file_hash, file_path) | 100 cloud_storage.Insert(bucket, file_hash, file_path) |
| 99 results.append(output_api.PresubmitNotifyResult( | 101 results.append(output_api.PresubmitNotifyResult( |
| 100 'Uploaded file to Cloud Storage: %s' % file_path)) | 102 'Uploaded file to Cloud Storage: %s' % file_path)) |
| 101 except cloud_storage.CloudStorageError, e: | 103 except cloud_storage.CloudStorageError, e: |
| 102 results.append(output_api.PresubmitError( | 104 results.append(output_api.PresubmitError( |
| 103 'Unable to upload to Cloud Storage: %s\n\n%s' % (file_path, e))) | 105 'Unable to upload to Cloud Storage: %s\n\n%s' % (file_path, e))) |
| 104 | 106 |
| 105 return results | 107 return results |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 128 return input_api.AffectedFiles(file_filter=_IsNewJsonPageSet) | 130 return input_api.AffectedFiles(file_filter=_IsNewJsonPageSet) |
| 129 | 131 |
| 130 def CheckChangeOnUpload(input_api, output_api): | 132 def CheckChangeOnUpload(input_api, output_api): |
| 131 results = _SyncFilesToCloud(input_api, output_api) | 133 results = _SyncFilesToCloud(input_api, output_api) |
| 132 return results | 134 return results |
| 133 | 135 |
| 134 | 136 |
| 135 def CheckChangeOnCommit(input_api, output_api): | 137 def CheckChangeOnCommit(input_api, output_api): |
| 136 results = _VerifyFilesInCloud(input_api, output_api) | 138 results = _VerifyFilesInCloud(input_api, output_api) |
| 137 return results | 139 return results |
| OLD | NEW |