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

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

Issue 2280023003: depot_tools: Remove third_party/gsutil (Closed)
Patch Set: Created 4 years, 3 months 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
(Empty)
1 # Copyright 2011 Google Inc. All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 from boto.exception import GSResponseError
16 from gslib.command import Command
17 from gslib.command import COMMAND_NAME
18 from gslib.command import COMMAND_NAME_ALIASES
19 from gslib.command import CONFIG_REQUIRED
20 from gslib.command import FILE_URIS_OK
21 from gslib.command import MAX_ARGS
22 from gslib.command import MIN_ARGS
23 from gslib.command import PROVIDER_URIS_OK
24 from gslib.command import SUPPORTED_SUB_ARGS
25 from gslib.command import URIS_START_ARG
26 from gslib.exception import CommandException
27 from gslib.help_provider import HELP_NAME
28 from gslib.help_provider import HELP_NAME_ALIASES
29 from gslib.help_provider import HELP_ONE_LINE_SUMMARY
30 from gslib.help_provider import HELP_TEXT
31 from gslib.help_provider import HelpType
32 from gslib.help_provider import HELP_TYPE
33 from gslib.util import NO_MAX
34
35 _detailed_help_text = ("""
36 <B>SYNOPSIS</B>
37 gsutil rb uri...
38
39 <B>DESCRIPTION</B>
40 The rb command deletes new bucket. Buckets must be empty before you can delete
41 them.
42
43 Be certain you want to delete a bucket before you do so, as once it is
44 deleted the name becomes available and another user may create a bucket with
45 that name. (But see also "DOMAIN NAMED BUCKETS" under "gsutil help naming"
46 for help carving out parts of the bucket name space.)
47 """)
48
49
50 class RbCommand(Command):
51 """Implementation of gsutil rb command."""
52
53 # Command specification (processed by parent class).
54 command_spec = {
55 # Name of command.
56 COMMAND_NAME : 'rb',
57 # List of command name aliases.
58 COMMAND_NAME_ALIASES : [
59 'deletebucket', 'removebucket', 'removebuckets', 'rmdir'],
60 # Min number of args required by this command.
61 MIN_ARGS : 1,
62 # Max number of args required by this command, or NO_MAX.
63 MAX_ARGS : NO_MAX,
64 # Getopt-style string specifying acceptable sub args.
65 SUPPORTED_SUB_ARGS : '',
66 # True if file URIs acceptable for this command.
67 FILE_URIS_OK : False,
68 # True if provider-only URIs acceptable for this command.
69 PROVIDER_URIS_OK : False,
70 # Index in args of first URI arg.
71 URIS_START_ARG : 0,
72 # True if must configure gsutil before running command.
73 CONFIG_REQUIRED : True,
74 }
75 help_spec = {
76 # Name of command or auxiliary help info for which this help applies.
77 HELP_NAME : 'rb',
78 # List of help name aliases.
79 HELP_NAME_ALIASES :
80 ['deletebucket', 'removebucket', 'removebuckets', 'rmdir'],
81 # Type of help:
82 HELP_TYPE : HelpType.COMMAND_HELP,
83 # One line summary of this help.
84 HELP_ONE_LINE_SUMMARY : 'Remove buckets',
85 # The full help text.
86 HELP_TEXT : _detailed_help_text,
87 }
88
89 # Command entry point.
90 def RunCommand(self):
91 # Expand bucket name wildcards, if any.
92 did_some_work = False
93 for uri_str in self.args:
94 for uri in self.WildcardIterator(uri_str).IterUris():
95 if uri.object_name:
96 raise CommandException('"rb" command requires a URI with no object '
97 'name')
98 print 'Removing %s...' % uri
99 try:
100 uri.delete_bucket(self.headers)
101 except GSResponseError as e:
102 if e.code == 'BucketNotEmpty' and uri.get_versioning_config():
103 raise CommandException('Bucket is not empty. Note: this is a '
104 'versioned bucket, so to delete all objects'
105 '\nyou need to use:\n\tgsutil rm -ra %s'
106 % uri)
107 else:
108 raise
109 did_some_work = True
110 if not did_some_work:
111 raise CommandException('No URIs matched')
112 return 0
113
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