IcsS3 Common Library

IcsS3: Library for S3

This is the IcsS3 common library.
class opslib.icss3.IcsS3(**kwargs)[source]

ICS Library for S3

__init__(**kwargs)[source]
__module__ = 'opslib.icss3'
add_rule(id=None, prefix=None, status=None, expiration=None, transition=None)[source]

Add a rule to this Lifecycle configuration. This only adds the rule to the local copy. To install the new rule(s) on the bucket, you need to pass this Lifecycle config object to the configure_lifecycle method of the Bucket object.

Parameters:
  • id (str) – Unique identifier for the rule. The value cannot be longer than 255 characters.
  • status (str) – If ‘Enabled’, the rule is currently being applied. If ‘Disabled’, the rule is not currently being applied.
  • expiration (int) – Indicates the lifetime, in days, of the objects that are subject to the rule. The value must be a non-zero positive integer. A Expiration object instance is also perfect.
  • transition (Transition) – Indicates when an object transitions to a different storage class.
Iparam prefix:

Prefix identifying one or more objects to which the rule applies.

batch_download(uri, pattern='', dirname=None)[source]

Batch download files from S3 (only for current folder)

Parameters:
  • url (str) – File URL in S3, like s3://bucket/path
  • pattern (string) – regrex expression to match
  • dirname (string) – local path to save, ‘None’ by default
Return type:

list

Returns:

a list containing dowloaded file path

configure_s3rule(bucket, rules=None)[source]
Parameters:
  • bucket (object) – the boto object of S3 bucket
  • rules (dict) – describes the lifecycle rules
Return type:

list

Returns:

a list of results

create_bucket(bucket_name, headers=None, location='us-west-2', policy=None)[source]

Creates a new located bucket. By default it’s in the USA.

Parameters:
  • bucket_name (string) – The name of the new bucket
  • headers (dict) – Additional headers to pass along with the request to AWS.
  • location (str) – The location of the new bucket, like “us-west-2”
  • policy (boto.s3.acl.CannedACLStrings) – A canned ACL policy that will be applied to the new key in S3.
download_file(uri, fp)[source]

Download a file from S3

Parameters:
  • url (str) – File URL in S3, like s3://bucket/path
  • fp (file) – file descriptor from local file
Return type:

string

Returns:

a string containing dowloaded file name

get_file_as_string(uri)[source]

Get a file as string from S3

Parameters:url (str) – File URL in S3, like s3://bucket/path
Return type:string
Returns:a string containing dowloaded file content
recursive_download(uri, pattern='', dirname=None)[source]

Recursive download files from S3

Parameters:
  • url (str) – File URL in S3, like s3://bucket/path
  • pattern (string) – regrex expression to match
  • dirname (string) – local path to save, ‘None’ by default
Return type:

list

Returns:

a list containing dowloaded file path

Indices and tables

Read the Docs v: latest
Versions
latest
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.