OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 # Copyright 2013 Google Inc. All Rights Reserved. | 2 # Copyright 2013 Google Inc. All Rights Reserved. |
3 # | 3 # |
4 # Licensed under the Apache License, Version 2.0 (the "License"); | 4 # Licensed under the Apache License, Version 2.0 (the "License"); |
5 # you may not use this file except in compliance with the License. | 5 # you may not use this file except in compliance with the License. |
6 # You may obtain a copy of the License at | 6 # You may obtain a copy of the License at |
7 # | 7 # |
8 # http://www.apache.org/licenses/LICENSE-2.0 | 8 # http://www.apache.org/licenses/LICENSE-2.0 |
9 # | 9 # |
10 # Unless required by applicable law or agreed to in writing, software | 10 # Unless required by applicable law or agreed to in writing, software |
11 # distributed under the License is distributed on an "AS IS" BASIS, | 11 # distributed under the License is distributed on an "AS IS" BASIS, |
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 # See the License for the specific language governing permissions and | 13 # See the License for the specific language governing permissions and |
14 # limitations under the License. | 14 # limitations under the License. |
15 """Implementation of Unix-like stat command for cloud storage providers.""" | 15 """Implementation of Unix-like stat command for cloud storage providers.""" |
16 | 16 |
17 from __future__ import absolute_import | 17 from __future__ import absolute_import |
18 | 18 |
19 import logging | 19 import logging |
| 20 import sys |
20 | 21 |
21 from gslib.bucket_listing_ref import BucketListingObject | 22 from gslib.bucket_listing_ref import BucketListingObject |
22 from gslib.cloud_api import AccessDeniedException | 23 from gslib.cloud_api import AccessDeniedException |
23 from gslib.cloud_api import NotFoundException | 24 from gslib.cloud_api import NotFoundException |
24 from gslib.command import Command | 25 from gslib.command import Command |
25 from gslib.command_argument import CommandArgument | 26 from gslib.command_argument import CommandArgument |
26 from gslib.cs_api_map import ApiSelector | 27 from gslib.cs_api_map import ApiSelector |
27 from gslib.exception import CommandException | 28 from gslib.exception import CommandException |
28 from gslib.exception import InvalidUrlError | 29 from gslib.exception import InvalidUrlError |
29 from gslib.storage_url import ContainsWildcard | 30 from gslib.storage_url import ContainsWildcard |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 single_obj = self.gsutil_api.GetObjectMetadata( | 132 single_obj = self.gsutil_api.GetObjectMetadata( |
132 url.bucket_name, url.object_name, generation=url.generation, | 133 url.bucket_name, url.object_name, generation=url.generation, |
133 provider=url.scheme, fields=stat_fields) | 134 provider=url.scheme, fields=stat_fields) |
134 blr_iter = [BucketListingObject(url, root_object=single_obj)] | 135 blr_iter = [BucketListingObject(url, root_object=single_obj)] |
135 for blr in blr_iter: | 136 for blr in blr_iter: |
136 if blr.IsObject(): | 137 if blr.IsObject(): |
137 arg_matches += 1 | 138 arg_matches += 1 |
138 if logging.getLogger().isEnabledFor(logging.INFO): | 139 if logging.getLogger().isEnabledFor(logging.INFO): |
139 PrintFullInfoAboutObject(blr, incl_acl=False) | 140 PrintFullInfoAboutObject(blr, incl_acl=False) |
140 except AccessDeniedException: | 141 except AccessDeniedException: |
141 logging.info('You aren\'t authorized to read %s - skipping', url_str) | 142 sys.stderr.write('You aren\'t authorized to read %s - skipping' % |
| 143 url_str) |
142 except InvalidUrlError: | 144 except InvalidUrlError: |
143 raise | 145 raise |
144 except NotFoundException: | 146 except NotFoundException: |
145 pass | 147 pass |
146 if not arg_matches: | 148 if not arg_matches: |
147 if logging.getLogger().isEnabledFor(logging.INFO): | 149 sys.stderr.write('No URLs matched %s' % url_str) |
148 logging.info('No URLs matched %s', url_str) | |
149 found_nonmatching_arg = True | 150 found_nonmatching_arg = True |
150 if found_nonmatching_arg: | 151 if found_nonmatching_arg: |
151 return 1 | 152 return 1 |
152 return 0 | 153 return 0 |
OLD | NEW |