Most viewed recipes tagged "aws"http://code.activestate.com/recipes/tags/aws/views/2014-11-06T18:31:44-08:00ActiveState Code RecipesUrllib handler for Amazon S3 buckets (Python)
2014-11-06T18:31:44-08:00Andrea Corbellinihttp://code.activestate.com/recipes/users/4186880/http://code.activestate.com/recipes/578957-urllib-handler-for-amazon-s3-buckets/
<p style="color: grey">
Python
recipe 578957
by <a href="/recipes/users/4186880/">Andrea Corbellini</a>
(<a href="/recipes/tags/aws/">aws</a>, <a href="/recipes/tags/s3/">s3</a>, <a href="/recipes/tags/urllib/">urllib</a>).
</p>
<p>This is a handler for the standard <a href="https://docs.python.org/dev/library/urllib.request.html">urllib.request</a> module capable of opening buckets stored on <a href="http://aws.amazon.com/s3/">Amazon S3</a>.</p>
<p>Here is an usage example:</p>
<pre class="prettyprint"><code>>>> from urllib.request import build_opener
>>> opener = build_opener(S3Handler)
>>> response = opener.open('s3://bucket-name/key-name')
>>> response.read()
b'contents'
</code></pre>
Amazon SNS handler for the logging module (Python)
2014-11-06T17:32:26-08:00Andrea Corbellinihttp://code.activestate.com/recipes/users/4186880/http://code.activestate.com/recipes/578956-amazon-sns-handler-for-the-logging-module/
<p style="color: grey">
Python
recipe 578956
by <a href="/recipes/users/4186880/">Andrea Corbellini</a>
(<a href="/recipes/tags/aws/">aws</a>, <a href="/recipes/tags/logging/">logging</a>, <a href="/recipes/tags/sns/">sns</a>).
Revision 2.
</p>
<p>This is a handler for the standard <a href="https://docs.python.org/library/logging.html">logging</a> module that sends notifications to the <a href="http://aws.amazon.com/sns/">Amazon Simple Notification Service</a>.</p>
<p>You can use it like so:</p>
<pre class="prettyprint"><code>logging.config.dictConfig({
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d '
'%(thread)d %(message)s',
},
'simple': {
'format': '%(levelname)s %(message)s',
},
},
'handlers': {
'sns': {
'level': 'INFO',
'class': 'SNSHandler',
'formatter': 'verbose',
'topic_arn': 'YOUR SNS TOPIC ARN',
},
},
'loggers': {
'YOUR MODULE': {
'handlers': ['sns'],
'level': 'INFO',
'propagate': True,
},
},
}
</code></pre>