OXIESEC PANEL
- Current Dir:
/
/
opt
/
gsutil
/
gslib
/
commands
Server IP: 2a02:4780:11:1594:0:ef5:22d7:a
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/11/2025 08:19:48 AM
rwxr-xr-x
📄
__init__.py
797 bytes
12/09/2024 05:26:03 PM
rw-r--r--
📁
__pycache__
-
02/11/2025 08:19:49 AM
rwxr-xr-x
📄
acl.py
23.78 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
autoclass.py
8.89 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
bucketpolicyonly.py
8.7 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
cat.py
5.43 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
compose.py
6.28 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
config.py
51.14 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
cors.py
8.54 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
cp.py
57.49 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
defacl.py
14.53 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
defstorageclass.py
7.73 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
du.py
10.48 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
hash.py
9.82 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
help.py
9.18 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
hmac.py
16.65 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
iam.py
34 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
kms.py
20.74 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
label.py
15.84 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
lifecycle.py
8.71 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
logging.py
12.93 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
ls.py
26.7 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
mb.py
16.6 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
mv.py
6.36 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
notification.py
33.94 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
pap.py
9.25 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
perfdiag.py
93.4 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
rb.py
5.71 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
requesterpays.py
8.28 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
retention.py
29.76 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
rewrite.py
25.7 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
rm.py
16 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
rpo.py
7.85 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
rsync.py
79.51 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
setmeta.py
15.86 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
signurl.py
28.89 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
stat.py
6.63 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
test.py
28.28 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
ubla.py
10.05 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
update.py
17.73 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
version.py
7.12 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
versioning.py
8.34 KB
12/09/2024 05:26:03 PM
rw-r--r--
📄
web.py
9.87 KB
12/09/2024 05:26:03 PM
rw-r--r--
Editing: rb.py
Close
# -*- coding: utf-8 -*- # Copyright 2011 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Implementation of rb command for deleting cloud storage buckets.""" from __future__ import absolute_import from __future__ import print_function from __future__ import division from __future__ import unicode_literals from gslib.cloud_api import NotEmptyException from gslib.command import Command from gslib.command_argument import CommandArgument from gslib.cs_api_map import ApiSelector from gslib.exception import CommandException from gslib.exception import NO_URLS_MATCHED_TARGET from gslib.storage_url import StorageUrlFromString from gslib.utils.constants import NO_MAX from gslib.utils.shim_util import GcloudStorageFlag from gslib.utils.shim_util import GcloudStorageMap _SYNOPSIS = """ gsutil rb [-f] gs://<bucket_name>... """ _DETAILED_HELP_TEXT = (""" <B>SYNOPSIS</B> """ + _SYNOPSIS + """ <B>DESCRIPTION</B> Delete one or more buckets. Buckets must be empty before you can delete them. Be certain you want to delete a bucket before you do so, as once it is deleted the name becomes available and another user may create a bucket with that name. (But see also "DOMAIN NAMED BUCKETS" under "gsutil help naming" for help carving out parts of the bucket name space.) <B>OPTIONS</B> -f Continues silently (without printing error messages) despite errors when removing buckets. If some buckets couldn't be removed, gsutil's exit status will be non-zero even if this flag is set. If no buckets could be removed, the command raises a "no matches" error. """) class RbCommand(Command): """Implementation of gsutil rb command.""" # Command specification. See base class for documentation. command_spec = Command.CreateCommandSpec( 'rb', command_name_aliases=[ 'deletebucket', 'removebucket', 'removebuckets', 'rmdir', ], usage_synopsis=_SYNOPSIS, min_args=1, max_args=NO_MAX, supported_sub_args='f', file_url_ok=False, provider_url_ok=False, urls_start_arg=0, gs_api_support=[ ApiSelector.XML, ApiSelector.JSON, ], gs_default_api=ApiSelector.JSON, argparse_arguments=[ CommandArgument.MakeZeroOrMoreCloudBucketURLsArgument(), ], ) # Help specification. See help_provider.py for documentation. help_spec = Command.HelpSpec( help_name='rb', help_name_aliases=[ 'deletebucket', 'removebucket', 'removebuckets', 'rmdir', ], help_type='command_help', help_one_line_summary='Remove buckets', help_text=_DETAILED_HELP_TEXT, subcommand_help_text={}, ) gcloud_storage_map = GcloudStorageMap( gcloud_command=['storage', 'buckets', 'delete'], flag_map={ '-f': GcloudStorageFlag('--continue-on-error'), }, ) def RunCommand(self): """Command entry point for the rb command.""" self.continue_on_error = False if self.sub_opts: for o, unused_a in self.sub_opts: if o == '-f': self.continue_on_error = True did_some_work = False some_failed = False for url_str in self.args: wildcard_url = StorageUrlFromString(url_str) if wildcard_url.IsObject(): raise CommandException('"rb" command requires a provider or ' 'bucket URL') # Wrap WildcardIterator call in try/except so we can avoid printing errors # with -f option if a non-existent URL listed, permission denial happens # while listing, etc. try: # Materialize iterator results into a list to catch exceptions. # Since this is listing buckets this list shouldn't be too large to fit # in memory at once. # Also, avoid listing all fields to avoid performing unnecessary bucket # metadata GETs. These would also be problematic when billing is # disabled, as deletes are allowed but GetBucket is not. blrs = list( self.WildcardIterator(url_str).IterBuckets(bucket_fields=['id'])) except: # pylint: disable=bare-except some_failed = True if self.continue_on_error: continue else: raise for blr in blrs: url = blr.storage_url self.logger.info('Removing %s...', url) try: self.gsutil_api.DeleteBucket(url.bucket_name, provider=url.scheme) except NotEmptyException as e: some_failed = True if self.continue_on_error: continue elif 'VersionedBucketNotEmpty' in e.reason: raise CommandException('Bucket is not empty. Note: this is a ' 'versioned bucket, so to delete all ' 'objects\nyou need to use:' '\n\tgsutil rm -r %s' % url) else: raise except: # pylint: disable=bare-except some_failed = True if not self.continue_on_error: raise did_some_work = True if not did_some_work: raise CommandException(NO_URLS_MATCHED_TARGET % list(self.args)) return 1 if some_failed else 0