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 json | 5 import json |
| 6 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 import shutil | 9 import shutil |
| 10 import tempfile | 10 import tempfile |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 | 66 |
| 67 Raises cloud storage Permissions or Credentials error when there is no | 67 Raises cloud storage Permissions or Credentials error when there is no |
| 68 local copy of the archive and the user doesn't have permission to access | 68 local copy of the archive and the user doesn't have permission to access |
| 69 the archive's bucket. | 69 the archive's bucket. |
| 70 | 70 |
| 71 Warns when a bucket is not specified or when the user doesn't have | 71 Warns when a bucket is not specified or when the user doesn't have |
| 72 permission to access the archive's bucket but a local copy of the archive | 72 permission to access the archive's bucket but a local copy of the archive |
| 73 exists. | 73 exists. |
| 74 """ | 74 """ |
| 75 # Download all .wpr files. | 75 # Download all .wpr files. |
| 76 if self._data: | |
|
aiolos (Not reviewing)
2015/01/13 19:42:58
I believe this should actually be
if not self._da
nednguyen
2015/01/13 19:58:51
lizeb@'s point is self._data cannot be None since
aiolos (Not reviewing)
2015/01/13 20:18:57
Ah, I missed that comment. We might rely on this n
| |
| 77 return | |
| 78 if not self._bucket: | 76 if not self._bucket: |
| 79 logging.warning('User story set in %s has no bucket specified, and ' | 77 logging.warning('User story set in %s has no bucket specified, and ' |
| 80 'cannot be downloaded from cloud_storage.', ) | 78 'cannot be downloaded from cloud_storage.', ) |
|
nednguyen
2015/01/13 18:20:59
Can you add: assert 'archives' in self._data, "Inv
Benoit L
2015/01/13 18:24:39
Acknowledged.
The constructor would throw without
nednguyen
2015/01/13 18:38:14
I prefer assertion since it gives a clearer debugg
| |
| 81 | |
| 82 for archive_path in self._data['archives']: | 79 for archive_path in self._data['archives']: |
| 83 archive_path = self._WprFileNameToPath(archive_path) | 80 archive_path = self._WprFileNameToPath(archive_path) |
| 84 try: | 81 try: |
| 85 cloud_storage.GetIfChanged(archive_path, self._bucket) | 82 cloud_storage.GetIfChanged(archive_path, self._bucket) |
| 86 except (cloud_storage.CredentialsError, cloud_storage.PermissionError): | 83 except (cloud_storage.CredentialsError, cloud_storage.PermissionError): |
| 87 if os.path.exists(archive_path): | 84 if os.path.exists(archive_path): |
| 88 # If the archive exists, assume the user recorded their own and | 85 # If the archive exists, assume the user recorded their own and |
| 89 # simply warn. | 86 # simply warn. |
| 90 logging.warning('Need credentials to update WPR archive: %s', | 87 logging.warning('Need credentials to update WPR archive: %s', |
| 91 archive_path) | 88 archive_path) |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 | 204 |
| 208 def _SetWprFileForUserStory(self, user_story_name, wpr_file): | 205 def _SetWprFileForUserStory(self, user_story_name, wpr_file): |
| 209 """For modifying the metadata when we're going to record a new archive.""" | 206 """For modifying the metadata when we're going to record a new archive.""" |
| 210 old_wpr_file = self._user_story_name_to_wpr_file.get(user_story_name, None) | 207 old_wpr_file = self._user_story_name_to_wpr_file.get(user_story_name, None) |
| 211 if old_wpr_file: | 208 if old_wpr_file: |
| 212 self._wpr_file_to_user_story_names[old_wpr_file].remove(user_story_name) | 209 self._wpr_file_to_user_story_names[old_wpr_file].remove(user_story_name) |
| 213 self._user_story_name_to_wpr_file[user_story_name] = wpr_file | 210 self._user_story_name_to_wpr_file[user_story_name] = wpr_file |
| 214 if wpr_file not in self._wpr_file_to_user_story_names: | 211 if wpr_file not in self._wpr_file_to_user_story_names: |
| 215 self._wpr_file_to_user_story_names[wpr_file] = [] | 212 self._wpr_file_to_user_story_names[wpr_file] = [] |
| 216 self._wpr_file_to_user_story_names[wpr_file].append(user_story_name) | 213 self._wpr_file_to_user_story_names[wpr_file].append(user_story_name) |
| OLD | NEW |