Client for Swift
Copyright 2012-2013 Gregory Holt
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
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.
Version str for Swiftly: "major.minor".
If the second number is even, it's an official release. If the second number is odd, it's a development release.
Contains swiftly.cli.cli.CLI that implements the swiftly command line interface and all the surrounding implementation modules.
CLI is imported here for convenience.
Copyright 2011-2013 Gregory Holt
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
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.
Contains a CLICommand that authenticates and then outputs the resulting information.
Uses the following from swiftly.cli.context.CLIContext:
client_manager | For connecting to Swift. |
io_manager | For directing output. |
Bases: swiftly.cli.command.CLICommand
A CLICommand that authenticates and then outputs the resulting information.
See the output of swiftly help auth for more information.
Authenticates and then outputs the resulting information.
See swiftly.cli.auth for context usage information.
See CLIAuth for more information.
Contains the CLI class that handles the original command line.
Bases: object
Handles the original command line.
An example script is swiftly itself:
#!/usr/bin/env python
import sys
import swiftly.cli
sys.exit(swiftly.cli.CLI()())
See the output of swiftly help for more information.
Parameters: | commands -- The list of commands available; if None COMMANDS will be used. |
---|
A dictionary of the available commands and their CLICommand instances.
The overall CLIContext containing attributes generated by the initial main_options parsing.
The available attributes are:
cdn | True if the CDN URL should be used instead of the default Storage URL. |
client_manager | The swiftly.client.manager.ClientManager to use for obtaining clients. |
concurrency | Number of concurrent actions to allow. |
io_manager | The swiftly.cli.iomanager.IOManager to use for input and output. |
eventlet | True if Eventlet is in use. |
original_args | The original args used by the CLI. |
original_begin | The original time.time() when the CLI was called. |
verbose | Function to call when you want to (optionally) emit verbose output. verbose(msg, *args) where the output will be constructed with msg % args. |
verbosity | Level of verbosity. Just None or 1 right now. |
The main OptionParser.
The list of CLICommand classes avaiable to CLI. You'll want to add any new CLICommand you create to this list.
A list of lowercase string values that equate to True.
Contains the CLICommand class that can be subclassed to create new Swiftly commands.
Bases: object
Subclass this to create new Swiftly commands.
Don't forget to add your new class to swiftly.cli.cli.COMMANDS.
Your subclass will be created by swiftly.cli.cli.CLI with the CLI instance as the only parameter. You should then call this superclass with that CLI instance, your command's name, and any other options desired.
See the implemention for other commands like swiftly.cli.auth.CLIAuth for good starting points.
Parameters: |
|
---|
Helper function that will convert an options list into a dict of key/values.
This is used for the quite common -hheader:value and -qparameter=value command line options, like this:
context.headers = self.options_list_to_lowered_dict(options.header)
context.query = self.options_list_to_lowered_dict(options.query)
For a full example, see swiftly.cli.get.CLIGet.__call__().
Helper method that will parse the args into options and remaining args as well as create an initial swiftly.cli.context.CLIContext.
The new context will be a copy of swiftly.cli.cli.CLI.context with the following attributes added:
muted_account_headers | The headers to omit when outputting account headers. |
muted_container_headers | The headers to omit when outputting container headers. |
muted_object_headers | The headers to omit when outputting object headers. |
Returns: | options, args, context |
---|
Bases: exceptions.Exception
Raise this to indicate the desire to exit.
Parameters: |
|
---|
Contains the CLIContext class used to pass contextual information to CLI functions.
Bases: object
Used to pass contextual information to CLI functions.
An instance of this class will allow almost any attribute access, even if that attribute did not previously exist. It offers an easy way to set new attributes on the fly for different use cases without having to create a whole new subclasses.
Returns a new CLIContext instance that is a shallow copy of the original, much like dict's copy method.
Convenience function to output headers in a formatted fashion to a file-like fp, optionally muting any headers in the mute list.
Contains a CLICommand for decrypting stdin to stdout.
Uses the following from swiftly.cli.context.CLIContext:
io_manager | For directing output. |
Bases: swiftly.cli.command.CLICommand
A CLICommand for decrypting stdin and sending that to stdout.
See the output of swiftly help decrypt for more information.
Decrypts context.io_manager's stdin and sends that to context.io_manager's stdout.
See swiftly.cli.decrypt for context usage information.
See CLIDecrypt for more information.
Contains a CLICommand that can issue DELETE requests.
Uses the following from swiftly.cli.context.CLIContext:
cdn | True if the CDN Management URL should be used instead of the Storage URL. |
client_manager | For connecting to Swift. |
concurrency | The number of concurrent actions that can be performed. |
headers | A dict of headers to send. |
ignore_404 | True if 404s should be silently ignored. |
io_manager | For directing output. |
query | A dict of query parameters to send. |
Bases: swiftly.cli.command.CLICommand
A CLICommand that can issue DELETE requests.
See the output of swiftly help delete for more information.
Deletes the item (account, container, or object) at the path.
See swiftly.cli.delete for context usage information.
See CLIDelete for more information.
Parameters: |
|
---|
Deletes all objects and containers in the account.
You must set yes_empty_account to True to verify you really want to do this.
By default, this will perform one pass at deleting all objects and containers; so if objects revert to previous versions or if new objects or containers otherwise arise during the process, the account may not be empty once done.
Set until_empty to True if you want multiple passes to keep trying to fully empty and delete the containers. Note until_empty=True could run forever if something else is making new items faster than they're being deleted.
See swiftly.cli.delete for context usage information.
See CLIDelete for more information.
Deletes all objects in the container.
By default, this will perform one pass at deleting all objects in the container; so if objects revert to previous versions or if new objects otherwise arise during the process, the container may not be empty once done.
Set until_empty to True if you want multiple passes to keep trying to fully empty the container. Note until_empty=True could run forever if something else is making new objects faster than they're being deleted.
See swiftly.cli.delete for context usage information.
See CLIDelete for more information.
Contains a CLICommand for encrypting stdin to stdout.
Uses the following from swiftly.cli.context.CLIContext:
io_manager | For directing output. |
Bases: swiftly.cli.command.CLICommand
A CLICommand for encrypting stdin and sending that to stdout.
This can be useful to encrypt to disk before attempting to upload, allowing uploads retries and segmented encrypted objects.
See the output of swiftly help encrypt for more information.
Encrypts context.io_manager's stdin and sends that to context.io_manager's stdout.
This can be useful to encrypt to disk before attempting to upload, allowing uploads retries and segmented encrypted objects.
See swiftly.cli.encrypt for context usage information.
See CLIEncrypt for more information.
Contains a CLICommand that can issue other commands for each item in an account or container listing.
Uses the following from swiftly.cli.context.CLIContext:
cdn | True if the CDN Management URL should be used instead of the Storage URL. |
client_manager | For connecting to Swift. |
concurrency | The number of concurrent actions that can be performed. |
headers | A dict of headers to send. |
ignore_404 | True if 404s should be silently ignored. |
io_manager | For directing output. |
query | A dict of query parameters to send. Of important use are limit, delimiter, prefix, marker, and end_marker as they are common listing query parameters. |
remaining_args | The list of command line args to issue to the sub-CLI instance; the first arg that equals '<item>' will be replaced with each item the for encounters. Any additional instances of '<item>' will be left alone, as you might be calling a nested "for ... do". |
original_main_args | Used when constructing sub-CLI instances. |
output_names | If True, outputs the name of each item just before calling [command] with it. To ensure easier parsing, the name will be url encoded and prefixed with "Item Name: ". For commands that have output of their own, this is usually only useful with single concurrency; otherwise the item names and the command output will get interspersed and impossible to associate. |
Bases: swiftly.cli.command.CLICommand
A CLICommand that can issue other commands for each item in an account or container listing.
See the output of swiftly help for for more information.
Issues commands for each item in an account or container listing.
See swiftly.cli.fordo for context usage information.
See CLIForDo for more information.
Contains a CLICommand that can issue GET requests.
Uses the following from swiftly.cli.context.CLIContext:
all_objects | True if instead of the listing itself you want all objects that the listing references to be output. |
cdn | True if the CDN Management URL should be used instead of the Storage URL. |
client_manager | For connecting to Swift. |
concurrency | The number of concurrent actions that can be performed. |
full | True if you want a full listing (additional information like object count, bytes used, and upload date) instead of just the item names. |
headers | A dict of headers to send. |
ignore_404 | True if 404s should be silently ignored. |
io_manager | For directing output. |
muted_account_headers | The headers to omit when outputting account response headers. |
muted_container_headers | The headers to omit when outputting container response headers. |
muted_object_headers | The headers to omit when outputting object response headers. |
output_headers | True if you want the headers from the response to also be output. |
query | A dict of query parameters to send. Of important use are limit, delimiter, prefix, marker, and end_marker as they are common listing query parameters. |
raw | Normally the result of the GET is translated as a listing and formatted output is generated. Setting this to True will skip any formatting a just output the raw contents from the response. Note that this will also just issue a single request and will not try additional follow-on marker requests. |
remove_empty_files | True if files created on disk should be removed if they result in an empty file. This can be useful with sub_commands that only output information for matches. |
suppress_container_name | True if files created on disk should have the container name stripped from the file name. When downloading a single container, this is usually desired. |
write_headers | A function used to output the response headers if output_headers is set True. |
Bases: swiftly.cli.command.CLICommand
A CLICommand that can issue GET requests.
See the output of swiftly help get for more information.
Performs a GET on the item (account, container, or object).
See swiftly.cli.get for context usage information.
See CLIGet for more information.
Performs a GET on the account as a listing request.
See swiftly.cli.get for context usage information.
See CLIGet for more information.
Performs a GET on the container as a listing request.
See swiftly.cli.get for context usage information.
See CLIGet for more information.
Contains a CLICommand that can issue HEAD requests.
Uses the following from swiftly.cli.context.CLIContext:
cdn | True if the CDN Management URL should be used instead of the Storage URL. |
client_manager | For connecting to Swift. |
headers | A dict of headers to send. |
ignore_404 | True if 404s should be silently ignored. |
io_manager | For directing output. |
muted_account_headers | The headers to omit when outputting account response headers. |
muted_container_headers | The headers to omit when outputting container response headers. |
muted_object_headers | The headers to omit when outputting object response headers. |
query | A dict of query parameters to send. |
write_headers | A function used to output the response headers. |
Bases: swiftly.cli.command.CLICommand
A CLICommand that can issue HEAD requests.
See the output of swiftly help head for more information.
Performs a HEAD on the item (account, container, or object).
See swiftly.cli.head for context usage information.
See CLIHead for more information.
Contains a CLICommand that outputs help information.
Uses the following from swiftly.cli.context.CLIContext:
io_manager | For directing output. |
Bases: swiftly.cli.command.CLICommand
A CLICommand that outputs help information.
See the output of swiftly help help for more information.
Outputs help information.
See swiftly.cli.help for context usage information.
See CLIHelp for more information.
Parameters: |
|
---|
Contains IOManager for managing access to input, output, error, and debug file-like objects.
Bases: object
Manages access to IO in ways that are mostly specific to swiftly.cli but might be generally useful.
Parameters: |
|
---|
Converts a client path into the operating system's path by replacing instances of '/' with os.path.sep.
Note: If the client path contains any instances of os.path.sep already, they will be replaced with '-'.
Returns a debug-output-suitable file-like object based on the optional os_path and optionally skipping any configured sub-command.
Returns a stderr-suitable file-like object based on the optional os_path and optionally skipping any configured sub-command.
Returns a stdin-suitable file-like object based on the optional os_path and optionally skipping any configured sub-command.
Returns a stdout-suitable file-like object based on the optional os_path and optionally skipping any configured sub-command.
Converts an operating system path into a client path by replacing instances of os.path.sep with '/'.
Note: If the client path contains any instances of '/' already, they will be replaced with '-'.
A context manager yielding a debug-output-suitable file-like object based on the optional os_path and optionally skipping any configured sub-command.
Parameters: |
|
---|
A context manager yielding a stderr-suitable file-like object based on the optional os_path and optionally skipping any configured sub-command.
Parameters: |
|
---|
A context manager yielding a stdin-suitable file-like object based on the optional os_path and optionally skipping any configured sub-command.
Parameters: |
|
---|
A context manager yielding a stdout-suitable file-like object based on the optional os_path and optionally skipping any configured sub-command.
Parameters: |
|
---|
Contains an extended optparse.OptionParser that works better with command line applications that may call other command line applications or use multiple parsers.
Bases: optparse.OptionParser, object
Extended optparse.OptionParser that supports an io_manager, raw_epilog output, and an error prefix. It also does not exit automatically on error and instead sets an instance bool of error_encountered.
Outputs the error msg to the file if specified, or to the io_manager's stderr if available, or to sys.stderr.
True if an error was encountered while parsing.
Output just before any error. This can be useful in identification when multiple parsers are in use.
Immediately exits Python with the given status (or 0) as the exit code and optionally outputs the msg using self.error.
Outputs help information to the file if specified, or to the io_manager's stdout if available, or to sys.stdout.
Outputs usage information to the file if specified, or to the io_manager's stdout if available, or to sys.stdout.
Outputs version information to the file if specified, or to the io_manager's stdout if available, or to sys.stdout.
Output just after the standard print_help output, in it's raw form. This is different than epilog in that epilog is reformatted.
Contains a CLICommand that implements ping test functionality.
Uses the following from swiftly.cli.context.CLIContext:
client_manager | For connecting to Swift. |
concurrency | The number of concurrent actions that can be performed. |
io_manager | For directing output. |
limit | The maximum number of Swift nodes to output information about. |
object_ring | An instance of swift.common.ring.ring.Ring if you want a report based on Swift nodes with implied usage during the ping test. |
ping_begin | The first time.time() when the entire ping test began. |
ping_begin_last | The time.time() the last ping task started. |
ping_count | The number of objects to use. |
ping_verbose | True if you want a full ping report rather than just the overall time. |
threshold | Defines the threshold for the threshold node report. This is the multiplier over the average request time. |
Bases: swiftly.cli.command.CLICommand
A CLICommand that implements ping test functionality.
See the output of swiftly help ping for more information.
Performs a ping test.
See swiftly.cli.ping for context usage information.
See CLIPing for more information.
Parameters: |
|
---|
Contains a CLICommand that can issue POST requests.
Uses the following from swiftly.cli.context.CLIContext:
cdn | True if the CDN Management URL should be used instead of the Storage URL. |
client_manager | For connecting to Swift. |
headers | A dict of headers to send. |
io_manager | For directing output. |
query | A dict of query parameters to send. |
Bases: swiftly.cli.command.CLICommand
A CLICommand that can issue POST requests.
See the output of swiftly help post for more information.
Performs a POST on the item (account, container, or object).
See swiftly.cli.post for context usage information.
See CLIPost for more information.
Parameters: |
|
---|
Contains a CLICommand that can issue PUT requests.
Uses the following from swiftly.cli.context.CLIContext:
cdn | True if the CDN Management URL should be used instead of the Storage URL. |
client_manager | For connecting to Swift. |
concurrency | The number of concurrent actions that can be performed. |
different | Set to True to check if the local file is different than an existing object before uploading. |
empty | Set to True if you wish to send an empty body with the PUT rather than reading from the io_manager's stdin. |
headers | A dict of headers to send. |
input_ | A string representing where input should be obtained from. If None, the io_manager's stdin will be used. If a directory path is specified, a set of PUTs will be generated for each item in the directory structure. If a file path is specified, that single file will be used as input. |
io_manager | For directing output and obtaining input if needed. |
newer | Set to True to check if the local file is newer than an existing object before uploading. |
query | A dict of query parameters to send. |
seek | Where to seek to in the input_ before uploading; usually just used by recursive calls with segmented objects. |
segment_size | The max size of a file before switching to a segmented object and the max size of each object segment. |
static_segments | Set to True to use static large object support instead of dynamic large object support. |
Bases: swiftly.cli.command.CLICommand
A CLICommand that can issue PUT requests.
See the output of swiftly help put for more information.
Performs a PUT on the item (account, container, or object).
See swiftly.cli.put for context usage information.
See CLIPut for more information.
Performs a PUT on the account.
See swiftly.cli.put for context usage information.
See CLIPut for more information.
Performs a PUT on the container.
See swiftly.cli.put for context usage information.
See CLIPut for more information.
Performs PUTs rooted at the path using a directory structure pointed to by context.input_.
See swiftly.cli.put for context usage information.
See CLIPut for more information.
Performs a PUT on the object.
See swiftly.cli.put for context usage information.
See CLIPut for more information.
Contains a CLICommand for generating TempURLs.
Uses the following from swiftly.cli.context.CLIContext:
io_manager | For directing output. |
client_manager | For connecting to Swift. |
Bases: swiftly.cli.command.CLICommand
A CLICommand for generating TempURLs.
See the output of swiftly help tempurl for more information.
Generates a TempURL and sends that to the context.io_manager's stdout.
See swiftly.cli.tempurl for context usage information.
See CLITempURL for more information.
Parameters: |
|
---|
Contains a CLICommand for translating transaction identifiers.
Uses the following from swiftly.cli.context.CLIContext:
io_manager | For directing output. |
Bases: swiftly.cli.command.CLICommand
A CLICommand for translating transaction identifiers.
See the output of swiftly help trans for more information.
Translates any information that can be determined from the x_trans_id and sends that to the context.io_manager's stdout.
See swiftly.cli.trans for context usage information.
See CLITrans for more information.
Contains tools for connecting to Swift services.
For convenience, the following names are imported from submodules:
StandardClient | swiftly.client.standardclient.StandardClient |
DirectClient | swiftly.client.directclient.DirectClient |
LocalClient | swiftly.client.localclient.LocalClient |
ClientManager | swiftly.client.manager.ClientManager |
generate_temp_url | swiftly.client.utils.generate_temp_url() |
get_trans_id_time | swiftly.client.utils.get_trans_id_time() |
Copyright 2011-2013 Gregory Holt Portions Copyright (c) 2010-2012 OpenStack Foundation
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
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.
Contains the base Client class for accessing Swift services.
Bases: object
The base class for accessing Swift services.
For concrete examples, see swiftly.client.standardclient.StandardClient and swiftly.client.directclient.DirectClient.
To form a new concrete subclass, you would need to implement request() and get_account_hash() minimally and optionally reset() and auth().
Just performs any authentication steps without making an actual request to the Swift system.
Sends a DELETE request to the account and returns the results.
With query['bulk-delete'] = '' this might mean a bulk delete request where the body of the request is new-line separated, url-encoded list of names to delete. Be careful with this! One wrong move and you might mark your account for deletion of you have the access to do so!
For a plain DELETE to the account, on clusters that support it and, assuming you have permissions to do so, the account will be marked as deleted and immediately begin removing the objects from the cluster in the backgound.
THERE IS NO GOING BACK!
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | A tuple of (status, reason, headers, contents).
|
DELETEs the container and returns the results.
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | A tuple of (status, reason, headers, contents).
|
DELETEs the object and returns the results.
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | A tuple of (status, reason, headers, contents).
|
GETs the account and returns the results. This is done to list the containers for the account. Some useful headers are also returned:
x-account-bytes-used | Object storage used for the account, in bytes. |
x-account-container-count | The number of containers in the account. |
x-account-object-count | The number of objects in the account. |
Also, any user headers beginning with x-account-meta- are returned.
These values can be delayed depending the Swift cluster.
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | A tuple of (status, reason, headers, contents).
|
Returns the account identifier for the Swift account being accessed.
GETs the container and returns the results. This is done to list the objects for the container. Some useful headers are also returned:
x-container-bytes-used | Object storage used for the container, in bytes. |
x-container-object-count | The number of objects in the container. |
Also, any user headers beginning with x-container-meta- are returned.
These values can be delayed depending the Swift cluster.
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | A tuple of (status, reason, headers, contents).
|
GETs the object and returns the results.
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | A tuple of (status, reason, headers, contents).
|
HEADs the account and returns the results. Useful headers returned are:
x-account-bytes-used | Object storage used for the account, in bytes. |
x-account-container-count | The number of containers in the account. |
x-account-object-count | The number of objects in the account. |
Also, any user headers beginning with x-account-meta- are returned.
These values can be delayed depending the Swift cluster.
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | A tuple of (status, reason, headers, contents).
|
HEADs the container and returns the results. Useful headers returned are:
x-container-bytes-used | Object storage used for the container, in bytes. |
x-container-object-count | The number of objects in the container. |
Also, any user headers beginning with x-container-meta- are returned.
These values can be delayed depending the Swift cluster.
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | A tuple of (status, reason, headers, contents).
|
HEADs the object and returns the results.
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | A tuple of (status, reason, headers, contents).
|
These HTTP methods do not allow contents
POSTs the account and returns the results. This is usually done to set X-Account-Meta-xxx headers. Note that any existing X-Account-Meta-xxx headers will remain untouched. To remove an X-Account-Meta-xxx header, send the header with an empty string as its value.
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | A tuple of (status, reason, headers, contents).
|
POSTs the container and returns the results. This is usually done to set X-Container-Meta-xxx headers. Note that any existing X-Container-Meta-xxx headers will remain untouched. To remove an X-Container-Meta-xxx header, send the header with an empty string as its value.
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | A tuple of (status, reason, headers, contents).
|
POSTs the object and returns the results. This is used to update the object's header values. Note that all headers must be sent with the POST, unlike the account and container POSTs. With account and container POSTs, existing headers are untouched. But with object POSTs, any existing headers are removed. The full list of supported headers depends on the Swift cluster, but usually include Content-Type, Content-Encoding, and any X-Object-Meta-xxx headers.
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | A tuple of (status, reason, headers, contents).
|
PUTs the account and returns the results. This is usually done with the extract-archive bulk upload request and has no other use I know of (but the call is left open in case there ever is).
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | A tuple of (status, reason, headers, contents).
|
PUTs the container and returns the results. This is usually done to create new containers and can also be used to set X-Container-Meta-xxx headers. Note that if the container already exists, any existing X-Container-Meta-xxx headers will remain untouched. To remove an X-Container-Meta-xxx header, send the header with an empty string as its value.
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | A tuple of (status, reason, headers, contents).
|
PUTs the object and returns the results. This is used to create or overwrite objects. X-Object-Meta-xxx can optionally be sent to be stored with the object. Content-Type, Content-Encoding and other standard HTTP headers can often also be set, depending on the Swift cluster.
Note that you can set the ETag header to the MD5 sum of the contents for extra verification the object was stored correctly.
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | A tuple of (status, reason, headers, contents).
|
Performs a direct HTTP request to the Swift service.
Parameters: |
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Returns: | A tuple of (status, reason, headers, contents).
|
Resets the client, closing any connections and discarding any state. This can be useful if some exceptional condition occurred and the request/response state can no longer be certain.
The string to use for the User-Agent request header.
Provides a direct client by using loaded Swift Proxy Server code to work with Swift.
Bases: swiftly.client.client.Client
Direct client by using loaded Swift Proxy Server code to work with Swift.
Parameters: |
|
---|
A client that uses the local file system pretending to be Swift.
Bases: swiftly.client.client.Client
A client that uses the local file system pretending to be Swift.
Note
This is a really early implementation and no-ops a lot of stuff. With time it will become a more complete representation.
Parameters: |
|
---|
The list of strings in names to substitute for.
Provides a local in-memory memcache client lookalike for use with Swift Proxy Server code. This can also be used as a WSGI app with the Brim.Net Core Package.
See swift.common.memcached.MemcacheRing for what this is acting as.
Bases: object
Contains the ClientManager class that can be used to manage a set of clients.
Bases: object
Can be used to manage a set of clients.
Parameters: |
|
---|
Obtains a client for use, whether an existing unused client or a brand new one if none are available.
Returns a client back into the pool for availability to future calls to get_client. This should only be called if get_client was used to obtain the client; with_client is a context manager that does this for you.
A context manager that obtains a client for use, whether an existing unused client or a brand new one if none are available.
Provides a logger lookalike that throws away everything sent to it for use with Swift Proxy Server code.
See swift.common.utils.LogAdapter for what this is acting as.
Bases: object
Provides the standard client for accessing Swift services.
Bases: swiftly.client.client.Client
The standard client for accessing Swift services.
Parameters: |
|
---|
Contains general tools useful when accessing Swift services.
Returns a TempURL good for the given request method, url, and number of seconds from now, signed by the given key.
Returns the time.time() embedded in the trans_id or None if no time information is embedded.
Copied from the Swift codebase. Copyright (c) 2010-2012 OpenStack Foundation
Converts a sequence of (name, value) tuples into a dict where if a given name occurs more than once its value in the dict will be a list of values.
Much like parse.quote in that it returns a URL encoded string for the given value, protecting the safe characters; but this version also ensures the value is UTF-8 encoded.
Concurrency API for Swiftly.
Copyright 2011-2013 Gregory Holt
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
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.
Bases: object
Convenience class to support concurrency, if Eventlet is available; otherwise it just performs at single concurrency.
Parameters: | concurrency -- The level of concurrency desired. Default: 10 |
---|
Returns a dict of the results currently available. The keys are the ident values given with the calls to spawn. The values are tuples of (exc_type, exc_value, exc_tb, result) where:
exc_type | The type of any exception raised. |
exc_value | The actual exception if any was raised. |
exc_tb | The traceback if any exception was raised. |
result | If no exception was raised, this will be the return value of the called function. |
Blocks until all currently pending functions have finished.
Returns immediately to the caller and begins executing the func in the background. Use get_results and the ident given to retrieve the results of the func. If the func causes an exception, this exception will be caught and the sys.exc_info() will be returned via get_results.
Parameters: |
|
---|---|
Returns: | None |
Encryption routines for Swiftly.
Requires PyCrypto 2.6.1 or greater. <https://www.dlitz.net/software/pycrypto/>
Copyright 2013 Gregory Holt
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
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.
Constant that can be used a preamble for algorithm detection.
Generator that decrypts a content stream using AES 256 in CBC mode.
Parameters: |
|
---|
Generator that encrypts a content stream using AES 256 in CBC mode.
Parameters: |
|
---|
Wraps an iterable to behave as a file-like object.
Copyright (c) 2010-2012 OpenStack Foundation
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
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.
Bases: object
Wraps an iterable to behave as a file-like object.
Taken from work I did for OpenStack Swift swift.common.utils.FileLikeIter, Copyright (c) 2010-2012 OpenStack Foundation.
Sets data attribute .closed to True. A closed file cannot be used for further I/O operations. close() may be called more than once without error. Some kinds of file objects (for example, opened by popen()) may return an exit status upon closing.
Check whether the "file" is empty reading the single byte.
If the size argument is negative or omitted, read until EOF is reached. Notice that when in non-blocking mode, less data than what was requested may be returned, even if no size parameter was given.
Retain newline. A non-negative size argument limits the maximum number of bytes to return (an incomplete line may be returned then). Return an empty string at EOF.
Call readline() repeatedly and return a list of the lines so read. The optional size argument, if given, is an approximate bound on the total number of bytes in the lines returned.
Resets the limit.