S3 operations.
pip install kwrappers-s3ops==0.2.79
A central repository for high level wrappers of AWS tasks. It is intended to be used as a python library. It should include any operations that:
It is foreseeable that this library becomes quite large and as such no noob user front end will be provided however it should be useful for informed users either, wishing to perform complex AWS automation or, writing CLI applications for their noobs to use.
pip install kwrappers
from kwrappers.util import Session
session = Session()
s3 = session.client('s3')
[b['Name'] for b in s3.list_buckets()['Buckets']]
from kwrappers.util import Session
from kwrappers.s3ops.general import TransferConfig, Transfer, ProgressPercentage
# 1. Get a session
# Get TOKEN ASSUMED_ROLE and MFA_SERIAL
role = "arn:aws:iam::167464700695:role/Demo-StackCreator"
mfa_serial = "arn:aws:iam::623551153426:mfa/IAM-T.Elson"
session = Session('ap-southeast-2', role=role, mfa_serial=mfa_serial, mfa_token='111222')
s3 = session.client('s3', 'ap-southeast-2')
# 2. Define to file for upload
file_name = '~/Downloads/Slack-2.8.2-macOS.zip'
bucket_name = 'khasha'
target_file_name = 'foo'
# 3. Define the setting for the transfer
config = TransferConfig(
multipart_threshold=8 * 1024 * 1024,
max_request_concurrency=4,
num_download_attempts=10,
max_bandwidth=15 * 1024, # Bytes/s
)
# 4. Carry out the transfer
transfer = Transfer(s3, config)
transfer.upload_file(
file_name,
bucket_name,
target_file_name,
callback=ProgressPercentage(file_name)
)
./dev_install.sh
pip install -r requirements_test.txt
Lint and test before committing code. The build system will fail if either of these steps fail:
pytest
flake8 --ignore=E501
To build a new version and upload to PyPi ensure these steps pass.
Write tests for new code. See current tests for examples. Use pytest
to run all tests.