| 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_aliases_string = ', '.join(cloud_storage.BUCKET_ALIASES) |
| 86 'Is this file [P]ublic or Google-[i]nternal?' | 86 bucket_input = raw_input( |
| 87 % file_path).lower() | 87 'Uploading to Cloud Storage: %s\n' |
| 88 if 'public'.startswith(bucket_input): | 88 'Which bucket should this go in? (%s) ' |
| 89 bucket = cloud_storage.PUBLIC_BUCKET | 89 % (file_path, bucket_aliases_string)).lower() |
| 90 elif ('internal'.startswith(bucket_input) or | 90 bucket = cloud_storage.BUCKET_ALIASES.get(bucket_input, None) |
| 91 'google-internal'.startswith(bucket_input)): | 91 if not bucket: |
| 92 bucket = cloud_storage.INTERNAL_BUCKET | |
| 93 else: | |
| 94 results.append(output_api.PresubmitError( | 92 results.append(output_api.PresubmitError( |
| 95 'Response was neither "public" nor "internal": %s' % bucket_input)) | 93 '"%s" was not one of %s' % (bucket_input, bucket_aliases_string))) |
| 96 return results | 94 return results |
| 97 | 95 |
| 98 cloud_storage.Insert(bucket, file_hash, file_path) | 96 cloud_storage.Insert(bucket, file_hash, file_path) |
| 99 results.append(output_api.PresubmitNotifyResult( | 97 results.append(output_api.PresubmitNotifyResult( |
| 100 'Uploaded file to Cloud Storage: %s' % file_path)) | 98 'Uploaded file to Cloud Storage: %s' % file_path)) |
| 101 except cloud_storage.CloudStorageError, e: | 99 except cloud_storage.CloudStorageError, e: |
| 102 results.append(output_api.PresubmitError( | 100 results.append(output_api.PresubmitError( |
| 103 'Unable to upload to Cloud Storage: %s\n\n%s' % (file_path, e))) | 101 'Unable to upload to Cloud Storage: %s\n\n%s' % (file_path, e))) |
| 104 | 102 |
| 105 return results | 103 return results |
| (...skipping 22 matching lines...) Expand all Loading... |
| 128 return input_api.AffectedFiles(file_filter=_IsNewJsonPageSet) | 126 return input_api.AffectedFiles(file_filter=_IsNewJsonPageSet) |
| 129 | 127 |
| 130 def CheckChangeOnUpload(input_api, output_api): | 128 def CheckChangeOnUpload(input_api, output_api): |
| 131 results = _SyncFilesToCloud(input_api, output_api) | 129 results = _SyncFilesToCloud(input_api, output_api) |
| 132 return results | 130 return results |
| 133 | 131 |
| 134 | 132 |
| 135 def CheckChangeOnCommit(input_api, output_api): | 133 def CheckChangeOnCommit(input_api, output_api): |
| 136 results = _VerifyFilesInCloud(input_api, output_api) | 134 results = _VerifyFilesInCloud(input_api, output_api) |
| 137 return results | 135 return results |
| OLD | NEW |