| OLD | NEW |
| 1 # -*- coding: utf-8 -*- |
| 1 # Copyright 2012 Google Inc. All Rights Reserved. | 2 # Copyright 2012 Google Inc. All Rights Reserved. |
| 2 # | 3 # |
| 3 # Licensed under the Apache License, Version 2.0 (the "License"); | 4 # 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 not use this file except in compliance with the License. |
| 5 # You may obtain a copy of the License at | 6 # You may obtain a copy of the License at |
| 6 # | 7 # |
| 7 # http://www.apache.org/licenses/LICENSE-2.0 | 8 # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 # | 9 # |
| 9 # Unless required by applicable law or agreed to in writing, software | 10 # Unless required by applicable law or agreed to in writing, software |
| 10 # distributed under the License is distributed on an "AS IS" BASIS, | 11 # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 # See the License for the specific language governing permissions and | 13 # See the License for the specific language governing permissions and |
| 13 # limitations under the License. | 14 # limitations under the License. |
| 15 """Additional help about gsutil command-level options.""" |
| 14 | 16 |
| 15 from gslib.help_provider import HELP_NAME | 17 from __future__ import absolute_import |
| 16 from gslib.help_provider import HELP_NAME_ALIASES | 18 |
| 17 from gslib.help_provider import HELP_ONE_LINE_SUMMARY | |
| 18 from gslib.help_provider import HelpProvider | 19 from gslib.help_provider import HelpProvider |
| 19 from gslib.help_provider import HELP_TEXT | |
| 20 from gslib.help_provider import HelpType | |
| 21 from gslib.help_provider import HELP_TYPE | |
| 22 | 20 |
| 23 _detailed_help_text = (""" | 21 _DETAILED_HELP_TEXT = (""" |
| 24 <B>SYNOPSIS</B> | 22 <B>SYNOPSIS</B> |
| 25 Top-level gsutil Options | 23 Top-level gsutil Options |
| 26 | 24 |
| 27 | 25 |
| 28 <B>DESCRIPTION</B> | 26 <B>DESCRIPTION</B> |
| 29 gsutil supports separate options for the top-level gsutil command and | 27 gsutil supports separate options for the top-level gsutil command and |
| 30 the individual sub-commands (like cp, rm, etc.) The top-level options | 28 the individual sub-commands (like cp, rm, etc.) The top-level options |
| 31 control behavior of gsutil that apply across commands. For example, in | 29 control behavior of gsutil that apply across commands. For example, in |
| 32 the command: | 30 the command: |
| 33 | 31 |
| 34 gsutil -m cp -p file gs://bucket/obj | 32 gsutil -m cp -p file gs://bucket/obj |
| 35 | 33 |
| 36 the -m option applies to gsutil, while the -p option applies to the cp | 34 the -m option applies to gsutil, while the -p option applies to the cp |
| 37 sub-command. | 35 sub-command. |
| 38 | 36 |
| 39 | 37 |
| 40 <B>OPTIONS</B> | 38 <B>OPTIONS</B> |
| 41 -d Shows HTTP requests/headers. | 39 -D Shows HTTP requests/headers and additional debug info needed when |
| 42 | |
| 43 -D Shows HTTP requests/headers plus additional debug info needed when | |
| 44 posting support requests. | 40 posting support requests. |
| 45 | 41 |
| 46 -DD Shows HTTP requests/headers plus additional debug info plus HTTP | 42 -DD Shows HTTP requests/headers, additional debug info plus HTTP |
| 47 upstream payload. | 43 upstream payload. |
| 48 | 44 |
| 49 -h Allows you to specify additional HTTP headers, for example: | 45 -h Allows you to specify certain HTTP headers, for example: |
| 50 | 46 |
| 51 gsutil -h "Cache-Control:public,max-age=3600" \\ | 47 gsutil -h "Cache-Control:public,max-age=3600" \\ |
| 52 -h "Content-Type:text/html" cp ... | 48 -h "Content-Type:text/html" cp ... |
| 53 | 49 |
| 54 Note that you need to quote the headers/values that | 50 Note that you need to quote the headers/values that |
| 55 contain spaces (such as "Content-Disposition: attachment; | 51 contain spaces (such as "Content-Disposition: attachment; |
| 56 filename=filename.ext"), to avoid having the shell split them | 52 filename=filename.ext"), to avoid having the shell split them |
| 57 into separate arguments. | 53 into separate arguments. |
| 58 | 54 |
| 59 Note that because the -h option allows you to specify any HTTP | 55 The following headers are supported: |
| 60 header, it is both powerful and potentially dangerous: | 56 Cache-Control |
| 57 Content-Disposition |
| 58 Content-Encoding |
| 59 Content-Language |
| 60 Content-MD5 |
| 61 Content-Type |
| 62 Custom metadata headers with a matching Cloud Storage Provider |
| 63 prefix, such as: |
| 61 | 64 |
| 62 - It is powerful because it allows you to specify headers that | 65 x-goog-meta- |
| 63 gsutil doesn't currently know about (e.g., to request | |
| 64 service features from a different storage service provider | |
| 65 than Google); or to override the values gsutil would normally | |
| 66 send with different values. | |
| 67 - It is potentially dangerous because you can specify headers | |
| 68 that cause gsutil to send invalid requests, or that in | |
| 69 other ways change the behavior of requests. | |
| 70 | 66 |
| 71 Thus, you should be sure you understand the underlying storage | 67 Note that for gs:// URLs, the Cache Control header is specific to |
| 72 service HTTP API (and what impact the headers you specify will | 68 the API being used. The XML API will accept any cache control |
| 73 have) before using the gsutil -h option. | 69 headers and return them during object downloads. The JSON API |
| 70 respects only the public, private, no-cache, and max-age cache |
| 71 control headers, and may add its own no-transform directive even |
| 72 if it was not specified. See 'gsutil help apis' for more |
| 73 information on gsutil's interaction with APIs. |
| 74 | 74 |
| 75 See also "gsutil help setmeta" for the ability to set metadata | 75 See also "gsutil help setmeta" for the ability to set metadata |
| 76 fields on objects after they have been uploaded. | 76 fields on objects after they have been uploaded. |
| 77 | 77 |
| 78 -m Causes supported operations (acl ch, acl set, cp, mv, rm, | 78 -m Causes supported operations (acl ch, acl set, cp, mv, rm, rsync, |
| 79 and setmeta) to run in parallel. This can significantly improve | 79 and setmeta) to run in parallel. This can significantly improve |
| 80 performance if you are uploading, downloading, moving, removing, | 80 performance if you are performing operations on a large number of |
| 81 or changing ACLs on a large number of files over a fast network | 81 files over a reasonably fast network connection. |
| 82 connection. | |
| 83 | 82 |
| 84 gsutil performs the specified operation using a combination of | 83 gsutil performs the specified operation using a combination of |
| 85 multi-threading and multi-processing, using a number of threads | 84 multi-threading and multi-processing, using a number of threads |
| 86 and processors determined by the parallel_thread_count and | 85 and processors determined by the parallel_thread_count and |
| 87 parallel_process_count values set in the boto configuration | 86 parallel_process_count values set in the boto configuration |
| 88 file. You might want to experiment with these values, as the | 87 file. You might want to experiment with these values, as the |
| 89 best values can vary based on a number of factors, including | 88 best values can vary based on a number of factors, including |
| 90 network speed, number of CPUs, and available memory. | 89 network speed, number of CPUs, and available memory. |
| 91 | 90 |
| 92 Using the -m option may make your performance worse if you | 91 Using the -m option may make your performance worse if you |
| 93 are using a slower network, such as the typical network speeds | 92 are using a slower network, such as the typical network speeds |
| 94 offered by non-business home network plans. | 93 offered by non-business home network plans. It can also make |
| 94 your performance worse for cases that perform all operations |
| 95 locally (e.g., gsutil rsync, where both source and desination URLs |
| 96 are on the local disk), because it can "thrash" your local disk. |
| 95 | 97 |
| 96 If a download or upload operation using parallel transfer fails | 98 If a download or upload operation using parallel transfer fails |
| 97 before the entire transfer is complete (e.g. failing after 300 of | 99 before the entire transfer is complete (e.g. failing after 300 of |
| 98 1000 files have been transferred), you will need to restart the | 100 1000 files have been transferred), you will need to restart the |
| 99 entire transfer. | 101 entire transfer. |
| 100 | 102 |
| 101 Also, although most commands will normally fail upon encountering | 103 Also, although most commands will normally fail upon encountering |
| 102 an error when the -m flag is disabled, all commands will | 104 an error when the -m flag is disabled, all commands will |
| 103 continue to try all operations when -m is enabled with multiple | 105 continue to try all operations when -m is enabled with multiple |
| 104 threads or processes, and the number of failed operations (if any) | 106 threads or processes, and the number of failed operations (if any) |
| 105 will be reported at the end of the command's execution. | 107 will be reported at the end of the command's execution. |
| 106 | 108 |
| 107 WARNING: If you use the gsutil -m option when copying data | 109 WARNING: If you use the gsutil -m option when copying data |
| 108 between versioned buckets, object version ordering will not be | 110 between versioned buckets, object version ordering will not be |
| 109 preserved. For more information see the | 111 preserved. For more information see the |
| 110 "COPYING VERSIONED BUCKETS" section under | 112 "COPYING VERSIONED BUCKETS" section under |
| 111 'gsutil help versions'. | 113 'gsutil help versions'. |
| 112 | 114 |
| 113 -o Set/override values in the boto configuration value, in the format | 115 -o Set/override values in the boto configuration value, in the format |
| 114 <section>:<name>=<value>, e.g. gsutil -o "Boto:proxy=host" ... | 116 <section>:<name>=<value>, e.g. gsutil -o "Boto:proxy=host" ... |
| 117 This will not pass the option to gsutil integration tests, which |
| 118 run in a separate process. |
| 115 | 119 |
| 116 -q Causes gsutil to perform operations quietly, i.e., without | 120 -q Causes gsutil to perform operations quietly, i.e., without |
| 117 reporting progress indicators of files being copied or removed, | 121 reporting progress indicators of files being copied or removed, |
| 118 etc. Errors are still reported. This option can be useful for | 122 etc. Errors are still reported. This option can be useful for |
| 119 running gsutil from a cron job that logs its output to a file, for | 123 running gsutil from a cron job that logs its output to a file, for |
| 120 which the only information desired in the log is failures. | 124 which the only information desired in the log is failures. |
| 121 | 125 |
| 122 -s Tells gsutil to use a simulated storage provider (for testing). | 126 -s Tells gsutil to use a simulated storage provider (for testing). |
| 123 """) | 127 """) |
| 124 | 128 |
| 125 | 129 |
| 126 class CommandOptions(HelpProvider): | 130 class CommandOptions(HelpProvider): |
| 127 """Additional help about gsutil command-level options.""" | 131 """Additional help about gsutil command-level options.""" |
| 128 | 132 |
| 129 help_spec = { | 133 # Help specification. See help_provider.py for documentation. |
| 130 # Name of command or auxiliary help info for which this help applies. | 134 help_spec = HelpProvider.HelpSpec( |
| 131 HELP_NAME : 'options', | 135 help_name='options', |
| 132 # List of help name aliases. | 136 help_name_aliases=['arg', 'args', 'cli', 'opt', 'opts'], |
| 133 HELP_NAME_ALIASES : ['arg', 'args', 'cli', 'opt', 'opts'], | 137 help_type='additional_help', |
| 134 # Type of help: | 138 help_one_line_summary='Top-Level Command-Line Options', |
| 135 HELP_TYPE : HelpType.ADDITIONAL_HELP, | 139 help_text=_DETAILED_HELP_TEXT, |
| 136 # One line summary of this help. | 140 subcommand_help_text={}, |
| 137 HELP_ONE_LINE_SUMMARY : 'Top-Level Command-Line Options', | 141 ) |
| 138 # The full help text. | |
| 139 HELP_TEXT : _detailed_help_text, | |
| 140 } | |
| OLD | NEW |