Merge lp:~aaron-whitehouse/duplicity/08-style-fixes into lp:~duplicity-team/duplicity/0.8-series

Proposed by Aaron Whitehouse
Status: Merged
Merged at revision: 1354
Proposed branch: lp:~aaron-whitehouse/duplicity/08-style-fixes
Merge into: lp:~duplicity-team/duplicity/0.8-series
Diff against target: 280 lines (+92/-91)
6 files modified
duplicity/asyncscheduler.py (+14/-14)
duplicity/backends/azurebackend.py (+4/-4)
duplicity/backends/b2backend.py (+2/-1)
duplicity/backends/webdavbackend.py (+66/-66)
duplicity/collections.py (+4/-4)
duplicity/statistics.py (+2/-2)
To merge this branch: bzr merge lp:~aaron-whitehouse/duplicity/08-style-fixes
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+364218@code.launchpad.net

Commit message

* Fix pylint style issues (over-indented text, whitespace on blank lines etc)
* Removed "pylint: disable=bad-string-format-type" comment, which was throwing an error and does not seem to be needed.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'duplicity/asyncscheduler.py'
2--- duplicity/asyncscheduler.py 2018-11-29 19:00:15 +0000
3+++ duplicity/asyncscheduler.py 2019-03-10 23:09:19 +0000
4@@ -241,18 +241,18 @@
5 thread.start_new_thread(trampoline, ())
6
7 def __execute_caller(self, caller):
8- # The caller half that we get here will not propagate
9- # errors back to us, but rather propagate it back to the
10- # "other half" of the async split.
11- succeeded, waiter = caller()
12- if not succeeded:
13- def _signal_failed():
14- if not self.__failed:
15- self.__failed = True
16- self.__failed_waiter = waiter
17- self.__cv.notifyAll()
18- with_lock(self.__cv, _signal_failed)
19+ # The caller half that we get here will not propagate
20+ # errors back to us, but rather propagate it back to the
21+ # "other half" of the async split.
22+ succeeded, waiter = caller()
23+ if not succeeded:
24+ def _signal_failed():
25+ if not self.__failed:
26+ self.__failed = True
27+ self.__failed_waiter = waiter
28+ self.__cv.notifyAll()
29+ with_lock(self.__cv, _signal_failed)
30
31- log.Info(u"%s: %s" % (self.__class__.__name__,
32- _(u"task execution done (success: %s)") % succeeded),
33- log.InfoCode.asynchronous_upload_done)
34+ log.Info(u"%s: %s" % (self.__class__.__name__,
35+ _(u"task execution done (success: %s)") % succeeded),
36+ log.InfoCode.asynchronous_upload_done)
37
38=== modified file 'duplicity/backends/azurebackend.py'
39--- duplicity/backends/azurebackend.py 2019-01-01 21:36:27 +0000
40+++ duplicity/backends/azurebackend.py 2019-03-10 23:09:19 +0000
41@@ -102,7 +102,7 @@
42 # fallback for azure-storage<0.30.0
43 except AttributeError:
44 self.blob_service._BLOB_MAX_CHUNK_DATA_SIZE = globals.azure_max_block_size
45-
46+
47 def _create_container(self):
48 try:
49 self.blob_service.create_container(self.container, fail_on_exist=True)
50@@ -124,16 +124,16 @@
51 self.blob_service.create_blob_from_path(self.container, remote_filename, source_path.name, **kwargs)
52 except AttributeError: # Old versions use a different method name
53 self.blob_service.put_block_blob_from_path(self.container, remote_filename, source_path.name, **kwargs)
54-
55+
56 self._set_tier(remote_filename)
57-
58+
59 def _set_tier(self, remote_filename):
60 if globals.azure_blob_tier is not None:
61 try:
62 self.blob_service.set_standard_blob_tier(self.container, remote_filename, globals.azure_blob_tier)
63 except AttributeError: # might not be available in old API
64 pass
65-
66+
67 def _get(self, remote_filename, local_path):
68 # https://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/#download-blobs
69 self.blob_service.get_blob_to_path(self.container, remote_filename, local_path.name)
70
71=== modified file 'duplicity/backends/b2backend.py'
72--- duplicity/backends/b2backend.py 2018-12-27 16:43:07 +0000
73+++ duplicity/backends/b2backend.py 2019-03-10 23:09:19 +0000
74@@ -38,7 +38,7 @@
75 class B2ProgressListener:
76 def __enter__(self):
77 pass
78-
79+
80 def set_total_bytes(self, total_byte_count):
81 self.total_byte_count = total_byte_count
82
83@@ -51,6 +51,7 @@
84 def __exit__(self, exc_type, exc_val, exc_tb):
85 pass
86
87+
88 class B2Backend(duplicity.backend.Backend):
89 u"""
90 Backend for BackBlaze's B2 storage service
91
92=== modified file 'duplicity/backends/webdavbackend.py'
93--- duplicity/backends/webdavbackend.py 2018-12-23 16:52:31 +0000
94+++ duplicity/backends/webdavbackend.py 2019-03-10 23:09:19 +0000
95@@ -57,76 +57,76 @@
96
97
98 class VerifiedHTTPSConnection(http.client.HTTPSConnection):
99- def __init__(self, *args, **kwargs):
100- try:
101- global socket, ssl
102- import socket
103- import ssl
104- except ImportError:
105- raise FatalBackendException(_(u"Missing socket or ssl python modules."))
106-
107- http.client.HTTPSConnection.__init__(self, *args, **kwargs)
108-
109- self.cacert_file = globals.ssl_cacert_file
110- self.cacert_candidates = [u"~/.duplicity/cacert.pem",
111- u"~/duplicity_cacert.pem",
112- u"/etc/duplicity/cacert.pem"]
113- # if no cacert file was given search default locations
114+ def __init__(self, *args, **kwargs):
115+ try:
116+ global socket, ssl
117+ import socket
118+ import ssl
119+ except ImportError:
120+ raise FatalBackendException(_(u"Missing socket or ssl python modules."))
121+
122+ http.client.HTTPSConnection.__init__(self, *args, **kwargs)
123+
124+ self.cacert_file = globals.ssl_cacert_file
125+ self.cacert_candidates = [u"~/.duplicity/cacert.pem",
126+ u"~/duplicity_cacert.pem",
127+ u"/etc/duplicity/cacert.pem"]
128+ # if no cacert file was given search default locations
129+ if not self.cacert_file:
130+ for path in self.cacert_candidates:
131+ path = os.path.expanduser(path)
132+ if (os.path.isfile(path)):
133+ self.cacert_file = path
134+ break
135+
136+ # check if file is accessible (libssl errors are not very detailed)
137+ if self.cacert_file and not os.access(self.cacert_file, os.R_OK):
138+ raise FatalBackendException(_(u"Cacert database file '%s' is not readable.") %
139+ self.cacert_file)
140+
141+ def connect(self):
142+ # create new socket
143+ sock = socket.create_connection((self.host, self.port),
144+ self.timeout)
145+ if self._tunnel_host:
146+ self.sock = sock
147+ self.tunnel()
148+
149+ # python 2.7.9+ supports default system certs now
150+ if u"create_default_context" in dir(ssl):
151+ context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH,
152+ cafile=self.cacert_file,
153+ capath=globals.ssl_cacert_path)
154+ self.sock = context.wrap_socket(sock, server_hostname=self.host)
155+ # the legacy way needing a cert file
156+ else:
157+ if globals.ssl_cacert_path:
158+ raise FatalBackendException(
159+ _(u"Option '--ssl-cacert-path' is not supported "
160+ u"with python 2.7.8 and below."))
161+
162 if not self.cacert_file:
163- for path in self.cacert_candidates:
164- path = os.path.expanduser(path)
165- if (os.path.isfile(path)):
166- self.cacert_file = path
167- break
168-
169- # check if file is accessible (libssl errors are not very detailed)
170- if self.cacert_file and not os.access(self.cacert_file, os.R_OK):
171- raise FatalBackendException(_(u"Cacert database file '%s' is not readable.") %
172- self.cacert_file)
173-
174- def connect(self):
175- # create new socket
176- sock = socket.create_connection((self.host, self.port),
177- self.timeout)
178- if self._tunnel_host:
179- self.sock = sock
180- self.tunnel()
181-
182- # python 2.7.9+ supports default system certs now
183- if u"create_default_context" in dir(ssl):
184- context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH,
185- cafile=self.cacert_file,
186- capath=globals.ssl_cacert_path)
187- self.sock = context.wrap_socket(sock, server_hostname=self.host)
188- # the legacy way needing a cert file
189- else:
190- if globals.ssl_cacert_path:
191- raise FatalBackendException(
192- _(u"Option '--ssl-cacert-path' is not supported "
193- u"with python 2.7.8 and below."))
194-
195- if not self.cacert_file:
196- raise FatalBackendException(_(u"""\
197+ raise FatalBackendException(_(u"""\
198 For certificate verification with python 2.7.8 or earlier a cacert database
199 file is needed in one of these locations: %s
200 Hints:
201- Consult the man page, chapter 'SSL Certificate Verification'.
202- Consider using the options --ssl-cacert-file, --ssl-no-check-certificate .""") %
203- u", ".join(self.cacert_candidates))
204-
205- # wrap the socket in ssl using verification
206- self.sock = ssl.wrap_socket(sock,
207- cert_reqs=ssl.CERT_REQUIRED,
208- ca_certs=self.cacert_file,
209- )
210-
211- def request(self, *args, **kwargs): # pylint: disable=method-hidden
212- try:
213- return http.client.HTTPSConnection.request(self, *args, **kwargs)
214- except ssl.SSLError as e:
215- # encapsulate ssl errors
216- raise BackendException(u"SSL failed: %s" % util.uexc(e),
217- log.ErrorCode.backend_error)
218+Consult the man page, chapter 'SSL Certificate Verification'.
219+Consider using the options --ssl-cacert-file, --ssl-no-check-certificate .""") %
220+ u", ".join(self.cacert_candidates))
221+
222+ # wrap the socket in ssl using verification
223+ self.sock = ssl.wrap_socket(sock,
224+ cert_reqs=ssl.CERT_REQUIRED,
225+ ca_certs=self.cacert_file,
226+ )
227+
228+ def request(self, *args, **kwargs): # pylint: disable=method-hidden
229+ try:
230+ return http.client.HTTPSConnection.request(self, *args, **kwargs)
231+ except ssl.SSLError as e:
232+ # encapsulate ssl errors
233+ raise BackendException(u"SSL failed: %s" % util.uexc(e),
234+ log.ErrorCode.backend_error)
235
236
237 class WebDAVBackend(duplicity.backend.Backend):
238
239=== modified file 'duplicity/collections.py'
240--- duplicity/collections.py 2019-02-22 20:25:02 +0000
241+++ duplicity/collections.py 2019-03-10 23:09:19 +0000
242@@ -1096,8 +1096,8 @@
243 if (chain.end_time < t and
244 (not self.matched_chain_pair or
245 chain is not self.matched_chain_pair[1])):
246- # don't delete the active (matched) chain
247- old_chains.append(chain)
248+ # don't delete the active (matched) chain
249+ old_chains.append(chain)
250 return old_chains
251
252 def get_signature_chains_older_than(self, t):
253@@ -1116,8 +1116,8 @@
254 if (chain.end_time < t and
255 (not self.matched_chain_pair or
256 chain is not self.matched_chain_pair[0])):
257- # don't delete the active (matched) chain
258- old_chains.append(chain)
259+ # don't delete the active (matched) chain
260+ old_chains.append(chain)
261 return old_chains
262
263 def get_last_full_backup_time(self):
264
265=== modified file 'duplicity/statistics.py'
266--- duplicity/statistics.py 2019-02-22 19:04:51 +0000
267+++ duplicity/statistics.py 2019-03-10 23:09:19 +0000
268@@ -156,10 +156,10 @@
269 u"""Return portion of statistics string dealing with time"""
270 timelist = []
271 if self.StartTime is not None:
272- timelist.append(u"StartTime %.2f (%s)\n" % # pylint: disable=bad-string-format-type
273+ timelist.append(u"StartTime %.2f (%s)\n" %
274 (self.StartTime, dup_time.timetopretty(self.StartTime)))
275 if self.EndTime is not None:
276- timelist.append(u"EndTime %.2f (%s)\n" % # pylint: disable=bad-string-format-type
277+ timelist.append(u"EndTime %.2f (%s)\n" %
278 (self.EndTime, dup_time.timetopretty(self.EndTime)))
279 if self.ElapsedTime or (self.StartTime is not None and
280 self.EndTime is not None):

Subscribers

People subscribed via source and target branches