Merge lp:~marix/duplicity/azure-storage-0.30.0-plus into lp:~duplicity-team/duplicity/0.8-series

Proposed by Matthias Bach
Status: Merged
Merged at revision: 1178
Proposed branch: lp:~marix/duplicity/azure-storage-0.30.0-plus
Merge into: lp:~duplicity-team/duplicity/0.8-series
Diff against target: 42 lines (+15/-3)
1 file modified
duplicity/backends/azurebackend.py (+15/-3)
To merge this branch: bzr merge lp:~marix/duplicity/azure-storage-0.30.0-plus
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+317129@code.launchpad.net

Description of the change

This branch make the Azure backend compatible with version 0.30.0 and up of the underlying azure-storage package.

Linux distributions won't ship older version of azure-storage forever. Thus duplicity will no longer be usable on newer distributions as long as it does not support current versions of the azure-storage package.

It can be easily tested by starting a backup to an azure bucket having a recent version of azure-storage installed. E.g. in a test virtualenv:
* pip install -U azure-storage
* duplicity <some dir> azure://<some container>

To post a comment you must log in.
Revision history for this message
Matthias Bach (marix) wrote :

This is the first time on contribute on Launchpad and on a project using Bazaar. Thus, I am sorry in case I missed some some commonly known contribution guidelines. Just let me know and I'll adjust the contribution.

1179. By Matthias Bach

Fix backup creation using azure-storage > 0.30.0

The previous fix only fixed restore and verification of backups.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'duplicity/backends/azurebackend.py'
--- duplicity/backends/azurebackend.py 2016-05-11 21:07:04 +0000
+++ duplicity/backends/azurebackend.py 2017-02-14 15:41:50 +0000
@@ -44,7 +44,11 @@
44 self.AzureConflictError = azure.WindowsAzureConflictError44 self.AzureConflictError = azure.WindowsAzureConflictError
45 else:45 else:
46 # v1.0.0 and above46 # v1.0.0 and above
47 from azure.storage.blob import BlobService47 import azure.storage.blob
48 if hasattr(azure.storage.blob, 'BlobService'):
49 from azure.storage.blob import BlobService
50 else:
51 from azure.storage.blob.blockblobservice import BlockBlobService as BlobService
48 self.AzureMissingResourceError = azure.common.AzureMissingResourceHttpError52 self.AzureMissingResourceError = azure.common.AzureMissingResourceHttpError
49 self.AzureConflictError = azure.common.AzureConflictHttpError53 self.AzureConflictError = azure.common.AzureConflictHttpError
50 except ImportError:54 except ImportError:
@@ -72,7 +76,10 @@
7276
73 def _put(self, source_path, remote_filename):77 def _put(self, source_path, remote_filename):
74 # https://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/#upload-a-blob-into-a-container78 # https://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/#upload-a-blob-into-a-container
75 self.blob_service.put_block_blob_from_path(self.container, remote_filename, source_path.name)79 try:
80 self.blob_service.create_blob_from_path(self.container, remote_filename, source_path.name)
81 except AttributeError: # Old versions use a different method name
82 self.blob_service.put_block_blob_from_path(self.container, remote_filename, source_path.name)
7683
77 def _get(self, remote_filename, local_path):84 def _get(self, remote_filename, local_path):
78 # https://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/#download-blobs85 # https://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/#download-blobs
@@ -96,7 +103,12 @@
96103
97 def _query(self, filename):104 def _query(self, filename):
98 prop = self.blob_service.get_blob_properties(self.container, filename)105 prop = self.blob_service.get_blob_properties(self.container, filename)
99 return {'size': int(prop['content-length'])}106 try:
107 info = {'size': int(prop.properties.content_length)}
108 except AttributeError:
109 # old versions directly returned the properties
110 info = {'size': int(prop['content-length'])}
111 return info
100112
101 def _error_code(self, operation, e):113 def _error_code(self, operation, e):
102 if isinstance(e, self.AzureMissingResourceError):114 if isinstance(e, self.AzureMissingResourceError):

Subscribers

People subscribed via source and target branches