Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • gmr/tornado-aws
1 result
Show changes
Commits on Source (6)
Loading
Loading
@@ -11,6 +11,9 @@ python:
before_install:
- docker run -d --name=dynalite -p 8000:8000 rajatvig/dynalite-alpine:latest
- docker run -d --name=s3 -p 4567:4567 verespej/fake-s3:latest
env:
DYNAMODB_ENDPOINT: http://localhost:8000
S3_ENDPOINT: http://localhost:4567
install:
- pip install -r requires/testing.txt
script: nosetests
Loading
Loading
#!/bin/sh
#
# NAME
# bootstrap -- initialize/update docker environment
#
# SYNOPSIS
# bootstrap
# bootstrap shellinit
#
# DESCRIPTION
# Execute this script without parameters to build the local docker
# environment. Once bootstrapped, dependent services are running
# via docker-compose and the environment variables are written to
# *build/test-environment* for future use.
#
# Running this script with the _shellinit_ command line parameter
# causes it to simply interrogate the running docker environment,
# update *build/test-environment*, and print the environment to
# the standard output stream in a shell executable manner. This
# makes the following pattern for setting environment variables
# in the current shell work.
#
# prompt% $(./bootstrap shellinit)
#
# vim: set ts=2 sts=2 sw=2 et:
if test -e /var/run/docker.sock
then
DOCKER_IP=127.0.0.1
else
echo "Failed to initialize docker environment"
exit 2
fi
get_exposed_port() {
docker-compose port $1 $2 | cut -d: -f2
}
build_env_file() {
cat > $1<<EOF
export DYNAMODB_ENDPOINT=http://${DOCKER_IP}:$(get_exposed_port dynalite 8000)
export S3_ENDPOINT=http://${DOCKER_IP}:$(get_exposed_port s3 4567)
EOF
}
set -e
mkdir -p build
if test "$1" = 'shellinit'
then
# just build the environment file from docker containers
build_env_file build/test-environment
else
docker-compose down --volumes --remove-orphans
docker-compose up -d
build_env_file build/test-environment
fi
cat build/test-environment
dynalite:
image: rajatvig/dynalite-alpine:latest
ports:
- 8000:8000
- 8000
 
s3:
image: verespej/fake-s3:latest
ports:
- 4567:4567
- 4567
Loading
Loading
@@ -3,6 +3,11 @@
Version History
===============
 
1.0.0 (2018-01-19)
------------------
- Add new exception type ``tornado_aws.exceptions.RequestException`` (#5 from `nvllsvm <https://github.com/nvllsvm>_`)
- Mark as stable in Trove classifiers
0.8.0 (2017-06-06)
------------------
- Rework error processing to support ``application/json``,
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@ tornado-aws
===========
``tornado-aws`` is a low-level Amazon Web Services API client for Tornado.
 
|Version| |Downloads| |Status| |Coverage| |License|
|Version| |Status| |Coverage| |License|
 
Contents:
 
Loading
Loading
@@ -43,8 +43,5 @@ Indices and tables
.. |Coverage| image:: https://img.shields.io/codecov/c/github/gmr/tornado-aws.svg?
:target: https://codecov.io/github/gmr/tornado-aws?branch=master
 
.. |Downloads| image:: https://img.shields.io/pypi/dm/tornado-aws.svg?
:target: https://pypi.python.org/pypi/tornado-aws
.. |License| image:: https://img.shields.io/pypi/l/tornado-aws.svg?
:target: https://tornado-aws.readthedocs.org
from os import path
import setuptools
 
CLASSIFIERS = ['Development Status :: 4 - Beta',
CLASSIFIERS = ['Development Status :: 5 - Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
Loading
Loading
@@ -39,7 +39,7 @@ def read_requirements(name):
 
setuptools.setup(
name='tornado-aws',
version='0.8.0',
version='1.0.0',
description=DESC,
long_description=open('README.rst').read(),
author='Gavin M. Roy',
Loading
Loading
Loading
Loading
@@ -393,7 +393,7 @@ class ClientFetchTestCase(MockTestCase):
with mock.patch.object(obj._client, 'fetch') as fetch:
fetch.side_effect = OSError()
body = json.dumps({'foo': 'bar'})
with self.assertRaises(exceptions.AWSClientException):
with self.assertRaises(exceptions.RequestException):
obj.fetch('POST', '/', body=body)
 
def test_fetch_no_headers(self):
Loading
Loading
@@ -636,7 +636,7 @@ class AsyncClientFetchTestCase(MockTestCase, utils.AsyncHTTPTestCase):
future = concurrent.Future()
future.set_exception(OSError)
fetch.return_value = future
with self.assertRaises(exceptions.AWSClientException):
with self.assertRaises(exceptions.RequestException):
yield obj.fetch('GET', '/api')
 
 
Loading
Loading
Loading
Loading
@@ -24,6 +24,9 @@ CREATE_BUCKET_BODY = """\
</CreateBucketConfiguration>
"""
 
DYNAMODB_ENDPOINT = os.environ['DYNAMODB_ENDPOINT']
S3_ENDPOINT = os.environ['S3_ENDPOINT']
 
class DynamoDBTestCase(testing.AsyncTestCase):
 
Loading
Loading
@@ -84,7 +87,7 @@ class DynamoDBTestCase(testing.AsyncTestCase):
os.environ['AWS_SECRET_ACCESS_KEY'] = str(uuid.uuid4())
os.environ['AWS_DEFAULT_REGION'] = 'local'
self.client = tornado_aws.AsyncAWSClient(
'dynamodb', endpoint='http://localhost:8000')
'dynamodb', endpoint=DYNAMODB_ENDPOINT)
 
@testing.gen_test
def test_create_table(self):
Loading
Loading
@@ -111,7 +114,7 @@ class UseCurlDynamoDBTestCase(DynamoDBTestCase):
os.environ['AWS_SECRET_ACCESS_KEY'] = str(uuid.uuid4())
os.environ['AWS_DEFAULT_REGION'] = 'local'
self.client = tornado_aws.AsyncAWSClient(
'dynamodb', endpoint='http://localhost:8000', use_curl=True)
'dynamodb', endpoint=DYNAMODB_ENDPOINT, use_curl=True)
 
@unittest.skipIf(curl_httpclient is None, 'pycurl not installed')
def test_create_table(self):
Loading
Loading
@@ -141,7 +144,7 @@ class S3TestCase(testing.AsyncTestCase):
os.environ['AWS_SECRET_ACCESS_KEY'] = str(uuid.uuid4())
os.environ['AWS_DEFAULT_REGION'] = 'local'
self.client = tornado_aws.AsyncAWSClient(
's3', endpoint='http://localhost:4567')
's3', endpoint=S3_ENDPOINT)
self.bucket = uuid.uuid4().hex
self.headers = {'Host': '{}.s3.amazonaws.com'.format(self.bucket)}
 
Loading
Loading
Loading
Loading
@@ -6,6 +6,6 @@ from tornado_aws.client import AWSClient
from tornado_aws.client import AsyncAWSClient
from tornado_aws.client import exceptions
 
__version__ = '0.8.0'
__version__ = '1.0.0'
 
__all__ = ['AWSClient', 'AsyncAWSClient', 'exceptions']
Loading
Loading
@@ -171,7 +171,7 @@ class AWSClient(object):
return result
except (OSError, socket.error) as error:
LOGGER.error('Error making request: %s', error)
raise exceptions.AWSClientException()
raise exceptions.RequestException(error=error)
except httpclient.HTTPError as error:
need_credentials, aws_error = self._process_error(error)
if need_credentials and not self._auth_config.local_credentials:
Loading
Loading
@@ -601,7 +601,7 @@ class AsyncAWSClient(AWSClient):
future.set_exception(aws_error if aws_error else exception)
else:
LOGGER.error('Error making request: %s', exception)
future.set_exception(exceptions.AWSClientException())
future.set_exception(exceptions.RequestException(error=exception))
else:
future.set_result(response.result())
 
Loading
Loading
Loading
Loading
@@ -69,3 +69,12 @@ class NoProfileError(AWSClientException):
 
"""
fmt = 'Profile ({profile}) not found ({path})'
class RequestException(AWSClientException):
"""Raised when a request failed due to a network issue.
:ivar error: The error which occured
"""
fmt = 'An error occured making a request {error}'