From 29ec822b67fe39cb8e7f0a0c956c1fe2c879b9bb Mon Sep 17 00:00:00 2001 From: Sandy Walsh Date: Tue, 3 Jun 2014 02:08:24 +0000 Subject: [PATCH] CloudFiles upload handler and setup.cfg tweak --- etc/sample_rax_credentials.conf | 2 -- setup.cfg | 11 +++++++---- shoebox/handlers.py | 8 ++++++-- tox.ini | 1 + 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/etc/sample_rax_credentials.conf b/etc/sample_rax_credentials.conf index 95d2086..f0d1564 100644 --- a/etc/sample_rax_credentials.conf +++ b/etc/sample_rax_credentials.conf @@ -1,5 +1,3 @@ -identity_type = rackspace - [rackspace_cloud] username = my_username api_key = 01234567890abcdef diff --git a/setup.cfg b/setup.cfg index cd30def..f11aca0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,7 +6,7 @@ summary = data archiving library description-file = README.md license = Apache-2 classifier = - Development Status :: 2 - Pre-Alpha + Development Status :: 5 - Production/Stable Environment :: Console Intended Audience :: Developers Intended Audience :: Information Technology @@ -14,9 +14,12 @@ classifier = Operating System :: OS Independent Programming Language :: Python Topic :: Software Development :: Libraries :: Python Modules +home-page = https://github.com/StackTach/shoebox keywords = - setup - distutils + json + archive + swift + openstack [files] packages = - shoebox \ No newline at end of file + shoebox diff --git a/shoebox/handlers.py b/shoebox/handlers.py index 8fe5611..5ad9de2 100644 --- a/shoebox/handlers.py +++ b/shoebox/handlers.py @@ -90,7 +90,7 @@ class MoveFileCallback(ArchiveCallback): class DeleteFileCallback(ArchiveCallback): def on_close(self, filename): """Delete this file.""" - os.delete(filename) + os.remove(filename) return None @@ -102,7 +102,11 @@ class SwiftUploadCallback(ArchiveCallback): raise MissingArgument("No credentials_file defined.") self.container = kwargs.get('container', 'shoebox') + self.auth_method = kwargs.get('auth_method', 'rackspace') + self.region = kwargs.get('region', 'DFW') + pyrax.set_setting('identity_type', self.auth_method) + pyrax.set_setting("region", self.region) pyrax.set_credential_file(self.credentials_file) self.cloud_files = pyrax.cloudfiles @@ -111,5 +115,5 @@ class SwiftUploadCallback(ArchiveCallback): checksum = pyrax.utils.get_checksum(filename) # Blocking call ... obj = self.cloud_files.upload_file(self.container, filename, - etag=chksum) + etag=checksum) return filename diff --git a/tox.ini b/tox.ini index 93a052e..ca0ec80 100644 --- a/tox.ini +++ b/tox.ini @@ -8,6 +8,7 @@ deps = mock notigen notification_utils + pyrax python-dateutil simport