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
1=== modified file 'duplicity/backends/azurebackend.py'
2--- duplicity/backends/azurebackend.py 2016-05-11 21:07:04 +0000
3+++ duplicity/backends/azurebackend.py 2017-02-14 15:41:50 +0000
4@@ -44,7 +44,11 @@
5 self.AzureConflictError = azure.WindowsAzureConflictError
6 else:
7 # v1.0.0 and above
8- from azure.storage.blob import BlobService
9+ import azure.storage.blob
10+ if hasattr(azure.storage.blob, 'BlobService'):
11+ from azure.storage.blob import BlobService
12+ else:
13+ from azure.storage.blob.blockblobservice import BlockBlobService as BlobService
14 self.AzureMissingResourceError = azure.common.AzureMissingResourceHttpError
15 self.AzureConflictError = azure.common.AzureConflictHttpError
16 except ImportError:
17@@ -72,7 +76,10 @@
18
19 def _put(self, source_path, remote_filename):
20 # https://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/#upload-a-blob-into-a-container
21- self.blob_service.put_block_blob_from_path(self.container, remote_filename, source_path.name)
22+ try:
23+ self.blob_service.create_blob_from_path(self.container, remote_filename, source_path.name)
24+ except AttributeError: # Old versions use a different method name
25+ self.blob_service.put_block_blob_from_path(self.container, remote_filename, source_path.name)
26
27 def _get(self, remote_filename, local_path):
28 # https://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/#download-blobs
29@@ -96,7 +103,12 @@
30
31 def _query(self, filename):
32 prop = self.blob_service.get_blob_properties(self.container, filename)
33- return {'size': int(prop['content-length'])}
34+ try:
35+ info = {'size': int(prop.properties.content_length)}
36+ except AttributeError:
37+ # old versions directly returned the properties
38+ info = {'size': int(prop['content-length'])}
39+ return info
40
41 def _error_code(self, operation, e):
42 if isinstance(e, self.AzureMissingResourceError):

Subscribers

People subscribed via source and target branches