dj-libcloud Documentation

Similar documents
Roman Numeral Converter Documentation

Python wrapper for Viscosity.app Documentation

TPS Documentation. Release Thomas Roten

Python Project Example Documentation

chatterbot-weather Documentation

Python simple arp table reader Documentation

PyCRC Documentation. Release 1.0

django-idioticon Documentation

Aircrack-ng python bindings Documentation

I2C LCD Documentation

sainsmart Documentation

Simple libtorrent streaming module Documentation

django-cas Documentation

django-reinhardt Documentation

Django Wordpress API Documentation

google-search Documentation

Release Nicholas A. Del Grosso

Poulpe Documentation. Release Edouard Klein

DNS Zone Test Documentation

Release Fulfil.IO Inc.

Redis Timeseries Documentation

Simple Binary Search Tree Documentation

Pykemon Documentation

django-users2 Documentation

OpenUpgrade Library Documentation

Python Schema Generator Documentation

Mantis STIX Importer Documentation

smartfilesorter Documentation

Google Domain Shared Contacts Client Documentation

Python AMT Tools Documentation

Game Server Manager Documentation

gunny Documentation Release David Blewett

open-helpdesk Documentation

eventbrite-sdk-python Documentation

Python State Machine Documentation

django CMS Export Objects Documentation

withenv Documentation

django-telegram-bot Documentation

django-private-chat Documentation

Frontier Documentation

pydrill Documentation

doconv Documentation Release Jacob Mourelos

django-responsive2 Documentation

smsghussd Documentation

Python AutoTask Web Services Documentation

Aldryn Installer Documentation

nacelle Documentation

e24paymentpipe Documentation

pyldavis Documentation

Release Ralph Offinger

Python State Machine Documentation

Poetaster. Release 0.1.1

AnyDo API Python Documentation

django-composite-foreignkey Documentation

PyZillow Documentation

API Wrapper Documentation

django-composite-foreignkey Documentation

yardstick Documentation

Python data pipelines similar to R Documentation

gpib-ctypes Documentation

django-bootstrap3 Documentation

PyCon APAC 2014 Documentation

django-stored-messages Documentation

syslog-ng Apache Kafka destination

Job Submitter Documentation

ejpiaj Documentation Release Marek Wywiał

dublincore Documentation

Gearthonic Documentation

xmljson Documentation

CID Documentation. Release Francis Reyes

Dragon Mapper Documentation

Airoscript-ng Documentation

pvl Documentation Release William Trevor Olson

ProxySQL Tools Documentation

dicompyler-core Documentation

invenio-formatter Documentation

lazy-object-proxy Release 1.3.1

invenio-groups Documentation

Infoblox Client Documentation

Python Finite State Machine. Release 0.1.5

xmodels Documentation

cwmon-mysql Release 0.5.0

Microlab Instruments Documentation

OTX to MISP. Release 1.4.2

Durga Documentation. Release dev2. transcode

Connexion Sqlalchemy Utils Documentation

pytest-benchmark Release 2.5.0

Archan. Release 2.0.1

Release Manu Phatak

django mail admin Documentation

Face Recognition Documentation

MT940 Documentation. Release Rick van Hattem (wolph)

redis-lock Release 3.2.0

contribution-guide.org Release

Django MFA Documentation

otree Virtual Machine Manager Documentation

Lazarus Documentation

mozilla-django-oidc Documentation

django simple pagination Documentation

timegate Documentation

Transcription:

dj-libcloud Documentation Release 0.2.0 Daniel Greenfeld December 19, 2016

Contents 1 dj-libcloud 3 1.1 Documentation.............................................. 3 1.2 Quickstart................................................ 3 1.3 Other LibCloud Providers........................................ 4 1.4 Features.................................................. 4 1.5 FAQ.................................................... 4 1.6 CREDIT................................................. 4 2 Cookbook 5 2.1 Amazon.................................................. 5 2.2 Google Cloud Storage.......................................... 5 2.3 Rackspace Cloudfiles........................................... 6 2.4 Microsoft Azure............................................. 6 2.5 Using django-pipeline.......................................... 6 3 Contributing 7 3.1 Types of Contributions.......................................... 7 3.2 Get Started!................................................ 8 3.3 Pull Request Guidelines......................................... 8 3.4 Tips.................................................... 9 4 Credits 11 4.1 Development Lead............................................ 11 4.2 Contributors............................................... 11 5 History 13 5.1 0.2.0(2014-06-23)............................................ 13 5.2 0.1.2 (2014-04-24)............................................ 13 5.3 0.1.1 (2014-04-21)............................................ 13 5.4 0.1.0 (2014-04-21)............................................ 13 i

ii

dj-libcloud Documentation, Release 0.2.0 Contents: Contents 1

dj-libcloud Documentation, Release 0.2.0 2 Contents

CHAPTER 1 dj-libcloud Adds easy python 3 and 2.7 support to Django for management of static assets. This is a wrapper around the excellent Apache Libcloud library. 1.1 Documentation The full documentation is at https://dj-libcloud.readthedocs.org. 1.2 Quickstart Libcloud verifies server SSL certificates before it lets you do anything. It will search your system for the CA certificate, and if it doesn t find it then it will blow up. See https://libcloud.readthedocs.org/en/latest/other/ssl-certificatevalidation.html Installing CA certificate bundle on Mac OS X: # Assuming you are using homebrew for Mac OS X dependency management. $ brew install curl-ca-bundle Install dj-libcloud: $ pip install dj-libcloud Then use it in a project, e.g. for your static files: # settings.py STATIC_URL = 'https://s3.amazonaws.com/my-assets/' STATICFILES_STORAGE = 'djlibcloud.storage.libcloudstorage' LIBCLOUD_PROVIDERS = { 'default': { 'type': 'libcloud.storage.types.provider.s3', 'user': os.environ.get('aws_access_key'), 'key': os.environ.get('aws_secret_key'), 'bucket': 'my-assets', 'secure': True, }, } 3

dj-libcloud Documentation, Release 0.2.0 1.3 Other LibCloud Providers If you want to use other libcloud providers (Rackspace, Openstack, other AWS centers, et al), please visit: The libcloud list of supported providers The dj-libcloud cookbook. 1.4 Features Works for uploading media assets using Python 3.3 and Django 1.6. In theory supports all the backends that libcloud supports. 1.5 FAQ Because you just had to ask. 1.5.1 Why not use dj-static or whitenoise? Those are great libraries, but are not what you want when handling user uploaded media. 1.5.2 Why not just update django-storages? libcloud is awesome and has a dedicated team devoted to it. We can have it do most of the heavy lifting. On the other hand, converting django-storages to work with Python 3 looked like too much work. Sometimes you just have to start anew, right? 1.5.3 What storage providers does dj-libcloud support? dj-libcloud is a wrapper around libcloud, meaning it supports all the providers of that library. Check out the full list of supported providers! 1.5.4 How can I contribute? Please read http://dj-libcloud.readthedocs.org/en/latest/contributing.html 1.5.5 What about compressors like django-pipeline? Working on it. Currently the PipelineCachedCloudStorage class breaks the second time you run it. See https://github.com/pydanny/dj-libcloud/issues/7 1.6 CREDIT Many thanks to Jannis Leidel (@jezdez) for giving me the code to get this started. He s a Django core developer, the master of Django static asset managment, and overall a great great guy. 4 Chapter 1. dj-libcloud

CHAPTER 2 Cookbook 2.1 Amazon 2.1.1 Using eu-west-1 STATIC_URL = 'https://s3-eu-west-1.amazonaws.com/my-assets/' STATICFILES_STORAGE = 'djlibcloud.storage.libcloudstorage' LIBCLOUD_PROVIDERS = { 'amazon_s3_eu_west': { 'type': 'libcloud.storage.types.provider.s3_eu_west', 'user': os.environ.get('aws_access_key'), 'key': os.environ.get('aws_secret_key'), 'bucket': 'my-assets', 'secure': True, }, } DEFAULT_LIBCLOUD_PROVIDER = 'amazon_s3_eu_west' 2.2 Google Cloud Storage STATIC_URL = 'https://storage.googleapis.com/my-assets/' STATICFILES_STORAGE = 'djlibcloud.storage.libcloudstorage' LIBCLOUD_PROVIDERS = { 'google_cloud_storage': { 'type': 'libcloud.storage.types.provider.google_storage', 'user': os.environ.get('google_access_key'), 'key': os.environ.get('google_secret_key'), 'bucket': 'my-assets', 'secure': True, }, } DEFAULT_LIBCLOUD_PROVIDER = 'google_cloud_storage' 5

dj-libcloud Documentation, Release 0.2.0 2.3 Rackspace Cloudfiles STATIC_URL = 'https://<long>-<hash>.ssl.cf5.rackcdn.com' STATICFILES_STORAGE = 'djlibcloud.storage.libcloudstorage' LIBCLOUD_PROVIDERS = { 'rackspace_cloudfiles': { 'type': 'libcloud.storage.types.provider.cloudfiles', 'user': os.environ.get('rackspace_user_name'), 'key': os.environ.get('rackspace_api_key'), 'bucket': 'my-assets', 'secure': True, }, } DEFAULT_LIBCLOUD_PROVIDER = 'rackspace_cloudfiles' 2.4 Microsoft Azure AZURE_ACCOUNT_NAME = os.environ.get('azure_account_name') STATIC_URL = 'https://%s.blob.core.windows.net/my-assets/' % AZURE_ACCOUNT_NAME STATICFILES_STORAGE = 'djlibcloud.storage.libcloudstorage' LIBCLOUD_PROVIDERS = { 'microsoft_azure': { 'type': 'libcloud.storage.types.provider.azure_blobs', 'user': AZURE_ACCOUNT_NAME, 'key': os.environ.get('azure_account_key'), 'bucket': 'my-assets', 'secure': True, }, } DEFAULT_LIBCLOUD_PROVIDER = 'microsoft_azure' 2.5 Using django-pipeline # core/storage.py from djlibcloud.storage import LibCloudStorage from pipeline.storage import PipelineMixin class PipelineCloudStorage(PipelineMixin, LibCloudStorage): """ UNTESTED! """ pass # settings.py STATICFILES_STORAGE = 'core.storage.pipelinecloudstorage' 6 Chapter 2. Cookbook

CHAPTER 3 Contributing Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given. You can contribute in many ways: 3.1 Types of Contributions 3.1.1 Report Bugs Report bugs at https://github.com/pydanny/dj-libcloud/issues. If you are reporting a bug, please include: Your operating system name and version. Any details about your local setup that might be helpful in troubleshooting. Detailed steps to reproduce the bug. 3.1.2 Fix Bugs Look through the GitHub issues for bugs. Anything tagged with bug is open to whoever wants to implement it. 3.1.3 Implement Features Look through the GitHub issues for features. Anything tagged with feature is open to whoever wants to implement it. 3.1.4 Write Documentation dj-libcloud could always use more documentation, whether as part of the official dj-libcloud docs, in docstrings, or even on the web in blog posts, articles, and such. 3.1.5 Submit Feedback The best way to send feedback is to file an issue at https://github.com/pydanny/dj-libcloud/issues. If you are proposing a feature: 7

dj-libcloud Documentation, Release 0.2.0 Explain in detail how it would work. Keep the scope as narrow as possible, to make it easier to implement. Remember that this is a volunteer-driven project, and that contributions are welcome :) 3.2 Get Started! Ready to contribute? Here s how to set up dj-libcloud for local development. 1. Fork the dj-libcloud repo on GitHub. 2. Clone your fork locally: $ git clone git@github.com:your_name_here/dj-libcloud.git 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development: $ mkvirtualenv dj-libcloud $ cd dj-libcloud/ $ python setup.py develop 4. Create a branch for local development: $ git checkout -b name-of-your-bugfix-or-feature Now you can make your changes locally. 5. When you re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox: $ flake8 djlibcloud tests $ python setup.py test $ tox To get flake8 and tox, just pip install them into your virtualenv. 6. Commit your changes and push your branch to GitHub: $ git add. $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature 7. Submit a pull request through the GitHub website. 3.3 Pull Request Guidelines Before you submit a pull request, check that it meets these guidelines: 1. The pull request should include tests. 2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst. 3. The pull request should work for Python 2.7, and 3.3. Check https://travis-ci.org/pydanny/djlibcloud/pull_requests and make sure that the tests pass for all supported Python versions. 8 Chapter 3. Contributing

dj-libcloud Documentation, Release 0.2.0 3.4 Tips To run a subset of tests: $ python -m unittest tests.test_djlibcloud 3.4. Tips 9

dj-libcloud Documentation, Release 0.2.0 10 Chapter 3. Contributing

CHAPTER 4 Credits 4.1 Development Lead Daniel Greenfeld <pydanny@gmail.com> Jannis Leidel 4.2 Contributors None yet. Why not be the first? 11

dj-libcloud Documentation, Release 0.2.0 12 Chapter 4. Credits

CHAPTER 5 History 5.1 0.2.0(2014-06-23) Updated url method to return correct values for Rackspace Cloudfiles, Microsoft Azure, Google Storage, non- US Amazon SV (Thanks Jannis!) Improved the cookbook immensely (Thanks Jannis!) Add link from README to cookbook Fix url method for Google Storage, Rackspace Cloudfiles and Microsoft Azure. Also return the correct value for non-us Amazon S3 buckets. 5.2 0.1.2 (2014-04-24) Confirmed to work with Python 2.7 Remove django-pipeline specific code from storages Add cookbook to docs that includes django-pipeline 5.3 0.1.1 (2014-04-21) Fixed second-time run problem by just using LibCloudStorage class Made django-pipeline optional Removed unnecessary files Moved TODO to issue tracker 5.4 0.1.0 (2014-04-21) First release on PyPI. Frustration over lack of easy media asset support for Django and Python 3. 13