Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: third_party/gsutil/gslib/commands/rb.py

Issue 1380943003: Roll version of gsutil to 4.15. (Closed) Base URL: https://github.com/catapult-project/catapult.git@master
Patch Set: rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/gsutil/gslib/commands/perfdiag.py ('k') | third_party/gsutil/gslib/commands/rm.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 # Copyright 2011 Google Inc. All Rights Reserved. 2 # Copyright 2011 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
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 some_failed = False 95 some_failed = False
96 for url_str in self.args: 96 for url_str in self.args:
97 wildcard_url = StorageUrlFromString(url_str) 97 wildcard_url = StorageUrlFromString(url_str)
98 if wildcard_url.IsObject(): 98 if wildcard_url.IsObject():
99 raise CommandException('"rb" command requires a provider or ' 99 raise CommandException('"rb" command requires a provider or '
100 'bucket URL') 100 'bucket URL')
101 # Wrap WildcardIterator call in try/except so we can avoid printing errors 101 # Wrap WildcardIterator call in try/except so we can avoid printing errors
102 # with -f option if a non-existent URL listed, permission denial happens 102 # with -f option if a non-existent URL listed, permission denial happens
103 # while listing, etc. 103 # while listing, etc.
104 try: 104 try:
105 # Need to materialize iterator results into a list to catch exceptions. 105 # Materialize iterator results into a list to catch exceptions.
106 # Since this is listing buckets this list shouldn't be too large to fit 106 # Since this is listing buckets this list shouldn't be too large to fit
107 # in memory at once. 107 # in memory at once.
108 blrs = list(self.WildcardIterator(url_str).IterBuckets()) 108 # Also, avoid listing all fields to avoid performing unnecessary bucket
109 # metadata GETs. These would also be problematic when billing is
110 # disabled, as deletes are allowed but GetBucket is not.
111 blrs = list(
112 self.WildcardIterator(url_str).IterBuckets(bucket_fields=['id']))
109 except: # pylint: disable=bare-except 113 except: # pylint: disable=bare-except
110 some_failed = True 114 some_failed = True
111 if self.continue_on_error: 115 if self.continue_on_error:
112 continue 116 continue
113 else: 117 else:
114 raise 118 raise
115 for blr in blrs: 119 for blr in blrs:
116 url = blr.storage_url 120 url = blr.storage_url
117 self.logger.info('Removing %s...', url) 121 self.logger.info('Removing %s...', url)
118 try: 122 try:
119 self.gsutil_api.DeleteBucket(url.bucket_name, provider=url.scheme) 123 self.gsutil_api.DeleteBucket(url.bucket_name, provider=url.scheme)
120 except NotEmptyException as e: 124 except NotEmptyException as e:
125 some_failed = True
121 if self.continue_on_error: 126 if self.continue_on_error:
122 continue 127 continue
123 elif 'VersionedBucketNotEmpty' in e.reason: 128 elif 'VersionedBucketNotEmpty' in e.reason:
124 raise CommandException('Bucket is not empty. Note: this is a ' 129 raise CommandException('Bucket is not empty. Note: this is a '
125 'versioned bucket, so to delete all ' 130 'versioned bucket, so to delete all '
126 'objects\nyou need to use:' 131 'objects\nyou need to use:'
127 '\n\tgsutil rm -r %s' % url) 132 '\n\tgsutil rm -r %s' % url)
128 else: 133 else:
129 raise 134 raise
130 except: # pylint: disable=bare-except 135 except: # pylint: disable=bare-except
136 some_failed = True
131 if not self.continue_on_error: 137 if not self.continue_on_error:
132 raise 138 raise
133 did_some_work = True 139 did_some_work = True
134 if not did_some_work: 140 if not did_some_work:
135 raise CommandException('No URLs matched') 141 raise CommandException('No URLs matched')
136 return 1 if some_failed else 0 142 return 1 if some_failed else 0
137 143
OLDNEW
« no previous file with comments | « third_party/gsutil/gslib/commands/perfdiag.py ('k') | third_party/gsutil/gslib/commands/rm.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698