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
1=== modified file 'duplicity/backends/b2backend.py'
2--- duplicity/backends/b2backend.py 2015-12-09 00:23:09 +0000
3+++ duplicity/backends/b2backend.py 2015-12-11 16:45:37 +0000
4@@ -45,6 +45,9 @@
5 """
6 duplicity.backend.Backend.__init__(self, parsed_url)
7
8+ # for prettier password prompt only
9+ self.parsed_url.hostname = 'B2'
10+
11 self.account_id = parsed_url.username
12 account_key = self.get_password()
13
14@@ -84,6 +87,7 @@
15 """
16 Download remote_filename to local_path
17 """
18+ log.Log("Getting file %s" % remote_filename, 9)
19 remote_filename = self.full_filename(remote_filename)
20 url = self.download_url + \
21 '/file/' + self.bucket_name + '/' + \
22@@ -98,6 +102,7 @@
23 """
24 Copy source_path to remote_filename
25 """
26+ log.Log("Putting file to %s" % remote_filename, 9)
27 self._delete(remote_filename)
28 digest = self.hex_sha1_of_file(source_path)
29 content_type = 'application/pgp-encrypted'
30@@ -120,6 +125,7 @@
31 """
32 List files on remote server
33 """
34+ log.Log("Listing files", 9)
35 endpoint = 'b2_list_file_names'
36 url = self.formatted_url(endpoint)
37 params = {
38@@ -132,10 +138,11 @@
39 return []
40
41 files = [x['fileName'].split('/')[-1] for x in resp['files']
42- if x['fileName'].startswith(self.path)]
43+ if os.path.dirname(x['fileName']) == self.path]
44
45 next_file = resp['nextFileName']
46 while next_file:
47+ log.Log("There are still files, getting next list", 9)
48 params['startFileName'] = next_file
49 try:
50 resp = self.get_or_post(url, params)
51@@ -143,7 +150,7 @@
52 return files
53
54 files += [x['fileName'].split('/')[-1] for x in resp['files']
55- if x['fileName'].startswith(self.path)]
56+ if os.path.dirname(x['fileName']) == self.path]
57 next_file = resp['nextFileName']
58
59 return files
60@@ -152,6 +159,7 @@
61 """
62 Delete filename from remote server
63 """
64+ log.Log("Deleting file %s" % filename, 9)
65 endpoint = 'b2_delete_file_version'
66 url = self.formatted_url(endpoint)
67 fileid = self.get_file_id(filename)
68@@ -171,6 +179,7 @@
69 """
70 Get size info of filename
71 """
72+ log.Log("Querying file %s" % filename, 9)
73 info = self.get_file_info(filename)
74 if not info:
75 return {'size': -1}
76@@ -325,6 +334,7 @@
77 """
78
79 def __init__(self, url, data, headers):
80+ log.Log("Getting %s" % url, 9)
81 self.url = url
82 self.data = data
83 self.headers = headers
84@@ -333,6 +343,11 @@
85 def __enter__(self):
86 request = urllib2.Request(self.url, self.data, self.headers)
87 self.file = urllib2.urlopen(request)
88+ log.Log(
89+ "Request of %s returned with status %s" % (
90+ self.url, self.file.code
91+ ), 9
92+ )
93 return self.file
94
95 def __exit__(self, exception_type, exception, traceback):

Subscribers

People subscribed via source and target branches