Merge lp:~matthew-t-bentley/duplicity/b2 into lp:~duplicity-team/duplicity/0.7-series

Proposed by Matthew Bentley
Status: Merged
Merged at revision: 1161
Proposed branch: lp:~matthew-t-bentley/duplicity/b2
Merge into: lp:~duplicity-team/duplicity/0.7-series
Diff against target: 95 lines (+17/-2)
1 file modified
duplicity/backends/b2backend.py (+17/-2)
To merge this branch: bzr merge lp:~matthew-t-bentley/duplicity/b2
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+280329@code.launchpad.net

Description of the change

A couple fixes allowing multiple backups to be hosted in different folders in the same bucket as well as some logging for -v9.

To post a comment you must log in.
Revision history for this message
edso (ed.so) wrote :

just a hint. you may use log.Debug() next time.. ede/duply.net

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'duplicity/backends/b2backend.py'
--- duplicity/backends/b2backend.py 2015-12-09 00:23:09 +0000
+++ duplicity/backends/b2backend.py 2015-12-11 16:45:37 +0000
@@ -45,6 +45,9 @@
45 """45 """
46 duplicity.backend.Backend.__init__(self, parsed_url)46 duplicity.backend.Backend.__init__(self, parsed_url)
4747
48 # for prettier password prompt only
49 self.parsed_url.hostname = 'B2'
50
48 self.account_id = parsed_url.username51 self.account_id = parsed_url.username
49 account_key = self.get_password()52 account_key = self.get_password()
5053
@@ -84,6 +87,7 @@
84 """87 """
85 Download remote_filename to local_path88 Download remote_filename to local_path
86 """89 """
90 log.Log("Getting file %s" % remote_filename, 9)
87 remote_filename = self.full_filename(remote_filename)91 remote_filename = self.full_filename(remote_filename)
88 url = self.download_url + \92 url = self.download_url + \
89 '/file/' + self.bucket_name + '/' + \93 '/file/' + self.bucket_name + '/' + \
@@ -98,6 +102,7 @@
98 """102 """
99 Copy source_path to remote_filename103 Copy source_path to remote_filename
100 """104 """
105 log.Log("Putting file to %s" % remote_filename, 9)
101 self._delete(remote_filename)106 self._delete(remote_filename)
102 digest = self.hex_sha1_of_file(source_path)107 digest = self.hex_sha1_of_file(source_path)
103 content_type = 'application/pgp-encrypted'108 content_type = 'application/pgp-encrypted'
@@ -120,6 +125,7 @@
120 """125 """
121 List files on remote server126 List files on remote server
122 """127 """
128 log.Log("Listing files", 9)
123 endpoint = 'b2_list_file_names'129 endpoint = 'b2_list_file_names'
124 url = self.formatted_url(endpoint)130 url = self.formatted_url(endpoint)
125 params = {131 params = {
@@ -132,10 +138,11 @@
132 return []138 return []
133139
134 files = [x['fileName'].split('/')[-1] for x in resp['files']140 files = [x['fileName'].split('/')[-1] for x in resp['files']
135 if x['fileName'].startswith(self.path)]141 if os.path.dirname(x['fileName']) == self.path]
136142
137 next_file = resp['nextFileName']143 next_file = resp['nextFileName']
138 while next_file:144 while next_file:
145 log.Log("There are still files, getting next list", 9)
139 params['startFileName'] = next_file146 params['startFileName'] = next_file
140 try:147 try:
141 resp = self.get_or_post(url, params)148 resp = self.get_or_post(url, params)
@@ -143,7 +150,7 @@
143 return files150 return files
144151
145 files += [x['fileName'].split('/')[-1] for x in resp['files']152 files += [x['fileName'].split('/')[-1] for x in resp['files']
146 if x['fileName'].startswith(self.path)]153 if os.path.dirname(x['fileName']) == self.path]
147 next_file = resp['nextFileName']154 next_file = resp['nextFileName']
148155
149 return files156 return files
@@ -152,6 +159,7 @@
152 """159 """
153 Delete filename from remote server160 Delete filename from remote server
154 """161 """
162 log.Log("Deleting file %s" % filename, 9)
155 endpoint = 'b2_delete_file_version'163 endpoint = 'b2_delete_file_version'
156 url = self.formatted_url(endpoint)164 url = self.formatted_url(endpoint)
157 fileid = self.get_file_id(filename)165 fileid = self.get_file_id(filename)
@@ -171,6 +179,7 @@
171 """179 """
172 Get size info of filename180 Get size info of filename
173 """181 """
182 log.Log("Querying file %s" % filename, 9)
174 info = self.get_file_info(filename)183 info = self.get_file_info(filename)
175 if not info:184 if not info:
176 return {'size': -1}185 return {'size': -1}
@@ -325,6 +334,7 @@
325 """334 """
326335
327 def __init__(self, url, data, headers):336 def __init__(self, url, data, headers):
337 log.Log("Getting %s" % url, 9)
328 self.url = url338 self.url = url
329 self.data = data339 self.data = data
330 self.headers = headers340 self.headers = headers
@@ -333,6 +343,11 @@
333 def __enter__(self):343 def __enter__(self):
334 request = urllib2.Request(self.url, self.data, self.headers)344 request = urllib2.Request(self.url, self.data, self.headers)
335 self.file = urllib2.urlopen(request)345 self.file = urllib2.urlopen(request)
346 log.Log(
347 "Request of %s returned with status %s" % (
348 self.url, self.file.code
349 ), 9
350 )
336 return self.file351 return self.file
337352
338 def __exit__(self, exception_type, exception, traceback):353 def __exit__(self, exception_type, exception, traceback):

Subscribers

People subscribed via source and target branches