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

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

Issue 12042069: Scripts to download files from google storage based on sha1 sums (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Removed gsutil/tests and gsutil/docs Created 7 years, 10 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
OLDNEW
(Empty)
1 # Copyright 2011 Google Inc.
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 gslib.command import Command
16 from gslib.command import COMMAND_NAME
17 from gslib.command import COMMAND_NAME_ALIASES
18 from gslib.command import CONFIG_REQUIRED
19 from gslib.command import FILE_URIS_OK
20 from gslib.command import MAX_ARGS
21 from gslib.command import MIN_ARGS
22 from gslib.command import PROVIDER_URIS_OK
23 from gslib.command import SUPPORTED_SUB_ARGS
24 from gslib.command import URIS_START_ARG
25 from gslib.exception import CommandException
26 from gslib.help_provider import HELP_NAME
27 from gslib.help_provider import HELP_NAME_ALIASES
28 from gslib.help_provider import HELP_ONE_LINE_SUMMARY
29 from gslib.help_provider import HELP_TEXT
30 from gslib.help_provider import HelpType
31 from gslib.help_provider import HELP_TYPE
32 from gslib.util import NO_MAX
33
34 _detailed_help_text = ("""
35 <B>SYNOPSIS</B>
36 gsutil rb uri...
37
38 <B>DESCRIPTION</B>
39 The rb command deletes new bucket. Buckets must be empty before you can delete
40 them.
41
42 Be certain you want to delete a bucket before you do so, as once it is
43 deleted the name becomes available and another user may create a bucket with
44 that name. (But see also "DOMAIN NAMED BUCKETS" under "gsutil help naming"
45 for help carving out parts of the bucket name space.)
46 """)
47
48
49 class RbCommand(Command):
50 """Implementation of gsutil rb command."""
51
52 # Command specification (processed by parent class).
53 command_spec = {
54 # Name of command.
55 COMMAND_NAME : 'rb',
56 # List of command name aliases.
57 COMMAND_NAME_ALIASES : [
58 'deletebucket', 'removebucket', 'removebuckets', 'rmdir'],
59 # Min number of args required by this command.
60 MIN_ARGS : 1,
61 # Max number of args required by this command, or NO_MAX.
62 MAX_ARGS : NO_MAX,
63 # Getopt-style string specifying acceptable sub args.
64 SUPPORTED_SUB_ARGS : '',
65 # True if file URIs acceptable for this command.
66 FILE_URIS_OK : False,
67 # True if provider-only URIs acceptable for this command.
68 PROVIDER_URIS_OK : False,
69 # Index in args of first URI arg.
70 URIS_START_ARG : 0,
71 # True if must configure gsutil before running command.
72 CONFIG_REQUIRED : True,
73 }
74 help_spec = {
75 # Name of command or auxiliary help info for which this help applies.
76 HELP_NAME : 'rb',
77 # List of help name aliases.
78 HELP_NAME_ALIASES :
79 ['deletebucket', 'removebucket', 'removebuckets', 'rmdir'],
80 # Type of help:
81 HELP_TYPE : HelpType.COMMAND_HELP,
82 # One line summary of this help.
83 HELP_ONE_LINE_SUMMARY : 'Remove buckets',
84 # The full help text.
85 HELP_TEXT : _detailed_help_text,
86 }
87
88 # Command entry point.
89 def RunCommand(self):
90 # Expand bucket name wildcards, if any.
91 did_some_work = False
92 for uri_str in self.args:
93 for uri in self.WildcardIterator(uri_str).IterUris():
94 if uri.object_name:
95 raise CommandException('"rb" command requires a URI with no object '
96 'name')
97 print 'Removing %s...' % uri
98 uri.delete_bucket(self.headers)
99 did_some_work = True
100 if not did_some_work:
101 raise CommandException('No URIs matched')
102 return 0
103
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698