Merge lp:~mterry/duplicity/2.6isms into lp:duplicity/0.6

Proposed by Michael Terry
Status: Merged
Merged at revision: 975
Proposed branch: lp:~mterry/duplicity/2.6isms
Merge into: lp:duplicity/0.6
Diff against target: 1807 lines (+259/-196)
46 files modified
bin/duplicity (+7/-7)
bin/rdiffdir (+1/-1)
duplicity/backend.py (+4/-4)
duplicity/backends/_boto_multi.py (+4/-4)
duplicity/backends/_boto_single.py (+8/-8)
duplicity/backends/_cf_cloudfiles.py (+13/-13)
duplicity/backends/_cf_pyrax.py (+13/-13)
duplicity/backends/_ssh_paramiko.py (+20/-20)
duplicity/backends/botobackend.py (+2/-2)
duplicity/backends/cfbackend.py (+2/-2)
duplicity/backends/dpbxbackend.py (+6/-5)
duplicity/backends/gdocsbackend.py (+7/-7)
duplicity/backends/giobackend.py (+6/-6)
duplicity/backends/imapbackend.py (+1/-1)
duplicity/backends/localbackend.py (+6/-6)
duplicity/backends/megabackend.py (+6/-6)
duplicity/backends/sshbackend.py (+2/-2)
duplicity/backends/swiftbackend.py (+17/-17)
duplicity/backends/webdavbackend.py (+5/-5)
duplicity/cached_ops.py (+1/-1)
duplicity/collections.py (+3/-3)
duplicity/commandline.py (+1/-1)
duplicity/diffdir.py (+4/-4)
duplicity/dup_temp.py (+3/-3)
duplicity/dup_threading.py (+2/-2)
duplicity/dup_time.py (+4/-4)
duplicity/file_naming.py (+1/-1)
duplicity/globals.py (+1/-1)
duplicity/gpg.py (+1/-1)
duplicity/gpginterface.py (+9/-9)
duplicity/librsync.py (+7/-7)
duplicity/patchdir.py (+1/-1)
duplicity/path.py (+1/-1)
duplicity/progress.py (+2/-2)
duplicity/robust.py (+1/-1)
duplicity/selection.py (+2/-2)
duplicity/statistics.py (+3/-3)
duplicity/tempdir.py (+1/-1)
duplicity/util.py (+2/-2)
testing/tests/test_badupload.py (+1/-1)
testing/tests/test_collections.py (+4/-4)
testing/tests/test_filenaming.py (+4/-4)
testing/tests/test_lazy.py (+2/-1)
testing/tests/test_patchdir.py (+6/-6)
testing/tests/test_python3.py (+61/-0)
testing/tests/test_restart.py (+1/-1)
To merge this branch: bzr merge lp:~mterry/duplicity/2.6isms
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+216404@code.launchpad.net

Description of the change

Here's a whole stack of minor syntax modernizations that will become necessary in python3. They all work in python2.6.

I've added a new test to keep us honest and prevent backsliding on these modernizations. It runs 2to3 and will fail the test if 2to3 finds anything that needs fixing (with a specific set of exceptions carved out).

This branch has most of the easy 2to3 fixes, the ones with obvious and safe syntax changes.

We could just let 2to3 do them for us, but ideally we use 2to3 as little as possible, since it doesn't always know how to solve a given problem. I will propose a branch later that actually does use 2to3 to generate python3 versions of duplicity if they are requested. But this is a first step to clean up the code base.

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
=== modified file 'bin/duplicity'
--- bin/duplicity 2014-04-16 02:43:43 +0000
+++ bin/duplicity 2014-04-17 22:26:47 +0000
@@ -1042,7 +1042,7 @@
1042 log.Notice(_("Deleting local %s (not authoritative at backend).") % util.ufn(del_name))1042 log.Notice(_("Deleting local %s (not authoritative at backend).") % util.ufn(del_name))
1043 try:1043 try:
1044 util.ignore_missing(os.unlink, del_name)1044 util.ignore_missing(os.unlink, del_name)
1045 except Exception, e:1045 except Exception as e:
1046 log.Warn(_("Unable to delete %s: %s") % (util.ufn(del_name), str(e)))1046 log.Warn(_("Unable to delete %s: %s") % (util.ufn(del_name), str(e)))
10471047
1048 def copy_to_local(fn):1048 def copy_to_local(fn):
@@ -1505,18 +1505,18 @@
1505 # sys.exit() function. Python handles this by1505 # sys.exit() function. Python handles this by
1506 # raising the SystemExit exception. Cleanup code1506 # raising the SystemExit exception. Cleanup code
1507 # goes here, if needed.1507 # goes here, if needed.
1508 except SystemExit, e:1508 except SystemExit as e:
1509 # No traceback, just get out1509 # No traceback, just get out
1510 util.release_lockfile()1510 util.release_lockfile()
1511 sys.exit(e)1511 sys.exit(e)
15121512
1513 except KeyboardInterrupt, e:1513 except KeyboardInterrupt as e:
1514 # No traceback, just get out1514 # No traceback, just get out
1515 log.Info(_("INT intercepted...exiting."))1515 log.Info(_("INT intercepted...exiting."))
1516 util.release_lockfile()1516 util.release_lockfile()
1517 sys.exit(4)1517 sys.exit(4)
15181518
1519 except gpg.GPGError, e:1519 except gpg.GPGError as e:
1520 # For gpg errors, don't show an ugly stack trace by1520 # For gpg errors, don't show an ugly stack trace by
1521 # default. But do with sufficient verbosity.1521 # default. But do with sufficient verbosity.
1522 util.release_lockfile()1522 util.release_lockfile()
@@ -1526,7 +1526,7 @@
1526 log.ErrorCode.gpg_failed,1526 log.ErrorCode.gpg_failed,
1527 e.__class__.__name__)1527 e.__class__.__name__)
15281528
1529 except duplicity.errors.UserError, e:1529 except duplicity.errors.UserError as e:
1530 util.release_lockfile()1530 util.release_lockfile()
1531 # For user errors, don't show an ugly stack trace by1531 # For user errors, don't show an ugly stack trace by
1532 # default. But do with sufficient verbosity.1532 # default. But do with sufficient verbosity.
@@ -1536,7 +1536,7 @@
1536 log.ErrorCode.user_error,1536 log.ErrorCode.user_error,
1537 e.__class__.__name__)1537 e.__class__.__name__)
15381538
1539 except duplicity.errors.BackendException, e:1539 except duplicity.errors.BackendException as e:
1540 util.release_lockfile()1540 util.release_lockfile()
1541 # For backend errors, don't show an ugly stack trace by1541 # For backend errors, don't show an ugly stack trace by
1542 # default. But do with sufficient verbosity.1542 # default. But do with sufficient verbosity.
@@ -1546,7 +1546,7 @@
1546 log.ErrorCode.user_error,1546 log.ErrorCode.user_error,
1547 e.__class__.__name__)1547 e.__class__.__name__)
15481548
1549 except Exception, e:1549 except Exception as e:
1550 util.release_lockfile()1550 util.release_lockfile()
1551 if "Forced assertion for testing" in str(e):1551 if "Forced assertion for testing" in str(e):
1552 log.FatalError(u"%s: %s" % (e.__class__.__name__, unicode(e)),1552 log.FatalError(u"%s: %s" % (e.__class__.__name__, unicode(e)),
15531553
=== modified file 'bin/rdiffdir'
--- bin/rdiffdir 2014-02-05 02:57:01 +0000
+++ bin/rdiffdir 2014-04-17 22:26:47 +0000
@@ -64,7 +64,7 @@
64 "include-filelist-stdin", "include-globbing-filelist",64 "include-filelist-stdin", "include-globbing-filelist",
65 "include-regexp=", "max-blocksize", "null-separator",65 "include-regexp=", "max-blocksize", "null-separator",
66 "verbosity=", "write-sig-to="])66 "verbosity=", "write-sig-to="])
67 except getopt.error, e:67 except getopt.error as e:
68 command_line_error("Bad command line option: %s" % (str(e),))68 command_line_error("Bad command line option: %s" % (str(e),))
6969
70 for opt, arg in optlist:70 for opt, arg in optlist:
7171
=== modified file 'duplicity/backend.py'
--- duplicity/backend.py 2014-04-17 19:02:22 +0000
+++ duplicity/backend.py 2014-04-17 22:26:47 +0000
@@ -306,7 +306,7 @@
306 try:306 try:
307 kwargs = {"raise_errors" : True}307 kwargs = {"raise_errors" : True}
308 return fn(*args, **kwargs)308 return fn(*args, **kwargs)
309 except Exception, e:309 except Exception as e:
310 log.Warn(_("Attempt %s failed: %s: %s")310 log.Warn(_("Attempt %s failed: %s: %s")
311 % (n, e.__class__.__name__, str(e)))311 % (n, e.__class__.__name__, str(e)))
312 log.Debug(_("Backtrace of previous error: %s")312 log.Debug(_("Backtrace of previous error: %s")
@@ -332,10 +332,10 @@
332 try:332 try:
333 self.retry_count = n333 self.retry_count = n
334 return fn(self, *args)334 return fn(self, *args)
335 except FatalBackendError, e:335 except FatalBackendError as e:
336 # die on fatal errors336 # die on fatal errors
337 raise e337 raise e
338 except Exception, e:338 except Exception as e:
339 # retry on anything else339 # retry on anything else
340 log.Warn(_("Attempt %s failed. %s: %s")340 log.Warn(_("Attempt %s failed. %s: %s")
341 % (n, e.__class__.__name__, str(e)))341 % (n, e.__class__.__name__, str(e)))
@@ -345,7 +345,7 @@
345 # final trial, die on exception345 # final trial, die on exception
346 self.retry_count = n+1346 self.retry_count = n+1
347 return fn(self, *args)347 return fn(self, *args)
348 except Exception, e:348 except Exception as e:
349 log.Debug(_("Backtrace of previous error: %s")349 log.Debug(_("Backtrace of previous error: %s")
350 % exception_traceback())350 % exception_traceback())
351 log.FatalError(_("Giving up after %s attempts. %s: %s")351 log.FatalError(_("Giving up after %s attempts. %s: %s")
352352
=== modified file 'duplicity/backends/_boto_multi.py'
--- duplicity/backends/_boto_multi.py 2014-04-09 09:22:27 +0000
+++ duplicity/backends/_boto_multi.py 2014-04-17 22:26:47 +0000
@@ -33,8 +33,8 @@
33from duplicity.filechunkio import FileChunkIO33from duplicity.filechunkio import FileChunkIO
34from duplicity import progress34from duplicity import progress
3535
36from _boto_single import BotoBackend as BotoSingleBackend36from ._boto_single import BotoBackend as BotoSingleBackend
37from _boto_single import get_connection37from ._boto_single import get_connection
3838
39BOTO_MIN_VERSION = "2.1.1"39BOTO_MIN_VERSION = "2.1.1"
4040
@@ -63,7 +63,7 @@
63 try:63 try:
64 args = self.queue.get(True, 1)64 args = self.queue.get(True, 1)
65 progress.report_transfer(args[0], args[1])65 progress.report_transfer(args[0], args[1])
66 except Queue.Empty, e:66 except Queue.Empty as e:
67 pass67 pass
6868
6969
@@ -210,7 +210,7 @@
210 conn = None210 conn = None
211 bucket = None211 bucket = None
212 del conn212 del conn
213 except Exception, e:213 except Exception as e:
214 traceback.print_exc()214 traceback.print_exc()
215 if num_retries:215 if num_retries:
216 log.Debug("%s: Upload of chunk %d failed. Retrying %d more times..." % (216 log.Debug("%s: Upload of chunk %d failed. Retrying %d more times..." % (
217217
=== modified file 'duplicity/backends/_boto_single.py'
--- duplicity/backends/_boto_single.py 2014-04-09 09:55:21 +0000
+++ duplicity/backends/_boto_single.py 2014-04-17 22:26:47 +0000
@@ -202,7 +202,7 @@
202 try:202 try:
203 try:203 try:
204 self.bucket = self.conn.get_bucket(self.bucket_name, validate=True)204 self.bucket = self.conn.get_bucket(self.bucket_name, validate=True)
205 except Exception, e:205 except Exception as e:
206 if "NoSuchBucket" in str(e):206 if "NoSuchBucket" in str(e):
207 if globals.s3_european_buckets:207 if globals.s3_european_buckets:
208 self.bucket = self.conn.create_bucket(self.bucket_name,208 self.bucket = self.conn.create_bucket(self.bucket_name,
@@ -211,7 +211,7 @@
211 self.bucket = self.conn.create_bucket(self.bucket_name)211 self.bucket = self.conn.create_bucket(self.bucket_name)
212 else:212 else:
213 raise e213 raise e
214 except Exception, e:214 except Exception as e:
215 log.Warn("Failed to create bucket (attempt #%d) '%s' failed (reason: %s: %s)"215 log.Warn("Failed to create bucket (attempt #%d) '%s' failed (reason: %s: %s)"
216 "" % (n, self.bucket_name,216 "" % (n, self.bucket_name,
217 e.__class__.__name__,217 e.__class__.__name__,
@@ -252,7 +252,7 @@
252 self.resetConnection()252 self.resetConnection()
253 log.Debug("Uploaded %s/%s to %s Storage at roughly %f bytes/second" % (self.straight_url, remote_filename, storage_class, rough_upload_speed))253 log.Debug("Uploaded %s/%s to %s Storage at roughly %f bytes/second" % (self.straight_url, remote_filename, storage_class, rough_upload_speed))
254 return254 return
255 except Exception, e:255 except Exception as e:
256 log.Warn("Upload '%s/%s' failed (attempt #%d, reason: %s: %s)"256 log.Warn("Upload '%s/%s' failed (attempt #%d, reason: %s: %s)"
257 "" % (self.straight_url,257 "" % (self.straight_url,
258 remote_filename,258 remote_filename,
@@ -279,7 +279,7 @@
279 key.get_contents_to_filename(local_path.name)279 key.get_contents_to_filename(local_path.name)
280 local_path.setdata()280 local_path.setdata()
281 return281 return
282 except Exception, e:282 except Exception as e:
283 log.Warn("Download %s/%s failed (attempt #%d, reason: %s: %s)"283 log.Warn("Download %s/%s failed (attempt #%d, reason: %s: %s)"
284 "" % (self.straight_url,284 "" % (self.straight_url,
285 remote_filename,285 remote_filename,
@@ -304,7 +304,7 @@
304 log.Info("Listing %s" % self.straight_url)304 log.Info("Listing %s" % self.straight_url)
305 try:305 try:
306 return self._list_filenames_in_bucket()306 return self._list_filenames_in_bucket()
307 except Exception, e:307 except Exception as e:
308 log.Warn("List %s failed (attempt #%d, reason: %s: %s)"308 log.Warn("List %s failed (attempt #%d, reason: %s: %s)"
309 "" % (self.straight_url,309 "" % (self.straight_url,
310 n,310 n,
@@ -348,7 +348,7 @@
348 if key is None:348 if key is None:
349 return {'size': -1}349 return {'size': -1}
350 return {'size': key.size}350 return {'size': key.size}
351 except Exception, e:351 except Exception as e:
352 log.Warn("Query %s/%s failed: %s"352 log.Warn("Query %s/%s failed: %s"
353 "" % (self.straight_url,353 "" % (self.straight_url,
354 filename,354 filename,
@@ -368,7 +368,7 @@
368368
369 def pre_process_download(self, files_to_download, wait=False):369 def pre_process_download(self, files_to_download, wait=False):
370 # Used primarily to move files in Glacier to S3370 # Used primarily to move files in Glacier to S3
371 if isinstance(files_to_download, basestring):371 if isinstance(files_to_download, (bytes, str, unicode)):
372 files_to_download = [files_to_download]372 files_to_download = [files_to_download]
373373
374 for remote_filename in files_to_download:374 for remote_filename in files_to_download:
@@ -397,7 +397,7 @@
397 log.Info("File %s was successfully restored from Glacier" % remote_filename)397 log.Info("File %s was successfully restored from Glacier" % remote_filename)
398 success = True398 success = True
399 break399 break
400 except Exception, e:400 except Exception as e:
401 log.Warn("Restoration from Glacier for file %s/%s failed (attempt #%d, reason: %s: %s)"401 log.Warn("Restoration from Glacier for file %s/%s failed (attempt #%d, reason: %s: %s)"
402 "" % (self.straight_url,402 "" % (self.straight_url,
403 remote_filename,403 remote_filename,
404404
=== modified file 'duplicity/backends/_cf_cloudfiles.py'
--- duplicity/backends/_cf_cloudfiles.py 2013-12-27 06:39:00 +0000
+++ duplicity/backends/_cf_cloudfiles.py 2014-04-17 22:26:47 +0000
@@ -44,17 +44,17 @@
44 self.resp_exc = ResponseError44 self.resp_exc = ResponseError
45 conn_kwargs = {}45 conn_kwargs = {}
4646
47 if not os.environ.has_key('CLOUDFILES_USERNAME'):47 if 'CLOUDFILES_USERNAME' not in os.environ:
48 raise BackendException('CLOUDFILES_USERNAME environment variable'48 raise BackendException('CLOUDFILES_USERNAME environment variable'
49 'not set.')49 'not set.')
5050
51 if not os.environ.has_key('CLOUDFILES_APIKEY'):51 if 'CLOUDFILES_APIKEY' not in os.environ:
52 raise BackendException('CLOUDFILES_APIKEY environment variable not set.')52 raise BackendException('CLOUDFILES_APIKEY environment variable not set.')
5353
54 conn_kwargs['username'] = os.environ['CLOUDFILES_USERNAME']54 conn_kwargs['username'] = os.environ['CLOUDFILES_USERNAME']
55 conn_kwargs['api_key'] = os.environ['CLOUDFILES_APIKEY']55 conn_kwargs['api_key'] = os.environ['CLOUDFILES_APIKEY']
5656
57 if os.environ.has_key('CLOUDFILES_AUTHURL'):57 if 'CLOUDFILES_AUTHURL' in os.environ:
58 conn_kwargs['authurl'] = os.environ['CLOUDFILES_AUTHURL']58 conn_kwargs['authurl'] = os.environ['CLOUDFILES_AUTHURL']
59 else:59 else:
60 conn_kwargs['authurl'] = consts.default_authurl60 conn_kwargs['authurl'] = consts.default_authurl
@@ -63,7 +63,7 @@
6363
64 try:64 try:
65 conn = Connection(**conn_kwargs)65 conn = Connection(**conn_kwargs)
66 except Exception, e:66 except Exception as e:
67 log.FatalError("Connection failed, please check your credentials: %s %s"67 log.FatalError("Connection failed, please check your credentials: %s %s"
68 % (e.__class__.__name__, str(e)),68 % (e.__class__.__name__, str(e)),
69 log.ErrorCode.connection_failed)69 log.ErrorCode.connection_failed)
@@ -79,10 +79,10 @@
79 sobject = self.container.create_object(remote_filename)79 sobject = self.container.create_object(remote_filename)
80 sobject.load_from_filename(source_path.name)80 sobject.load_from_filename(source_path.name)
81 return81 return
82 except self.resp_exc, error:82 except self.resp_exc as error:
83 log.Warn("Upload of '%s' failed (attempt %d): CloudFiles returned: %s %s"83 log.Warn("Upload of '%s' failed (attempt %d): CloudFiles returned: %s %s"
84 % (remote_filename, n, error.status, error.reason))84 % (remote_filename, n, error.status, error.reason))
85 except Exception, e:85 except Exception as e:
86 log.Warn("Upload of '%s' failed (attempt %s): %s: %s"86 log.Warn("Upload of '%s' failed (attempt %s): %s: %s"
87 % (remote_filename, n, e.__class__.__name__, str(e)))87 % (remote_filename, n, e.__class__.__name__, str(e)))
88 log.Debug("Backtrace of previous error: %s"88 log.Debug("Backtrace of previous error: %s"
@@ -102,10 +102,10 @@
102 f.write(chunk)102 f.write(chunk)
103 local_path.setdata()103 local_path.setdata()
104 return104 return
105 except self.resp_exc, resperr:105 except self.resp_exc as resperr:
106 log.Warn("Download of '%s' failed (attempt %s): CloudFiles returned: %s %s"106 log.Warn("Download of '%s' failed (attempt %s): CloudFiles returned: %s %s"
107 % (remote_filename, n, resperr.status, resperr.reason))107 % (remote_filename, n, resperr.status, resperr.reason))
108 except Exception, e:108 except Exception as e:
109 log.Warn("Download of '%s' failed (attempt %s): %s: %s"109 log.Warn("Download of '%s' failed (attempt %s): %s: %s"
110 % (remote_filename, n, e.__class__.__name__, str(e)))110 % (remote_filename, n, e.__class__.__name__, str(e)))
111 log.Debug("Backtrace of previous error: %s"111 log.Debug("Backtrace of previous error: %s"
@@ -128,10 +128,10 @@
128 objs = self.container.list_objects(marker=keys[-1])128 objs = self.container.list_objects(marker=keys[-1])
129 keys += objs129 keys += objs
130 return keys130 return keys
131 except self.resp_exc, resperr:131 except self.resp_exc as resperr:
132 log.Warn("Listing of '%s' failed (attempt %s): CloudFiles returned: %s %s"132 log.Warn("Listing of '%s' failed (attempt %s): CloudFiles returned: %s %s"
133 % (self.container, n, resperr.status, resperr.reason))133 % (self.container, n, resperr.status, resperr.reason))
134 except Exception, e:134 except Exception as e:
135 log.Warn("Listing of '%s' failed (attempt %s): %s: %s"135 log.Warn("Listing of '%s' failed (attempt %s): %s: %s"
136 % (self.container, n, e.__class__.__name__, str(e)))136 % (self.container, n, e.__class__.__name__, str(e)))
137 log.Debug("Backtrace of previous error: %s"137 log.Debug("Backtrace of previous error: %s"
@@ -148,14 +148,14 @@
148 try:148 try:
149 self.container.delete_object(remote_filename)149 self.container.delete_object(remote_filename)
150 return150 return
151 except self.resp_exc, resperr:151 except self.resp_exc as resperr:
152 if n > 1 and resperr.status == 404:152 if n > 1 and resperr.status == 404:
153 # We failed on a timeout, but delete succeeded on the server153 # We failed on a timeout, but delete succeeded on the server
154 log.Warn("Delete of '%s' missing after retry - must have succeded earler" % remote_filename )154 log.Warn("Delete of '%s' missing after retry - must have succeded earler" % remote_filename )
155 return155 return
156 log.Warn("Delete of '%s' failed (attempt %s): CloudFiles returned: %s %s"156 log.Warn("Delete of '%s' failed (attempt %s): CloudFiles returned: %s %s"
157 % (remote_filename, n, resperr.status, resperr.reason))157 % (remote_filename, n, resperr.status, resperr.reason))
158 except Exception, e:158 except Exception as e:
159 log.Warn("Delete of '%s' failed (attempt %s): %s: %s"159 log.Warn("Delete of '%s' failed (attempt %s): %s: %s"
160 % (remote_filename, n, e.__class__.__name__, str(e)))160 % (remote_filename, n, e.__class__.__name__, str(e)))
161 log.Debug("Backtrace of previous error: %s"161 log.Debug("Backtrace of previous error: %s"
@@ -179,7 +179,7 @@
179 return {'size': sobject.size}179 return {'size': sobject.size}
180 except NoSuchObject:180 except NoSuchObject:
181 return {'size': -1}181 return {'size': -1}
182 except Exception, e:182 except Exception as e:
183 log.Warn("Error querying '%s/%s': %s"183 log.Warn("Error querying '%s/%s': %s"
184 "" % (self.container,184 "" % (self.container,
185 filename,185 filename,
186186
=== modified file 'duplicity/backends/_cf_pyrax.py'
--- duplicity/backends/_cf_pyrax.py 2013-12-27 06:39:00 +0000
+++ duplicity/backends/_cf_pyrax.py 2014-04-17 22:26:47 +0000
@@ -45,24 +45,24 @@
4545
46 conn_kwargs = {}46 conn_kwargs = {}
4747
48 if not os.environ.has_key('CLOUDFILES_USERNAME'):48 if 'CLOUDFILES_USERNAME' not in os.environ:
49 raise BackendException('CLOUDFILES_USERNAME environment variable'49 raise BackendException('CLOUDFILES_USERNAME environment variable'
50 'not set.')50 'not set.')
5151
52 if not os.environ.has_key('CLOUDFILES_APIKEY'):52 if 'CLOUDFILES_APIKEY' not in os.environ:
53 raise BackendException('CLOUDFILES_APIKEY environment variable not set.')53 raise BackendException('CLOUDFILES_APIKEY environment variable not set.')
5454
55 conn_kwargs['username'] = os.environ['CLOUDFILES_USERNAME']55 conn_kwargs['username'] = os.environ['CLOUDFILES_USERNAME']
56 conn_kwargs['api_key'] = os.environ['CLOUDFILES_APIKEY']56 conn_kwargs['api_key'] = os.environ['CLOUDFILES_APIKEY']
5757
58 if os.environ.has_key('CLOUDFILES_REGION'):58 if 'CLOUDFILES_REGION' in os.environ:
59 conn_kwargs['region'] = os.environ['CLOUDFILES_REGION']59 conn_kwargs['region'] = os.environ['CLOUDFILES_REGION']
6060
61 container = parsed_url.path.lstrip('/')61 container = parsed_url.path.lstrip('/')
6262
63 try:63 try:
64 pyrax.set_credentials(**conn_kwargs)64 pyrax.set_credentials(**conn_kwargs)
65 except Exception, e:65 except Exception as e:
66 log.FatalError("Connection failed, please check your credentials: %s %s"66 log.FatalError("Connection failed, please check your credentials: %s %s"
67 % (e.__class__.__name__, str(e)),67 % (e.__class__.__name__, str(e)),
68 log.ErrorCode.connection_failed)68 log.ErrorCode.connection_failed)
@@ -81,10 +81,10 @@
81 try:81 try:
82 self.container.upload_file(source_path.name, remote_filename)82 self.container.upload_file(source_path.name, remote_filename)
83 return83 return
84 except self.client_exc, error:84 except self.client_exc as error:
85 log.Warn("Upload of '%s' failed (attempt %d): pyrax returned: %s %s"85 log.Warn("Upload of '%s' failed (attempt %d): pyrax returned: %s %s"
86 % (remote_filename, n, error.__class__.__name__, error.message))86 % (remote_filename, n, error.__class__.__name__, error.message))
87 except Exception, e:87 except Exception as e:
88 log.Warn("Upload of '%s' failed (attempt %s): %s: %s"88 log.Warn("Upload of '%s' failed (attempt %s): %s: %s"
89 % (remote_filename, n, e.__class__.__name__, str(e)))89 % (remote_filename, n, e.__class__.__name__, str(e)))
90 log.Debug("Backtrace of previous error: %s"90 log.Debug("Backtrace of previous error: %s"
@@ -105,10 +105,10 @@
105 return105 return
106 except self.nso_exc:106 except self.nso_exc:
107 return107 return
108 except self.client_exc, resperr:108 except self.client_exc as resperr:
109 log.Warn("Download of '%s' failed (attempt %s): pyrax returned: %s %s"109 log.Warn("Download of '%s' failed (attempt %s): pyrax returned: %s %s"
110 % (remote_filename, n, resperr.__class__.__name__, resperr.message))110 % (remote_filename, n, resperr.__class__.__name__, resperr.message))
111 except Exception, e:111 except Exception as e:
112 log.Warn("Download of '%s' failed (attempt %s): %s: %s"112 log.Warn("Download of '%s' failed (attempt %s): %s: %s"
113 % (remote_filename, n, e.__class__.__name__, str(e)))113 % (remote_filename, n, e.__class__.__name__, str(e)))
114 log.Debug("Backtrace of previous error: %s"114 log.Debug("Backtrace of previous error: %s"
@@ -131,10 +131,10 @@
131 objs = self.container.get_object_names(marker = keys[-1])131 objs = self.container.get_object_names(marker = keys[-1])
132 keys += objs132 keys += objs
133 return keys133 return keys
134 except self.client_exc, resperr:134 except self.client_exc as resperr:
135 log.Warn("Listing of '%s' failed (attempt %s): pyrax returned: %s %s"135 log.Warn("Listing of '%s' failed (attempt %s): pyrax returned: %s %s"
136 % (self.container, n, resperr.__class__.__name__, resperr.message))136 % (self.container, n, resperr.__class__.__name__, resperr.message))
137 except Exception, e:137 except Exception as e:
138 log.Warn("Listing of '%s' failed (attempt %s): %s: %s"138 log.Warn("Listing of '%s' failed (attempt %s): %s: %s"
139 % (self.container, n, e.__class__.__name__, str(e)))139 % (self.container, n, e.__class__.__name__, str(e)))
140 log.Debug("Backtrace of previous error: %s"140 log.Debug("Backtrace of previous error: %s"
@@ -151,14 +151,14 @@
151 try:151 try:
152 self.container.delete_object(remote_filename)152 self.container.delete_object(remote_filename)
153 return153 return
154 except self.client_exc, resperr:154 except self.client_exc as resperr:
155 if n > 1 and resperr.status == 404:155 if n > 1 and resperr.status == 404:
156 # We failed on a timeout, but delete succeeded on the server156 # We failed on a timeout, but delete succeeded on the server
157 log.Warn("Delete of '%s' missing after retry - must have succeded earler" % remote_filename)157 log.Warn("Delete of '%s' missing after retry - must have succeded earler" % remote_filename)
158 return158 return
159 log.Warn("Delete of '%s' failed (attempt %s): pyrax returned: %s %s"159 log.Warn("Delete of '%s' failed (attempt %s): pyrax returned: %s %s"
160 % (remote_filename, n, resperr.__class__.__name__, resperr.message))160 % (remote_filename, n, resperr.__class__.__name__, resperr.message))
161 except Exception, e:161 except Exception as e:
162 log.Warn("Delete of '%s' failed (attempt %s): %s: %s"162 log.Warn("Delete of '%s' failed (attempt %s): %s: %s"
163 % (remote_filename, n, e.__class__.__name__, str(e)))163 % (remote_filename, n, e.__class__.__name__, str(e)))
164 log.Debug("Backtrace of previous error: %s"164 log.Debug("Backtrace of previous error: %s"
@@ -181,7 +181,7 @@
181 return {'size': sobject.total_bytes}181 return {'size': sobject.total_bytes}
182 except self.nso_exc:182 except self.nso_exc:
183 return {'size': -1}183 return {'size': -1}
184 except Exception, e:184 except Exception as e:
185 log.Warn("Error querying '%s/%s': %s"185 log.Warn("Error querying '%s/%s': %s"
186 "" % (self.container,186 "" % (self.container,
187 filename,187 filename,
188188
=== modified file 'duplicity/backends/_ssh_paramiko.py'
--- duplicity/backends/_ssh_paramiko.py 2013-12-30 16:01:49 +0000
+++ duplicity/backends/_ssh_paramiko.py 2014-04-17 22:26:47 +0000
@@ -134,7 +134,7 @@
134 try:134 try:
135 if os.path.isfile("/etc/ssh/ssh_known_hosts"):135 if os.path.isfile("/etc/ssh/ssh_known_hosts"):
136 self.client.load_system_host_keys("/etc/ssh/ssh_known_hosts")136 self.client.load_system_host_keys("/etc/ssh/ssh_known_hosts")
137 except Exception, e:137 except Exception as e:
138 raise BackendException("could not load /etc/ssh/ssh_known_hosts, maybe corrupt?")138 raise BackendException("could not load /etc/ssh/ssh_known_hosts, maybe corrupt?")
139 try:139 try:
140 # use load_host_keys() to signal it's writable to paramiko140 # use load_host_keys() to signal it's writable to paramiko
@@ -144,7 +144,7 @@
144 self.client.load_host_keys(file)144 self.client.load_host_keys(file)
145 else:145 else:
146 self.client._host_keys_filename = file146 self.client._host_keys_filename = file
147 except Exception, e:147 except Exception as e:
148 raise BackendException("could not load ~/.ssh/known_hosts, maybe corrupt?")148 raise BackendException("could not load ~/.ssh/known_hosts, maybe corrupt?")
149149
150 """ the next block reorganizes all host parameters into a150 """ the next block reorganizes all host parameters into a
@@ -211,7 +211,7 @@
211 allow_agent=True, 211 allow_agent=True,
212 look_for_keys=True,212 look_for_keys=True,
213 key_filename=self.config['identityfile'])213 key_filename=self.config['identityfile'])
214 except Exception, e:214 except Exception as e:
215 raise BackendException("ssh connection to %s@%s:%d failed: %s" % (215 raise BackendException("ssh connection to %s@%s:%d failed: %s" % (
216 self.config['user'],216 self.config['user'],
217 self.config['hostname'],217 self.config['hostname'],
@@ -229,7 +229,7 @@
229 else:229 else:
230 try:230 try:
231 self.sftp=self.client.open_sftp()231 self.sftp=self.client.open_sftp()
232 except Exception, e:232 except Exception as e:
233 raise BackendException("sftp negotiation failed: %s" % e)233 raise BackendException("sftp negotiation failed: %s" % e)
234234
235235
@@ -244,17 +244,17 @@
244 continue244 continue
245 try:245 try:
246 attrs=self.sftp.stat(d)246 attrs=self.sftp.stat(d)
247 except IOError, e:247 except IOError as e:
248 if e.errno == errno.ENOENT:248 if e.errno == errno.ENOENT:
249 try:249 try:
250 self.sftp.mkdir(d)250 self.sftp.mkdir(d)
251 except Exception, e:251 except Exception as e:
252 raise BackendException("sftp mkdir %s failed: %s" % (self.sftp.normalize(".")+"/"+d,e))252 raise BackendException("sftp mkdir %s failed: %s" % (self.sftp.normalize(".")+"/"+d,e))
253 else:253 else:
254 raise BackendException("sftp stat %s failed: %s" % (self.sftp.normalize(".")+"/"+d,e))254 raise BackendException("sftp stat %s failed: %s" % (self.sftp.normalize(".")+"/"+d,e))
255 try:255 try:
256 self.sftp.chdir(d)256 self.sftp.chdir(d)
257 except Exception, e:257 except Exception as e:
258 raise BackendException("sftp chdir to %s failed: %s" % (self.sftp.normalize(".")+"/"+d,e))258 raise BackendException("sftp chdir to %s failed: %s" % (self.sftp.normalize(".")+"/"+d,e))
259259
260 def put(self, source_path, remote_filename = None):260 def put(self, source_path, remote_filename = None):
@@ -275,7 +275,7 @@
275 chan=self.client.get_transport().open_session()275 chan=self.client.get_transport().open_session()
276 chan.settimeout(globals.timeout)276 chan.settimeout(globals.timeout)
277 chan.exec_command("scp -t '%s'" % self.remote_dir) # scp in sink mode uses the arg as base directory277 chan.exec_command("scp -t '%s'" % self.remote_dir) # scp in sink mode uses the arg as base directory
278 except Exception, e:278 except Exception as e:
279 raise BackendException("scp execution failed: %s" % e)279 raise BackendException("scp execution failed: %s" % e)
280 # scp protocol: one 0x0 after startup, one after the Create meta, one after saving280 # scp protocol: one 0x0 after startup, one after the Create meta, one after saving
281 # if there's a problem: 0x1 or 0x02 and some error text281 # if there's a problem: 0x1 or 0x02 and some error text
@@ -298,9 +298,9 @@
298 try:298 try:
299 self.sftp.put(source_path.name,remote_filename)299 self.sftp.put(source_path.name,remote_filename)
300 return300 return
301 except Exception, e:301 except Exception as e:
302 raise BackendException("sftp put of %s (as %s) failed: %s" % (source_path.name,remote_filename,e))302 raise BackendException("sftp put of %s (as %s) failed: %s" % (source_path.name,remote_filename,e))
303 except Exception, e:303 except Exception as e:
304 log.Warn("%s (Try %d of %d) Will retry in %d seconds." % (e,n,globals.num_retries,self.retry_delay))304 log.Warn("%s (Try %d of %d) Will retry in %d seconds." % (e,n,globals.num_retries,self.retry_delay))
305 raise BackendException("Giving up trying to upload '%s' after %d attempts" % (remote_filename,n))305 raise BackendException("Giving up trying to upload '%s' after %d attempts" % (remote_filename,n))
306306
@@ -320,7 +320,7 @@
320 chan=self.client.get_transport().open_session()320 chan=self.client.get_transport().open_session()
321 chan.settimeout(globals.timeout)321 chan.settimeout(globals.timeout)
322 chan.exec_command("scp -f '%s/%s'" % (self.remote_dir,remote_filename))322 chan.exec_command("scp -f '%s/%s'" % (self.remote_dir,remote_filename))
323 except Exception, e:323 except Exception as e:
324 raise BackendException("scp execution failed: %s" % e)324 raise BackendException("scp execution failed: %s" % e)
325325
326 chan.send('\0') # overall ready indicator326 chan.send('\0') # overall ready indicator
@@ -343,7 +343,7 @@
343 buff=chan.recv(blocksize)343 buff=chan.recv(blocksize)
344 f.write(buff)344 f.write(buff)
345 togo-=len(buff)345 togo-=len(buff)
346 except Exception, e:346 except Exception as e:
347 raise BackendException("scp get %s failed: %s" % (remote_filename,e))347 raise BackendException("scp get %s failed: %s" % (remote_filename,e))
348348
349 msg=chan.recv(1) # check the final status349 msg=chan.recv(1) # check the final status
@@ -357,10 +357,10 @@
357 try:357 try:
358 self.sftp.get(remote_filename,local_path.name)358 self.sftp.get(remote_filename,local_path.name)
359 return359 return
360 except Exception, e:360 except Exception as e:
361 raise BackendException("sftp get of %s (to %s) failed: %s" % (remote_filename,local_path.name,e))361 raise BackendException("sftp get of %s (to %s) failed: %s" % (remote_filename,local_path.name,e))
362 local_path.setdata()362 local_path.setdata()
363 except Exception, e:363 except Exception as e:
364 log.Warn("%s (Try %d of %d) Will retry in %d seconds." % (e,n,globals.num_retries,self.retry_delay))364 log.Warn("%s (Try %d of %d) Will retry in %d seconds." % (e,n,globals.num_retries,self.retry_delay))
365 raise BackendException("Giving up trying to download '%s' after %d attempts" % (remote_filename,n))365 raise BackendException("Giving up trying to download '%s' after %d attempts" % (remote_filename,n))
366366
@@ -379,9 +379,9 @@
379 else:379 else:
380 try:380 try:
381 return self.sftp.listdir()381 return self.sftp.listdir()
382 except Exception, e:382 except Exception as e:
383 raise BackendException("sftp listing of %s failed: %s" % (self.sftp.getcwd(),e))383 raise BackendException("sftp listing of %s failed: %s" % (self.sftp.getcwd(),e))
384 except Exception, e:384 except Exception as e:
385 log.Warn("%s (Try %d of %d) Will retry in %d seconds." % (e,n,globals.num_retries,self.retry_delay))385 log.Warn("%s (Try %d of %d) Will retry in %d seconds." % (e,n,globals.num_retries,self.retry_delay))
386 raise BackendException("Giving up trying to list '%s' after %d attempts" % (self.remote_dir,n))386 raise BackendException("Giving up trying to list '%s' after %d attempts" % (self.remote_dir,n))
387387
@@ -397,12 +397,12 @@
397 else:397 else:
398 try:398 try:
399 self.sftp.remove(fn)399 self.sftp.remove(fn)
400 except Exception, e:400 except Exception as e:
401 raise BackendException("sftp rm %s failed: %s" % (fn,e))401 raise BackendException("sftp rm %s failed: %s" % (fn,e))
402402
403 # If we get here, we deleted this file successfully. Move on to the next one.403 # If we get here, we deleted this file successfully. Move on to the next one.
404 break404 break
405 except Exception, e:405 except Exception as e:
406 if n == globals.num_retries:406 if n == globals.num_retries:
407 log.FatalError(str(e), log.ErrorCode.backend_error)407 log.FatalError(str(e), log.ErrorCode.backend_error)
408 else:408 else:
@@ -416,7 +416,7 @@
416 chan=self.client.get_transport().open_session()416 chan=self.client.get_transport().open_session()
417 chan.settimeout(globals.timeout)417 chan.settimeout(globals.timeout)
418 chan.exec_command(cmd)418 chan.exec_command(cmd)
419 except Exception, e:419 except Exception as e:
420 raise BackendException("%sexecution failed: %s" % (errorprefix,e))420 raise BackendException("%sexecution failed: %s" % (errorprefix,e))
421 output=chan.recv(-1)421 output=chan.recv(-1)
422 res=chan.recv_exit_status()422 res=chan.recv_exit_status()
@@ -434,7 +434,7 @@
434 sshconfig = paramiko.SSHConfig()434 sshconfig = paramiko.SSHConfig()
435 try:435 try:
436 sshconfig.parse(open(file))436 sshconfig.parse(open(file))
437 except Exception, e:437 except Exception as e:
438 raise BackendException("could not load '%s', maybe corrupt?" % (file))438 raise BackendException("could not load '%s', maybe corrupt?" % (file))
439 439
440 return sshconfig.lookup(host)440 return sshconfig.lookup(host)
441441
=== modified file 'duplicity/backends/botobackend.py'
--- duplicity/backends/botobackend.py 2014-04-16 20:45:09 +0000
+++ duplicity/backends/botobackend.py 2014-04-17 22:26:47 +0000
@@ -22,8 +22,8 @@
2222
23import duplicity.backend23import duplicity.backend
24from duplicity import globals24from duplicity import globals
25from _boto_multi import BotoBackend as BotoMultiUploadBackend25from ._boto_multi import BotoBackend as BotoMultiUploadBackend
26from _boto_single import BotoBackend as BotoSingleUploadBackend26from ._boto_single import BotoBackend as BotoSingleUploadBackend
2727
28if globals.s3_use_multiprocessing:28if globals.s3_use_multiprocessing:
29 duplicity.backend.register_backend("gs", BotoMultiUploadBackend)29 duplicity.backend.register_backend("gs", BotoMultiUploadBackend)
3030
=== modified file 'duplicity/backends/cfbackend.py'
--- duplicity/backends/cfbackend.py 2013-11-24 16:49:57 +0000
+++ duplicity/backends/cfbackend.py 2014-04-17 22:26:47 +0000
@@ -22,6 +22,6 @@
2222
23if (globals.cf_backend and23if (globals.cf_backend and
24 globals.cf_backend.lower().strip() == 'pyrax'):24 globals.cf_backend.lower().strip() == 'pyrax'):
25 import _cf_pyrax25 from . import _cf_pyrax
26else:26else:
27 import _cf_cloudfiles27 from . import _cf_cloudfiles
2828
=== modified file 'duplicity/backends/dpbxbackend.py'
--- duplicity/backends/dpbxbackend.py 2014-03-05 17:05:04 +0000
+++ duplicity/backends/dpbxbackend.py 2014-04-17 22:26:47 +0000
@@ -29,6 +29,7 @@
29import urllib29import urllib
30import re30import re
31import locale, sys31import locale, sys
32from functools import reduce
3233
33import traceback, StringIO34import traceback, StringIO
34from exceptions import Exception35from exceptions import Exception
@@ -80,14 +81,14 @@
8081
81 try:82 try:
82 return f(self, *args)83 return f(self, *args)
83 except TypeError, e:84 except TypeError as e:
84 log_exception(e)85 log_exception(e)
85 log.FatalError('dpbx type error "%s"' % (e,), log.ErrorCode.backend_code_error)86 log.FatalError('dpbx type error "%s"' % (e,), log.ErrorCode.backend_code_error)
86 except rest.ErrorResponse, e:87 except rest.ErrorResponse as e:
87 msg = e.user_error_msg or str(e)88 msg = e.user_error_msg or str(e)
88 log.Error('dpbx error: %s' % (msg,), log.ErrorCode.backend_command_error)89 log.Error('dpbx error: %s' % (msg,), log.ErrorCode.backend_command_error)
89 raise e90 raise e
90 except Exception, e:91 except Exception as e:
91 log_exception(e)92 log_exception(e)
92 log.Error('dpbx code error "%s"' % (e,), log.ErrorCode.backend_code_error)93 log.Error('dpbx code error "%s"' % (e,), log.ErrorCode.backend_code_error)
93 raise e94 raise e
@@ -119,7 +120,7 @@
119 120
120 def write_creds(self, token):121 def write_creds(self, token):
121 open(self.TOKEN_FILE, 'w').close() # create/reset file122 open(self.TOKEN_FILE, 'w').close() # create/reset file
122 os.chmod(self.TOKEN_FILE,0600) # set it -rw------ (NOOP in Windows?)123 os.chmod(self.TOKEN_FILE, 0o600) # set it -rw------ (NOOP in Windows?)
123 # now write the content124 # now write the content
124 f = open(self.TOKEN_FILE, 'w')125 f = open(self.TOKEN_FILE, 'w')
125 f.write("|".join([token.key, token.secret]))126 f.write("|".join([token.key, token.secret]))
@@ -159,7 +160,7 @@
159 if not self.sess.is_linked():160 if not self.sess.is_linked():
160 try: # to login to the box161 try: # to login to the box
161 self.sess.link()162 self.sess.link()
162 except rest.ErrorResponse, e:163 except rest.ErrorResponse as e:
163 log.FatalError('dpbx Error: %s\n' % str(e), log.ErrorCode.dpbx_nologin)164 log.FatalError('dpbx Error: %s\n' % str(e), log.ErrorCode.dpbx_nologin)
164 if not self.sess.is_linked(): # stil not logged in165 if not self.sess.is_linked(): # stil not logged in
165 log.FatalError("dpbx Cannot login: check your credentials",log.ErrorCode.dpbx_nologin)166 log.FatalError("dpbx Cannot login: check your credentials",log.ErrorCode.dpbx_nologin)
166167
=== modified file 'duplicity/backends/gdocsbackend.py'
--- duplicity/backends/gdocsbackend.py 2014-01-03 10:37:54 +0000
+++ duplicity/backends/gdocsbackend.py 2014-04-17 22:26:47 +0000
@@ -113,7 +113,7 @@
113 self.__handle_error("Failed to initialize upload of file '%s' to remote folder '%s'"113 self.__handle_error("Failed to initialize upload of file '%s' to remote folder '%s'"
114 % (source_path.get_filename(), self.folder.title.text), raise_errors)114 % (source_path.get_filename(), self.folder.title.text), raise_errors)
115 assert not file.close()115 assert not file.close()
116 except Exception, e:116 except Exception as e:
117 self.__handle_error("Failed to upload file '%s' to remote folder '%s': %s"117 self.__handle_error("Failed to upload file '%s' to remote folder '%s': %s"
118 % (source_path.get_filename(), self.folder.title.text, str(e)), raise_errors)118 % (source_path.get_filename(), self.folder.title.text, str(e)), raise_errors)
119119
@@ -132,7 +132,7 @@
132 else:132 else:
133 self.__handle_error("Failed to find file '%s' in remote folder '%s'"133 self.__handle_error("Failed to find file '%s' in remote folder '%s'"
134 % (remote_filename, self.folder.title.text), raise_errors)134 % (remote_filename, self.folder.title.text), raise_errors)
135 except Exception, e:135 except Exception as e:
136 self.__handle_error("Failed to download file '%s' in remote folder '%s': %s"136 self.__handle_error("Failed to download file '%s' in remote folder '%s': %s"
137 % (remote_filename, self.folder.title.text, str(e)), raise_errors)137 % (remote_filename, self.folder.title.text, str(e)), raise_errors)
138138
@@ -143,7 +143,7 @@
143 entries = self.__fetch_entries(self.folder.resource_id.text,143 entries = self.__fetch_entries(self.folder.resource_id.text,
144 GDocsBackend.BACKUP_DOCUMENT_TYPE)144 GDocsBackend.BACKUP_DOCUMENT_TYPE)
145 return [entry.title.text for entry in entries]145 return [entry.title.text for entry in entries]
146 except Exception, e:146 except Exception as e:
147 self.__handle_error("Failed to fetch list of files in remote folder '%s': %s"147 self.__handle_error("Failed to fetch list of files in remote folder '%s': %s"
148 % (self.folder.title.text, str(e)), raise_errors)148 % (self.folder.title.text, str(e)), raise_errors)
149149
@@ -166,7 +166,7 @@
166 else:166 else:
167 log.Warn("Failed to fetch file '%s' in remote folder '%s'"167 log.Warn("Failed to fetch file '%s' in remote folder '%s'"
168 % (filename, self.folder.title.text))168 % (filename, self.folder.title.text))
169 except Exception, e:169 except Exception as e:
170 self.__handle_error("Failed to remove file '%s' in remote folder '%s': %s"170 self.__handle_error("Failed to remove file '%s' in remote folder '%s': %s"
171 % (filename, self.folder.title.text, str(e)), raise_errors)171 % (filename, self.folder.title.text, str(e)), raise_errors)
172172
@@ -184,7 +184,7 @@
184 service='writely',184 service='writely',
185 captcha_token=captcha_token,185 captcha_token=captcha_token,
186 captcha_response=captcha_response)186 captcha_response=captcha_response)
187 except gdata.client.CaptchaChallenge, challenge:187 except gdata.client.CaptchaChallenge as challenge:
188 print('A captcha challenge in required. Please visit ' + challenge.captcha_url)188 print('A captcha challenge in required. Please visit ' + challenge.captcha_url)
189 answer = None189 answer = None
190 while not answer:190 while not answer:
@@ -196,7 +196,7 @@
196 'access code for using this Duplicity backend. Follow the instrucction in '196 'access code for using this Duplicity backend. Follow the instrucction in '
197 'http://www.google.com/support/accounts/bin/static.py?page=guide.cs&guide=1056283&topic=1056286 '197 'http://www.google.com/support/accounts/bin/static.py?page=guide.cs&guide=1056283&topic=1056286 '
198 'and create your application-specific password to run duplicity backups.')198 'and create your application-specific password to run duplicity backups.')
199 except Exception, e:199 except Exception as e:
200 self.__handle_error('Error while authenticating client: %s.' % str(e))200 self.__handle_error('Error while authenticating client: %s.' % str(e))
201201
202 def __fetch_entries(self, folder_id, type, title=None):202 def __fetch_entries(self, folder_id, type, title=None):
@@ -238,7 +238,7 @@
238238
239 # Done!239 # Done!
240 return result240 return result
241 except Exception, e:241 except Exception as e:
242 self.__handle_error('Error while fetching remote entries: %s.' % str(e))242 self.__handle_error('Error while fetching remote entries: %s.' % str(e))
243243
244duplicity.backend.register_backend('gdocs', GDocsBackend)244duplicity.backend.register_backend('gdocs', GDocsBackend)
245245
=== modified file 'duplicity/backends/giobackend.py'
--- duplicity/backends/giobackend.py 2013-12-27 06:39:00 +0000
+++ duplicity/backends/giobackend.py 2014-04-17 22:26:47 +0000
@@ -93,14 +93,14 @@
93 # Now make the directory if it doesn't exist93 # Now make the directory if it doesn't exist
94 try:94 try:
95 self.remote_file.make_directory_with_parents(None)95 self.remote_file.make_directory_with_parents(None)
96 except GLib.GError, e:96 except GLib.GError as e:
97 if e.code != Gio.IOErrorEnum.EXISTS:97 if e.code != Gio.IOErrorEnum.EXISTS:
98 raise98 raise
9999
100 def done_with_mount(self, fileobj, result, loop):100 def done_with_mount(self, fileobj, result, loop):
101 try:101 try:
102 fileobj.mount_enclosing_volume_finish(result)102 fileobj.mount_enclosing_volume_finish(result)
103 except GLib.GError, e:103 except GLib.GError as e:
104 # check for NOT_SUPPORTED because some schemas (e.g. file://) validly don't104 # check for NOT_SUPPORTED because some schemas (e.g. file://) validly don't
105 if e.code != Gio.IOErrorEnum.ALREADY_MOUNTED and e.code != Gio.IOErrorEnum.NOT_SUPPORTED:105 if e.code != Gio.IOErrorEnum.ALREADY_MOUNTED and e.code != Gio.IOErrorEnum.NOT_SUPPORTED:
106 log.FatalError(_("Connection failed, please check your password: %s")106 log.FatalError(_("Connection failed, please check your password: %s")
@@ -132,7 +132,7 @@
132 source.copy(target,132 source.copy(target,
133 Gio.FileCopyFlags.OVERWRITE | Gio.FileCopyFlags.NOFOLLOW_SYMLINKS,133 Gio.FileCopyFlags.OVERWRITE | Gio.FileCopyFlags.NOFOLLOW_SYMLINKS,
134 None, self.copy_progress, None)134 None, self.copy_progress, None)
135 except Exception, e:135 except Exception as e:
136 self.handle_error(raise_errors, e, op, source.get_parse_name(),136 self.handle_error(raise_errors, e, op, source.get_parse_name(),
137 target.get_parse_name())137 target.get_parse_name())
138138
@@ -163,7 +163,7 @@
163 while info:163 while info:
164 files.append(info.get_name())164 files.append(info.get_name())
165 info = enum.next_file(None)165 info = enum.next_file(None)
166 except Exception, e:166 except Exception as e:
167 self.handle_error(raise_errors, e, 'list',167 self.handle_error(raise_errors, e, 'list',
168 self.remote_file.get_parse_name())168 self.remote_file.get_parse_name())
169 return files169 return files
@@ -176,7 +176,7 @@
176 target_file = self.remote_file.get_child(filename)176 target_file = self.remote_file.get_child(filename)
177 try:177 try:
178 target_file.delete(None)178 target_file.delete(None)
179 except Exception, e:179 except Exception as e:
180 if isinstance(e, GLib.GError):180 if isinstance(e, GLib.GError):
181 if e.code == Gio.IOErrorEnum.NOT_FOUND:181 if e.code == Gio.IOErrorEnum.NOT_FOUND:
182 continue182 continue
@@ -193,7 +193,7 @@
193 info = target_file.query_info(attrs, Gio.FileQueryInfoFlags.NONE,193 info = target_file.query_info(attrs, Gio.FileQueryInfoFlags.NONE,
194 None)194 None)
195 return {'size': info.get_size()}195 return {'size': info.get_size()}
196 except Exception, e:196 except Exception as e:
197 if isinstance(e, GLib.GError):197 if isinstance(e, GLib.GError):
198 if e.code == Gio.IOErrorEnum.NOT_FOUND:198 if e.code == Gio.IOErrorEnum.NOT_FOUND:
199 return {'size': -1} # early exit, no need to retry199 return {'size': -1} # early exit, no need to retry
200200
=== modified file 'duplicity/backends/imapbackend.py'
--- duplicity/backends/imapbackend.py 2013-12-27 06:39:00 +0000
+++ duplicity/backends/imapbackend.py 2014-04-17 22:26:47 +0000
@@ -54,7 +54,7 @@
5454
55 # Set the password55 # Set the password
56 if ( not parsed_url.password ):56 if ( not parsed_url.password ):
57 if os.environ.has_key('IMAP_PASSWORD'):57 if 'IMAP_PASSWORD' in os.environ:
58 password = os.environ.get('IMAP_PASSWORD')58 password = os.environ.get('IMAP_PASSWORD')
59 else:59 else:
60 password = getpass.getpass("Enter account password: ")60 password = getpass.getpass("Enter account password: ")
6161
=== modified file 'duplicity/backends/localbackend.py'
--- duplicity/backends/localbackend.py 2013-12-27 06:39:00 +0000
+++ duplicity/backends/localbackend.py 2014-04-17 22:26:47 +0000
@@ -74,13 +74,13 @@
74 source_path.rename(target_path)74 source_path.rename(target_path)
75 except OSError:75 except OSError:
76 pass76 pass
77 except Exception, e:77 except Exception as e:
78 self.handle_error(e, 'put', source_path.name, target_path.name)78 self.handle_error(e, 'put', source_path.name, target_path.name)
79 else:79 else:
80 return80 return
81 try:81 try:
82 target_path.writefileobj(source_path.open("rb"))82 target_path.writefileobj(source_path.open("rb"))
83 except Exception, e:83 except Exception as e:
84 self.handle_error(e, 'put', source_path.name, target_path.name)84 self.handle_error(e, 'put', source_path.name, target_path.name)
8585
86 """If we get here, renaming failed previously"""86 """If we get here, renaming failed previously"""
@@ -93,7 +93,7 @@
93 source_path = self.remote_pathdir.append(filename)93 source_path = self.remote_pathdir.append(filename)
94 try:94 try:
95 local_path.writefileobj(source_path.open("rb"))95 local_path.writefileobj(source_path.open("rb"))
96 except Exception, e:96 except Exception as e:
97 self.handle_error(e, 'get', source_path.name, local_path.name)97 self.handle_error(e, 'get', source_path.name, local_path.name)
9898
99 def _list(self):99 def _list(self):
@@ -104,7 +104,7 @@
104 pass104 pass
105 try:105 try:
106 return self.remote_pathdir.listdir()106 return self.remote_pathdir.listdir()
107 except Exception, e:107 except Exception as e:
108 self.handle_error(e, 'list', self.remote_pathdir.name)108 self.handle_error(e, 'list', self.remote_pathdir.name)
109109
110 def delete(self, filename_list):110 def delete(self, filename_list):
@@ -113,7 +113,7 @@
113 for filename in filename_list:113 for filename in filename_list:
114 try:114 try:
115 self.remote_pathdir.append(filename).delete()115 self.remote_pathdir.append(filename).delete()
116 except Exception, e:116 except Exception as e:
117 self.handle_error(e, 'delete', self.remote_pathdir.append(filename).name)117 self.handle_error(e, 'delete', self.remote_pathdir.append(filename).name)
118118
119 def _query_file_info(self, filename):119 def _query_file_info(self, filename):
@@ -125,7 +125,7 @@
125 target_file.setdata()125 target_file.setdata()
126 size = target_file.getsize()126 size = target_file.getsize()
127 return {'size': size}127 return {'size': size}
128 except Exception, e:128 except Exception as e:
129 self.handle_error(e, 'query', target_file.name)129 self.handle_error(e, 'query', target_file.name)
130 return {'size': None}130 return {'size': None}
131131
132132
=== modified file 'duplicity/backends/megabackend.py'
--- duplicity/backends/megabackend.py 2013-12-27 06:39:00 +0000
+++ duplicity/backends/megabackend.py 2014-04-17 22:26:47 +0000
@@ -80,7 +80,7 @@
8080
81 self.client.upload(source_path.get_canonical(), self.folder, dest_filename=remote_filename)81 self.client.upload(source_path.get_canonical(), self.folder, dest_filename=remote_filename)
8282
83 except Exception, e:83 except Exception as e:
84 self.__handle_error("Failed to upload file '%s' to remote folder '%s': %s"84 self.__handle_error("Failed to upload file '%s' to remote folder '%s': %s"
85 % (source_path.get_canonical(), self.__get_node_name(self.folder), str(e)), raise_errors)85 % (source_path.get_canonical(), self.__get_node_name(self.folder), str(e)), raise_errors)
8686
@@ -100,7 +100,7 @@
100 else:100 else:
101 self.__handle_error("Failed to find file '%s' in remote folder '%s'"101 self.__handle_error("Failed to find file '%s' in remote folder '%s'"
102 % (remote_filename, self.__get_node_name(self.folder)), raise_errors)102 % (remote_filename, self.__get_node_name(self.folder)), raise_errors)
103 except Exception, e:103 except Exception as e:
104 self.__handle_error("Failed to download file '%s' in remote folder '%s': %s"104 self.__handle_error("Failed to download file '%s' in remote folder '%s': %s"
105 % (remote_filename, self.__get_node_name(self.folder), str(e)), raise_errors)105 % (remote_filename, self.__get_node_name(self.folder), str(e)), raise_errors)
106106
@@ -110,7 +110,7 @@
110 try:110 try:
111 entries = self.client.get_files_in_node(self.folder)111 entries = self.client.get_files_in_node(self.folder)
112 return [ self.client.get_name_from_file({entry:entries[entry]}) for entry in entries]112 return [ self.client.get_name_from_file({entry:entries[entry]}) for entry in entries]
113 except Exception, e:113 except Exception as e:
114 self.__handle_error("Failed to fetch list of files in remote folder '%s': %s"114 self.__handle_error("Failed to fetch list of files in remote folder '%s': %s"
115 % (self.__get_node_name(self.folder), str(e)), raise_errors)115 % (self.__get_node_name(self.folder), str(e)), raise_errors)
116116
@@ -129,7 +129,7 @@
129 else:129 else:
130 log.Warn("Failed to fetch file '%s' in remote folder '%s'"130 log.Warn("Failed to fetch file '%s' in remote folder '%s'"
131 % (filename, self.__get_node_name(self.folder)))131 % (filename, self.__get_node_name(self.folder)))
132 except Exception, e:132 except Exception as e:
133 self.__handle_error("Failed to remove file '%s' in remote folder '%s': %s"133 self.__handle_error("Failed to remove file '%s' in remote folder '%s': %s"
134 % (filename, self.__get_node_name(self.folder), str(e)), raise_errors)134 % (filename, self.__get_node_name(self.folder), str(e)), raise_errors)
135135
@@ -147,7 +147,7 @@
147 def __authorize(self, email, password):147 def __authorize(self, email, password):
148 try:148 try:
149 self.client.login(email, password)149 self.client.login(email, password)
150 except Exception, e:150 except Exception as e:
151 self.__handle_error('Error while authenticating client: %s.' % str(e))151 self.__handle_error('Error while authenticating client: %s.' % str(e))
152152
153 def __filter_entries(self, entries, parent_id=None, title=None, type=None):153 def __filter_entries(self, entries, parent_id=None, title=None, type=None):
@@ -169,7 +169,7 @@
169 result.update({k:v})169 result.update({k:v})
170170
171 return result171 return result
172 except Exception, e:172 except Exception as e:
173 self.__handle_error('Error while fetching remote entries: %s.' % str(e))173 self.__handle_error('Error while fetching remote entries: %s.' % str(e))
174174
175duplicity.backend.register_backend('mega', MegaBackend)175duplicity.backend.register_backend('mega', MegaBackend)
176176
=== modified file 'duplicity/backends/sshbackend.py'
--- duplicity/backends/sshbackend.py 2012-05-16 11:03:20 +0000
+++ duplicity/backends/sshbackend.py 2014-04-17 22:26:47 +0000
@@ -26,11 +26,11 @@
2626
27if (globals.ssh_backend and27if (globals.ssh_backend and
28 globals.ssh_backend.lower().strip() == 'pexpect'):28 globals.ssh_backend.lower().strip() == 'pexpect'):
29 import _ssh_pexpect29 from . import _ssh_pexpect
30else:30else:
31 # take user by the hand to prevent typo driven bug reports31 # take user by the hand to prevent typo driven bug reports
32 if globals.ssh_backend.lower().strip() != 'paramiko':32 if globals.ssh_backend.lower().strip() != 'paramiko':
33 log.Warn(_("Warning: Selected ssh backend '%s' is neither 'paramiko nor 'pexpect'. Will use default paramiko instead.") % globals.ssh_backend)33 log.Warn(_("Warning: Selected ssh backend '%s' is neither 'paramiko nor 'pexpect'. Will use default paramiko instead.") % globals.ssh_backend)
34 warn_option("--scp-command", globals.scp_command)34 warn_option("--scp-command", globals.scp_command)
35 warn_option("--sftp-command", globals.sftp_command)35 warn_option("--sftp-command", globals.sftp_command)
36 import _ssh_paramiko36 from . import _ssh_paramiko
3737
=== modified file 'duplicity/backends/swiftbackend.py'
--- duplicity/backends/swiftbackend.py 2013-12-27 06:39:00 +0000
+++ duplicity/backends/swiftbackend.py 2014-04-17 22:26:47 +0000
@@ -44,20 +44,20 @@
44 conn_kwargs = {}44 conn_kwargs = {}
4545
46 # if the user has already authenticated46 # if the user has already authenticated
47 if os.environ.has_key('SWIFT_PREAUTHURL') and os.environ.has_key('SWIFT_PREAUTHTOKEN'):47 if 'SWIFT_PREAUTHURL' in os.environ and 'SWIFT_PREAUTHTOKEN' in os.environ:
48 conn_kwargs['preauthurl'] = os.environ['SWIFT_PREAUTHURL']48 conn_kwargs['preauthurl'] = os.environ['SWIFT_PREAUTHURL']
49 conn_kwargs['preauthtoken'] = os.environ['SWIFT_PREAUTHTOKEN'] 49 conn_kwargs['preauthtoken'] = os.environ['SWIFT_PREAUTHTOKEN']
50 50
51 else:51 else:
52 if not os.environ.has_key('SWIFT_USERNAME'):52 if 'SWIFT_USERNAME' not in os.environ:
53 raise BackendException('SWIFT_USERNAME environment variable '53 raise BackendException('SWIFT_USERNAME environment variable '
54 'not set.')54 'not set.')
5555
56 if not os.environ.has_key('SWIFT_PASSWORD'):56 if 'SWIFT_PASSWORD' not in os.environ:
57 raise BackendException('SWIFT_PASSWORD environment variable '57 raise BackendException('SWIFT_PASSWORD environment variable '
58 'not set.')58 'not set.')
5959
60 if not os.environ.has_key('SWIFT_AUTHURL'):60 if 'SWIFT_AUTHURL' not in os.environ:
61 raise BackendException('SWIFT_AUTHURL environment variable '61 raise BackendException('SWIFT_AUTHURL environment variable '
62 'not set.')62 'not set.')
6363
@@ -65,11 +65,11 @@
65 conn_kwargs['key'] = os.environ['SWIFT_PASSWORD']65 conn_kwargs['key'] = os.environ['SWIFT_PASSWORD']
66 conn_kwargs['authurl'] = os.environ['SWIFT_AUTHURL']66 conn_kwargs['authurl'] = os.environ['SWIFT_AUTHURL']
6767
68 if os.environ.has_key('SWIFT_AUTHVERSION'):68 if 'SWIFT_AUTHVERSION' in os.environ:
69 conn_kwargs['auth_version'] = os.environ['SWIFT_AUTHVERSION']69 conn_kwargs['auth_version'] = os.environ['SWIFT_AUTHVERSION']
70 else:70 else:
71 conn_kwargs['auth_version'] = '1'71 conn_kwargs['auth_version'] = '1'
72 if os.environ.has_key('SWIFT_TENANTNAME'):72 if 'SWIFT_TENANTNAME' in os.environ:
73 conn_kwargs['tenant_name'] = os.environ['SWIFT_TENANTNAME']73 conn_kwargs['tenant_name'] = os.environ['SWIFT_TENANTNAME']
74 74
75 self.container = parsed_url.path.lstrip('/')75 self.container = parsed_url.path.lstrip('/')
@@ -77,7 +77,7 @@
77 try:77 try:
78 self.conn = Connection(**conn_kwargs)78 self.conn = Connection(**conn_kwargs)
79 self.conn.put_container(self.container)79 self.conn.put_container(self.container)
80 except Exception, e:80 except Exception as e:
81 log.FatalError("Connection failed: %s %s"81 log.FatalError("Connection failed: %s %s"
82 % (e.__class__.__name__, str(e)),82 % (e.__class__.__name__, str(e)),
83 log.ErrorCode.connection_failed)83 log.ErrorCode.connection_failed)
@@ -93,10 +93,10 @@
93 remote_filename, 93 remote_filename,
94 file(source_path.name))94 file(source_path.name))
95 return95 return
96 except self.resp_exc, error:96 except self.resp_exc as error:
97 log.Warn("Upload of '%s' failed (attempt %d): Swift server returned: %s %s"97 log.Warn("Upload of '%s' failed (attempt %d): Swift server returned: %s %s"
98 % (remote_filename, n, error.http_status, error.message))98 % (remote_filename, n, error.http_status, error.message))
99 except Exception, e:99 except Exception as e:
100 log.Warn("Upload of '%s' failed (attempt %s): %s: %s"100 log.Warn("Upload of '%s' failed (attempt %s): %s: %s"
101 % (remote_filename, n, e.__class__.__name__, str(e)))101 % (remote_filename, n, e.__class__.__name__, str(e)))
102 log.Debug("Backtrace of previous error: %s"102 log.Debug("Backtrace of previous error: %s"
@@ -117,10 +117,10 @@
117 f.write(chunk)117 f.write(chunk)
118 local_path.setdata()118 local_path.setdata()
119 return119 return
120 except self.resp_exc, resperr:120 except self.resp_exc as resperr:
121 log.Warn("Download of '%s' failed (attempt %s): Swift server returned: %s %s"121 log.Warn("Download of '%s' failed (attempt %s): Swift server returned: %s %s"
122 % (remote_filename, n, resperr.http_status, resperr.message))122 % (remote_filename, n, resperr.http_status, resperr.message))
123 except Exception, e:123 except Exception as e:
124 log.Warn("Download of '%s' failed (attempt %s): %s: %s"124 log.Warn("Download of '%s' failed (attempt %s): %s: %s"
125 % (remote_filename, n, e.__class__.__name__, str(e)))125 % (remote_filename, n, e.__class__.__name__, str(e)))
126 log.Debug("Backtrace of previous error: %s"126 log.Debug("Backtrace of previous error: %s"
@@ -139,10 +139,10 @@
139 # to make multiple requests to get them all.139 # to make multiple requests to get them all.
140 headers, objs = self.conn.get_container(self.container)140 headers, objs = self.conn.get_container(self.container)
141 return [ o['name'] for o in objs ]141 return [ o['name'] for o in objs ]
142 except self.resp_exc, resperr:142 except self.resp_exc as resperr:
143 log.Warn("Listing of '%s' failed (attempt %s): Swift server returned: %s %s"143 log.Warn("Listing of '%s' failed (attempt %s): Swift server returned: %s %s"
144 % (self.container, n, resperr.http_status, resperr.message))144 % (self.container, n, resperr.http_status, resperr.message))
145 except Exception, e:145 except Exception as e:
146 log.Warn("Listing of '%s' failed (attempt %s): %s: %s"146 log.Warn("Listing of '%s' failed (attempt %s): %s: %s"
147 % (self.container, n, e.__class__.__name__, str(e)))147 % (self.container, n, e.__class__.__name__, str(e)))
148 log.Debug("Backtrace of previous error: %s"148 log.Debug("Backtrace of previous error: %s"
@@ -159,14 +159,14 @@
159 try:159 try:
160 self.conn.delete_object(self.container, remote_filename)160 self.conn.delete_object(self.container, remote_filename)
161 return161 return
162 except self.resp_exc, resperr:162 except self.resp_exc as resperr:
163 if n > 1 and resperr.http_status == 404:163 if n > 1 and resperr.http_status == 404:
164 # We failed on a timeout, but delete succeeded on the server164 # We failed on a timeout, but delete succeeded on the server
165 log.Warn("Delete of '%s' missing after retry - must have succeded earlier" % remote_filename )165 log.Warn("Delete of '%s' missing after retry - must have succeded earlier" % remote_filename )
166 return166 return
167 log.Warn("Delete of '%s' failed (attempt %s): Swift server returned: %s %s"167 log.Warn("Delete of '%s' failed (attempt %s): Swift server returned: %s %s"
168 % (remote_filename, n, resperr.http_status, resperr.message))168 % (remote_filename, n, resperr.http_status, resperr.message))
169 except Exception, e:169 except Exception as e:
170 log.Warn("Delete of '%s' failed (attempt %s): %s: %s"170 log.Warn("Delete of '%s' failed (attempt %s): %s: %s"
171 % (remote_filename, n, e.__class__.__name__, str(e)))171 % (remote_filename, n, e.__class__.__name__, str(e)))
172 log.Debug("Backtrace of previous error: %s"172 log.Debug("Backtrace of previous error: %s"
@@ -186,10 +186,10 @@
186 def _query_file_info(self, filename, raise_errors=False):186 def _query_file_info(self, filename, raise_errors=False):
187 try:187 try:
188 sobject = self.conn.head_object(self.container, filename)188 sobject = self.conn.head_object(self.container, filename)
189 return {'size': long(sobject['content-length'])}189 return {'size': int(sobject['content-length'])}
190 except self.resp_exc:190 except self.resp_exc:
191 return {'size': -1}191 return {'size': -1}
192 except Exception, e:192 except Exception as e:
193 log.Warn("Error querying '%s/%s': %s"193 log.Warn("Error querying '%s/%s': %s"
194 "" % (self.container,194 "" % (self.container,
195 filename,195 filename,
196196
=== modified file 'duplicity/backends/webdavbackend.py'
--- duplicity/backends/webdavbackend.py 2014-04-16 20:45:09 +0000
+++ duplicity/backends/webdavbackend.py 2014-04-17 22:26:47 +0000
@@ -96,7 +96,7 @@
96 def request(self, *args, **kwargs):96 def request(self, *args, **kwargs):
97 try:97 try:
98 return httplib.HTTPSConnection.request(self, *args, **kwargs)98 return httplib.HTTPSConnection.request(self, *args, **kwargs)
99 except ssl.SSLError, e:99 except ssl.SSLError as e:
100 # encapsulate ssl errors100 # encapsulate ssl errors
101 raise BackendException("SSL failed: %s" % str(e),log.ErrorCode.backend_error)101 raise BackendException("SSL failed: %s" % str(e),log.ErrorCode.backend_error)
102102
@@ -293,7 +293,7 @@
293 if filename:293 if filename:
294 result.append(filename)294 result.append(filename)
295 return result295 return result
296 except Exception, e:296 except Exception as e:
297 raise e297 raise e
298 finally:298 finally:
299 if response: response.close()299 if response: response.close()
@@ -383,7 +383,7 @@
383 reason = response.reason383 reason = response.reason
384 response.close()384 response.close()
385 raise BackendException("Bad status code %s reason %s." % (status,reason))385 raise BackendException("Bad status code %s reason %s." % (status,reason))
386 except Exception, e:386 except Exception as e:
387 raise e387 raise e
388 finally:388 finally:
389 if response: response.close()389 if response: response.close()
@@ -407,7 +407,7 @@
407 reason = response.reason407 reason = response.reason
408 response.close()408 response.close()
409 raise BackendException("Bad status code %s reason %s." % (status,reason))409 raise BackendException("Bad status code %s reason %s." % (status,reason))
410 except Exception, e:410 except Exception as e:
411 raise e411 raise e
412 finally:412 finally:
413 if response: response.close()413 if response: response.close()
@@ -429,7 +429,7 @@
429 reason = response.reason429 reason = response.reason
430 response.close()430 response.close()
431 raise BackendException("Bad status code %s reason %s." % (status,reason))431 raise BackendException("Bad status code %s reason %s." % (status,reason))
432 except Exception, e:432 except Exception as e:
433 raise e433 raise e
434 finally:434 finally:
435 if response: response.close()435 if response: response.close()
436436
=== modified file 'duplicity/cached_ops.py'
--- duplicity/cached_ops.py 2012-11-09 03:21:40 +0000
+++ duplicity/cached_ops.py 2014-04-17 22:26:47 +0000
@@ -34,7 +34,7 @@
34 def __call__(self, *args):34 def __call__(self, *args):
35 try:35 try:
36 return self.cache[args]36 return self.cache[args]
37 except (KeyError, TypeError), e:37 except (KeyError, TypeError) as e:
38 result = self.f(*args)38 result = self.f(*args)
39 if not isinstance(e, TypeError):39 if not isinstance(e, TypeError):
40 # TypeError most likely means that args is not hashable40 # TypeError most likely means that args is not hashable
4141
=== modified file 'duplicity/collections.py'
--- duplicity/collections.py 2014-01-17 16:44:46 +0000
+++ duplicity/collections.py 2014-04-17 22:26:47 +0000
@@ -96,7 +96,7 @@
96 self.set_manifest(filename)96 self.set_manifest(filename)
97 else:97 else:
98 assert pr.volume_number is not None98 assert pr.volume_number is not None
99 assert not self.volume_name_dict.has_key(pr.volume_number), \99 assert pr.volume_number not in self.volume_name_dict, \
100 (self.volume_name_dict, filename)100 (self.volume_name_dict, filename)
101 self.volume_name_dict[pr.volume_number] = filename101 self.volume_name_dict[pr.volume_number] = filename
102102
@@ -222,7 +222,7 @@
222 # public key w/o secret key222 # public key w/o secret key
223 try:223 try:
224 manifest_buffer = self.backend.get_data(self.remote_manifest_name)224 manifest_buffer = self.backend.get_data(self.remote_manifest_name)
225 except GPGError, message:225 except GPGError as message:
226 #TODO: We check for gpg v1 and v2 messages, should be an error code.226 #TODO: We check for gpg v1 and v2 messages, should be an error code.
227 if ("secret key not available" in message.args[0] or227 if ("secret key not available" in message.args[0] or
228 "No secret key" in message.args[0]):228 "No secret key" in message.args[0]):
@@ -916,7 +916,7 @@
916 # Build dictionary from end_times to lists of corresponding chains916 # Build dictionary from end_times to lists of corresponding chains
917 endtime_chain_dict = {}917 endtime_chain_dict = {}
918 for chain in chain_list:918 for chain in chain_list:
919 if endtime_chain_dict.has_key(chain.end_time):919 if chain.end_time in endtime_chain_dict:
920 endtime_chain_dict[chain.end_time].append(chain)920 endtime_chain_dict[chain.end_time].append(chain)
921 else:921 else:
922 endtime_chain_dict[chain.end_time] = [chain]922 endtime_chain_dict[chain.end_time] = [chain]
923923
=== modified file 'duplicity/commandline.py'
--- duplicity/commandline.py 2014-04-17 17:45:37 +0000
+++ duplicity/commandline.py 2014-04-17 22:26:47 +0000
@@ -109,7 +109,7 @@
109def check_time(option, opt, value):109def check_time(option, opt, value):
110 try:110 try:
111 return dup_time.genstrtotime(value)111 return dup_time.genstrtotime(value)
112 except dup_time.TimeException, e:112 except dup_time.TimeException as e:
113 raise optparse.OptionValueError(str(e))113 raise optparse.OptionValueError(str(e))
114114
115def check_verbosity(option, opt, value):115def check_verbosity(option, opt, value):
116116
=== modified file 'duplicity/diffdir.py'
--- duplicity/diffdir.py 2013-12-27 06:39:00 +0000
+++ duplicity/diffdir.py 2014-04-17 22:26:47 +0000
@@ -389,7 +389,7 @@
389 def read(self, length = -1):389 def read(self, length = -1):
390 try:390 try:
391 buf = self.infile.read(length)391 buf = self.infile.read(length)
392 except IOError, ex:392 except IOError as ex:
393 buf = ""393 buf = ""
394 log.Warn(_("Error %s getting delta for %s") % (str(ex), util.ufn(self.infile.name)))394 log.Warn(_("Error %s getting delta for %s") % (str(ex), util.ufn(self.infile.name)))
395 if stats:395 if stats:
@@ -461,7 +461,7 @@
461 TarBlockIter initializer461 TarBlockIter initializer
462 """462 """
463 self.input_iter = input_iter463 self.input_iter = input_iter
464 self.offset = 0l # total length of data read464 self.offset = 0 # total length of data read
465 self.process_waiting = False # process_continued has more blocks465 self.process_waiting = False # process_continued has more blocks
466 self.process_next_vol_number = None # next volume number to write in multivol466 self.process_next_vol_number = None # next volume number to write in multivol
467 self.previous_index = None # holds index of last block returned467 self.previous_index = None # holds index of last block returned
@@ -564,7 +564,7 @@
564 Return closing string for tarfile, reset offset564 Return closing string for tarfile, reset offset
565 """565 """
566 blocks, remainder = divmod(self.offset, tarfile.RECORDSIZE) #@UnusedVariable566 blocks, remainder = divmod(self.offset, tarfile.RECORDSIZE) #@UnusedVariable
567 self.offset = 0l567 self.offset = 0
568 return '\0' * (tarfile.RECORDSIZE - remainder) # remainder can be 0568 return '\0' * (tarfile.RECORDSIZE - remainder) # remainder can be 0
569569
570 def __iter__(self):570 def __iter__(self):
@@ -736,5 +736,5 @@
736 return 512 # set minimum of 512 bytes736 return 512 # set minimum of 512 bytes
737 else:737 else:
738 # Split file into about 2000 pieces, rounding to 512738 # Split file into about 2000 pieces, rounding to 512
739 file_blocksize = long((file_len / (2000 * 512)) * 512)739 file_blocksize = int((file_len / (2000 * 512)) * 512)
740 return min(file_blocksize, globals.max_blocksize)740 return min(file_blocksize, globals.max_blocksize)
741741
=== modified file 'duplicity/dup_temp.py'
--- duplicity/dup_temp.py 2013-12-27 06:39:00 +0000
+++ duplicity/dup_temp.py 2014-04-17 22:26:47 +0000
@@ -179,9 +179,9 @@
179 tgt = self.dirpath.append(self.remname)179 tgt = self.dirpath.append(self.remname)
180 src_iter = SrcIter(src)180 src_iter = SrcIter(src)
181 if pr.compressed:181 if pr.compressed:
182 gpg.GzipWriteFile(src_iter, tgt.name, size = sys.maxint)182 gpg.GzipWriteFile(src_iter, tgt.name, size = sys.maxsize)
183 elif pr.encrypted:183 elif pr.encrypted:
184 gpg.GPGWriteFile(src_iter, tgt.name, globals.gpg_profile, size = sys.maxint)184 gpg.GPGWriteFile(src_iter, tgt.name, globals.gpg_profile, size = sys.maxsize)
185 else:185 else:
186 os.system("cp -p \"%s\" \"%s\"" % (src.name, tgt.name))186 os.system("cp -p \"%s\" \"%s\"" % (src.name, tgt.name))
187 globals.backend.move(tgt) #@UndefinedVariable187 globals.backend.move(tgt) #@UndefinedVariable
@@ -195,7 +195,7 @@
195 src_iter = SrcIter(src)195 src_iter = SrcIter(src)
196 pr = file_naming.parse(self.permname)196 pr = file_naming.parse(self.permname)
197 if pr.compressed:197 if pr.compressed:
198 gpg.GzipWriteFile(src_iter, tgt.name, size = sys.maxint)198 gpg.GzipWriteFile(src_iter, tgt.name, size = sys.maxsize)
199 os.unlink(src.name)199 os.unlink(src.name)
200 else:200 else:
201 os.rename(src.name, tgt.name)201 os.rename(src.name, tgt.name)
202202
=== modified file 'duplicity/dup_threading.py'
--- duplicity/dup_threading.py 2010-07-22 19:15:11 +0000
+++ duplicity/dup_threading.py 2014-04-17 22:26:47 +0000
@@ -192,7 +192,7 @@
192 if state['error'] is None:192 if state['error'] is None:
193 return state['value']193 return state['value']
194 else:194 else:
195 raise state['error'], None, state['trace']195 raise state['error'].with_traceback(state['trace'])
196 finally:196 finally:
197 cv.release()197 cv.release()
198198
@@ -207,7 +207,7 @@
207 cv.release()207 cv.release()
208208
209 return (True, waiter)209 return (True, waiter)
210 except Exception, e:210 except Exception as e:
211 cv.acquire()211 cv.acquire()
212 state['done'] = True212 state['done'] = True
213 state['error'] = e213 state['error'] = e
214214
=== modified file 'duplicity/dup_time.py'
--- duplicity/dup_time.py 2011-11-03 11:27:45 +0000
+++ duplicity/dup_time.py 2014-04-17 22:26:47 +0000
@@ -62,7 +62,7 @@
62def setcurtime(time_in_secs = None):62def setcurtime(time_in_secs = None):
63 """Sets the current time in curtime and curtimestr"""63 """Sets the current time in curtime and curtimestr"""
64 global curtime, curtimestr64 global curtime, curtimestr
65 t = time_in_secs or long(time.time())65 t = time_in_secs or int(time.time())
66 assert type(t) in (types.LongType, types.IntType)66 assert type(t) in (types.LongType, types.IntType)
67 curtime, curtimestr = t, timetostring(t)67 curtime, curtimestr = t, timetostring(t)
6868
@@ -137,9 +137,9 @@
137 # even when we're not in the same timezone that wrote the137 # even when we're not in the same timezone that wrote the
138 # string138 # string
139 if len(timestring) == 16:139 if len(timestring) == 16:
140 return long(utc_in_secs)140 return int(utc_in_secs)
141 else:141 else:
142 return long(utc_in_secs + tzdtoseconds(timestring[19:]))142 return int(utc_in_secs + tzdtoseconds(timestring[19:]))
143 except (TypeError, ValueError, AssertionError):143 except (TypeError, ValueError, AssertionError):
144 return None144 return None
145145
@@ -169,7 +169,7 @@
169 if seconds == 1:169 if seconds == 1:
170 partlist.append("1 second")170 partlist.append("1 second")
171 elif not partlist or seconds > 1:171 elif not partlist or seconds > 1:
172 if isinstance(seconds, int) or isinstance(seconds, long):172 if isinstance(seconds, (types.LongType, types.IntType)):
173 partlist.append("%s seconds" % seconds)173 partlist.append("%s seconds" % seconds)
174 else:174 else:
175 partlist.append("%.2f seconds" % seconds)175 partlist.append("%.2f seconds" % seconds)
176176
=== modified file 'duplicity/file_naming.py'
--- duplicity/file_naming.py 2014-01-31 12:41:00 +0000
+++ duplicity/file_naming.py 2014-04-17 22:26:47 +0000
@@ -158,7 +158,7 @@
158 """158 """
159 Convert string s in base 36 to long int159 Convert string s in base 36 to long int
160 """160 """
161 total = 0L161 total = 0
162 for i in range(len(s)):162 for i in range(len(s)):
163 total *= 36163 total *= 36
164 digit_ord = ord(s[i])164 digit_ord = ord(s[i])
165165
=== modified file 'duplicity/globals.py'
--- duplicity/globals.py 2014-04-09 09:22:27 +0000
+++ duplicity/globals.py 2014-04-17 22:26:47 +0000
@@ -87,7 +87,7 @@
87gpg_options = ''87gpg_options = ''
8888
89# Maximum file blocksize89# Maximum file blocksize
90max_blocksize = 2048L90max_blocksize = 2048
9191
92# If true, filelists and directory statistics will be split on92# If true, filelists and directory statistics will be split on
93# nulls instead of newlines.93# nulls instead of newlines.
9494
=== modified file 'duplicity/gpg.py'
--- duplicity/gpg.py 2013-12-27 06:39:00 +0000
+++ duplicity/gpg.py 2014-04-17 22:26:47 +0000
@@ -215,7 +215,7 @@
215 msg += unicode(line.strip(), locale.getpreferredencoding(), 'replace') + u"\n"215 msg += unicode(line.strip(), locale.getpreferredencoding(), 'replace') + u"\n"
216 msg += u"===== End GnuPG log =====\n"216 msg += u"===== End GnuPG log =====\n"
217 if not (msg.find(u"invalid packet (ctb=14)") > -1):217 if not (msg.find(u"invalid packet (ctb=14)") > -1):
218 raise GPGError, msg218 raise GPGError(msg)
219 else:219 else:
220 return ""220 return ""
221221
222222
=== modified file 'duplicity/gpginterface.py'
--- duplicity/gpginterface.py 2013-12-27 06:39:00 +0000
+++ duplicity/gpginterface.py 2014-04-17 22:26:47 +0000
@@ -353,14 +353,14 @@
353 if attach_fhs == None: attach_fhs = {}353 if attach_fhs == None: attach_fhs = {}
354354
355 for std in _stds:355 for std in _stds:
356 if not attach_fhs.has_key(std) \356 if std not in attach_fhs \
357 and std not in create_fhs:357 and std not in create_fhs:
358 attach_fhs.setdefault(std, getattr(sys, std))358 attach_fhs.setdefault(std, getattr(sys, std))
359359
360 handle_passphrase = 0360 handle_passphrase = 0
361361
362 if self.passphrase != None \362 if self.passphrase != None \
363 and not attach_fhs.has_key('passphrase') \363 and 'passphrase' not in attach_fhs \
364 and 'passphrase' not in create_fhs:364 and 'passphrase' not in create_fhs:
365 handle_passphrase = 1365 handle_passphrase = 1
366 create_fhs.append('passphrase')366 create_fhs.append('passphrase')
@@ -384,18 +384,18 @@
384 process = Process()384 process = Process()
385385
386 for fh_name in create_fhs + attach_fhs.keys():386 for fh_name in create_fhs + attach_fhs.keys():
387 if not _fd_modes.has_key(fh_name):387 if fh_name not in _fd_modes:
388 raise KeyError, \388 raise KeyError(
389 "unrecognized filehandle name '%s'; must be one of %s" \389 "unrecognized filehandle name '%s'; must be one of %s" \
390 % (fh_name, _fd_modes.keys())390 % (fh_name, _fd_modes.keys()))
391391
392 for fh_name in create_fhs:392 for fh_name in create_fhs:
393 # make sure the user doesn't specify a filehandle393 # make sure the user doesn't specify a filehandle
394 # to be created *and* attached394 # to be created *and* attached
395 if attach_fhs.has_key(fh_name):395 if fh_name in attach_fhs:
396 raise ValueError, \396 raise ValueError(
397 "cannot have filehandle '%s' in both create_fhs and attach_fhs" \397 "cannot have filehandle '%s' in both create_fhs and attach_fhs" \
398 % fh_name398 % fh_name)
399399
400 pipe = os.pipe()400 pipe = os.pipe()
401 # fix by drt@un.bewaff.net noting401 # fix by drt@un.bewaff.net noting
@@ -660,7 +660,7 @@
660 if self.returned == None:660 if self.returned == None:
661 self.thread.join()661 self.thread.join()
662 if self.returned != 0:662 if self.returned != 0:
663 raise IOError, "GnuPG exited non-zero, with code %d" % (self.returned >> 8)663 raise IOError("GnuPG exited non-zero, with code %d" % (self.returned >> 8))
664664
665665
666def threaded_waitpid(process):666def threaded_waitpid(process):
667667
=== modified file 'duplicity/librsync.py'
--- duplicity/librsync.py 2010-11-20 15:39:00 +0000
+++ duplicity/librsync.py 2014-04-17 22:26:47 +0000
@@ -26,7 +26,7 @@
2626
27"""27"""
2828
29import _librsync29from . import _librsync
30import types, array30import types, array
3131
32blocksize = _librsync.RS_JOB_BLOCKSIZE32blocksize = _librsync.RS_JOB_BLOCKSIZE
@@ -90,7 +90,7 @@
90 self._add_to_inbuf()90 self._add_to_inbuf()
91 try:91 try:
92 self.eof, len_inbuf_read, cycle_out = self.maker.cycle(self.inbuf)92 self.eof, len_inbuf_read, cycle_out = self.maker.cycle(self.inbuf)
93 except _librsync.librsyncError, e:93 except _librsync.librsyncError as e:
94 raise librsyncError(str(e))94 raise librsyncError(str(e))
95 self.inbuf = self.inbuf[len_inbuf_read:]95 self.inbuf = self.inbuf[len_inbuf_read:]
96 self.outbuf.fromstring(cycle_out)96 self.outbuf.fromstring(cycle_out)
@@ -126,7 +126,7 @@
126 LikeFile.__init__(self, infile)126 LikeFile.__init__(self, infile)
127 try:127 try:
128 self.maker = _librsync.new_sigmaker(blocksize)128 self.maker = _librsync.new_sigmaker(blocksize)
129 except _librsync.librsyncError, e:129 except _librsync.librsyncError as e:
130 raise librsyncError(str(e))130 raise librsyncError(str(e))
131131
132class DeltaFile(LikeFile):132class DeltaFile(LikeFile):
@@ -148,7 +148,7 @@
148 assert not signature.close()148 assert not signature.close()
149 try:149 try:
150 self.maker = _librsync.new_deltamaker(sig_string)150 self.maker = _librsync.new_deltamaker(sig_string)
151 except _librsync.librsyncError, e:151 except _librsync.librsyncError as e:
152 raise librsyncError(str(e))152 raise librsyncError(str(e))
153153
154154
@@ -167,7 +167,7 @@
167 raise TypeError("basis_file must be a (true) file")167 raise TypeError("basis_file must be a (true) file")
168 try:168 try:
169 self.maker = _librsync.new_patchmaker(basis_file)169 self.maker = _librsync.new_patchmaker(basis_file)
170 except _librsync.librsyncError, e:170 except _librsync.librsyncError as e:
171 raise librsyncError(str(e))171 raise librsyncError(str(e))
172172
173173
@@ -182,7 +182,7 @@
182 """Return new signature instance"""182 """Return new signature instance"""
183 try:183 try:
184 self.sig_maker = _librsync.new_sigmaker(blocksize)184 self.sig_maker = _librsync.new_sigmaker(blocksize)
185 except _librsync.librsyncError, e:185 except _librsync.librsyncError as e:
186 raise librsyncError(str(e))186 raise librsyncError(str(e))
187 self.gotsig = None187 self.gotsig = None
188 self.buffer = ""188 self.buffer = ""
@@ -201,7 +201,7 @@
201 """Run self.buffer through sig_maker, add to self.sig_string"""201 """Run self.buffer through sig_maker, add to self.sig_string"""
202 try:202 try:
203 eof, len_buf_read, cycle_out = self.sig_maker.cycle(self.buffer)203 eof, len_buf_read, cycle_out = self.sig_maker.cycle(self.buffer)
204 except _librsync.librsyncError, e:204 except _librsync.librsyncError as e:
205 raise librsyncError(str(e))205 raise librsyncError(str(e))
206 self.buffer = self.buffer[len_buf_read:]206 self.buffer = self.buffer[len_buf_read:]
207 self.sigstring_list.append(cycle_out)207 self.sigstring_list.append(cycle_out)
208208
=== modified file 'duplicity/patchdir.py'
--- duplicity/patchdir.py 2013-12-27 06:39:00 +0000
+++ duplicity/patchdir.py 2014-04-17 22:26:47 +0000
@@ -504,7 +504,7 @@
504 if final_ropath.exists():504 if final_ropath.exists():
505 # otherwise final patch was delete505 # otherwise final patch was delete
506 yield final_ropath506 yield final_ropath
507 except Exception, e:507 except Exception as e:
508 filename = normalized[-1].get_ropath().get_relative_path()508 filename = normalized[-1].get_ropath().get_relative_path()
509 log.Warn(_("Error '%s' patching %s") % 509 log.Warn(_("Error '%s' patching %s") %
510 (str(e), filename),510 (str(e), filename),
511511
=== modified file 'duplicity/path.py'
--- duplicity/path.py 2013-12-27 06:39:00 +0000
+++ duplicity/path.py 2014-04-17 22:26:47 +0000
@@ -500,7 +500,7 @@
500 """Refresh stat cache"""500 """Refresh stat cache"""
501 try:501 try:
502 self.stat = os.lstat(self.name)502 self.stat = os.lstat(self.name)
503 except OSError, e:503 except OSError as e:
504 err_string = errno.errorcode[e[0]]504 err_string = errno.errorcode[e[0]]
505 if err_string in ["ENOENT", "ENOTDIR", "ELOOP", "ENOTCONN"]:505 if err_string in ["ENOENT", "ENOTDIR", "ELOOP", "ENOTCONN"]:
506 self.stat, self.type = None, None # file doesn't exist506 self.stat, self.type = None, None # file doesn't exist
507507
=== modified file 'duplicity/progress.py'
--- duplicity/progress.py 2013-04-15 12:10:35 +0000
+++ duplicity/progress.py 2014-04-17 22:26:47 +0000
@@ -264,7 +264,7 @@
264 projection = 1.0264 projection = 1.0
265 if self.progress_estimation > 0:265 if self.progress_estimation > 0:
266 projection = (1.0 - self.progress_estimation) / self.progress_estimation266 projection = (1.0 - self.progress_estimation) / self.progress_estimation
267 self.time_estimation = long(projection * float(self.elapsed_sum.total_seconds()))267 self.time_estimation = int(projection * float(self.elapsed_sum.total_seconds()))
268268
269 # Apply values only when monotonic, so the estimates look more consistent to the human eye269 # Apply values only when monotonic, so the estimates look more consistent to the human eye
270 if self.progress_estimation < last_progress_estimation:270 if self.progress_estimation < last_progress_estimation:
@@ -299,7 +299,7 @@
299 volume and for the current volume299 volume and for the current volume
300 """300 """
301 changing = max(bytecount - self.last_bytecount, 0)301 changing = max(bytecount - self.last_bytecount, 0)
302 self.total_bytecount += long(changing) # Annotate only changing bytes since last probe302 self.total_bytecount += int(changing) # Annotate only changing bytes since last probe
303 self.last_bytecount = bytecount303 self.last_bytecount = bytecount
304 if changing > 0:304 if changing > 0:
305 self.stall_last_time = datetime.now()305 self.stall_last_time = datetime.now()
306306
=== modified file 'duplicity/robust.py'
--- duplicity/robust.py 2013-12-27 06:39:00 +0000
+++ duplicity/robust.py 2014-04-17 22:26:47 +0000
@@ -39,7 +39,7 @@
39 # RPathException, Rdiff.RdiffException,39 # RPathException, Rdiff.RdiffException,
40 # librsync.librsyncError, C.UnknownFileTypeError), exc:40 # librsync.librsyncError, C.UnknownFileTypeError), exc:
41 # TracebackArchive.add()41 # TracebackArchive.add()
42 except (IOError, EnvironmentError, librsync.librsyncError, path.PathException), exc:42 except (IOError, EnvironmentError, librsync.librsyncError, path.PathException) as exc:
43 if (not isinstance(exc, EnvironmentError) or43 if (not isinstance(exc, EnvironmentError) or
44 ((exc[0] in errno.errorcode)44 ((exc[0] in errno.errorcode)
45 and errno.errorcode[exc[0]] in45 and errno.errorcode[exc[0]] in
4646
=== modified file 'duplicity/selection.py'
--- duplicity/selection.py 2013-12-27 06:39:00 +0000
+++ duplicity/selection.py 2014-04-17 22:26:47 +0000
@@ -256,7 +256,7 @@
256 self.add_selection_func(self.regexp_get_sf(arg, 1))256 self.add_selection_func(self.regexp_get_sf(arg, 1))
257 else:257 else:
258 assert 0, "Bad selection option %s" % opt258 assert 0, "Bad selection option %s" % opt
259 except SelectError, e:259 except SelectError as e:
260 self.parse_catch_error(e)260 self.parse_catch_error(e)
261 assert filelists_index == len(filelists)261 assert filelists_index == len(filelists)
262 self.parse_last_excludes()262 self.parse_last_excludes()
@@ -351,7 +351,7 @@
351 continue # skip blanks351 continue # skip blanks
352 try:352 try:
353 tuple = self.filelist_parse_line(line, include)353 tuple = self.filelist_parse_line(line, include)
354 except FilePrefixError, exc:354 except FilePrefixError as exc:
355 incr_warnings(exc)355 incr_warnings(exc)
356 continue356 continue
357 tuple_list.append(tuple)357 tuple_list.append(tuple)
358358
=== modified file 'duplicity/statistics.py'
--- duplicity/statistics.py 2010-07-22 19:15:11 +0000
+++ duplicity/statistics.py 2014-04-17 22:26:47 +0000
@@ -104,7 +104,7 @@
104 if not index:104 if not index:
105 filename = "."105 filename = "."
106 else:106 else:
107 filename = apply(os.path.join, index)107 filename = os.path.join(*index)
108 if use_repr:108 if use_repr:
109 # use repr to quote newlines in relative filename, then109 # use repr to quote newlines in relative filename, then
110 # take of leading and trailing quote and quote spaces.110 # take of leading and trailing quote and quote spaces.
@@ -123,7 +123,7 @@
123 for attr, val_string in zip(self.stat_file_attrs,123 for attr, val_string in zip(self.stat_file_attrs,
124 lineparts[-len(self.stat_file_attrs):]):124 lineparts[-len(self.stat_file_attrs):]):
125 try:125 try:
126 val = long(val_string)126 val = int(val_string)
127 except ValueError:127 except ValueError:
128 try:128 try:
129 val = float(val_string)129 val = float(val_string)
@@ -230,7 +230,7 @@
230 error(line)230 error(line)
231 try:231 try:
232 try:232 try:
233 val1 = long(value_string)233 val1 = int(value_string)
234 except ValueError:234 except ValueError:
235 val1 = None235 val1 = None
236 val2 = float(value_string)236 val2 = float(value_string)
237237
=== modified file 'duplicity/tempdir.py'
--- duplicity/tempdir.py 2013-12-27 06:39:00 +0000
+++ duplicity/tempdir.py 2014-04-17 22:26:47 +0000
@@ -213,7 +213,7 @@
213 """213 """
214 self.__lock.acquire()214 self.__lock.acquire()
215 try:215 try:
216 if self.__pending.has_key(fname):216 if fname in self.__pending:
217 log.Debug(_("Forgetting temporary file %s") % util.ufn(fname))217 log.Debug(_("Forgetting temporary file %s") % util.ufn(fname))
218 del(self.__pending[fname])218 del(self.__pending[fname])
219 else:219 else:
220220
=== modified file 'duplicity/util.py'
--- duplicity/util.py 2014-01-17 16:44:46 +0000
+++ duplicity/util.py 2014-04-17 22:26:47 +0000
@@ -80,7 +80,7 @@
80 """80 """
81 try:81 try:
82 return fn()82 return fn()
83 except Exception, e:83 except Exception as e:
84 if globals.ignore_errors:84 if globals.ignore_errors:
85 log.Warn(_("IGNORED_ERROR: Warning: ignoring error as requested: %s: %s")85 log.Warn(_("IGNORED_ERROR: Warning: ignoring error as requested: %s: %s")
86 % (e.__class__.__name__, str(e)))86 % (e.__class__.__name__, str(e)))
@@ -131,7 +131,7 @@
131 """131 """
132 try:132 try:
133 fn(filename)133 fn(filename)
134 except OSError, ex:134 except OSError as ex:
135 if ex.errno == errno.ENOENT:135 if ex.errno == errno.ENOENT:
136 pass136 pass
137 else:137 else:
138138
=== modified file 'testing/gnupg/trustdb.gpg'
139Binary files testing/gnupg/trustdb.gpg 2011-11-04 12:48:04 +0000 and testing/gnupg/trustdb.gpg 2014-04-17 22:26:47 +0000 differ139Binary files testing/gnupg/trustdb.gpg 2011-11-04 12:48:04 +0000 and testing/gnupg/trustdb.gpg 2014-04-17 22:26:47 +0000 differ
=== modified file 'testing/tests/test_badupload.py'
--- testing/tests/test_badupload.py 2014-04-16 02:43:43 +0000
+++ testing/tests/test_badupload.py 2014-04-17 22:26:47 +0000
@@ -36,7 +36,7 @@
36 try:36 try:
37 self.backup("full", "testfiles/dir1", options=["--skip-volume=1"])37 self.backup("full", "testfiles/dir1", options=["--skip-volume=1"])
38 self.fail()38 self.fail()
39 except CmdError, e:39 except CmdError as e:
40 self.assertEqual(e.exit_status, 44)40 self.assertEqual(e.exit_status, 44)
4141
42if __name__ == "__main__":42if __name__ == "__main__":
4343
=== modified file 'testing/tests/test_collections.py'
--- testing/tests/test_collections.py 2014-04-16 02:43:43 +0000
+++ testing/tests/test_collections.py 2014-04-17 22:26:47 +0000
@@ -111,8 +111,8 @@
111 assert 0111 assert 0
112112
113 chain = chains[0]113 chain = chains[0]
114 assert chain.end_time == 1029654270L114 assert chain.end_time == 1029654270
115 assert chain.fullset.time == 1029626221L115 assert chain.fullset.time == 1029626221
116116
117 def test_collections_status(self):117 def test_collections_status(self):
118 """Test CollectionStatus object's set_values()"""118 """Test CollectionStatus object's set_values()"""
@@ -121,7 +121,7 @@
121 assert cs.values_set121 assert cs.values_set
122122
123 assert cs.matched_chain_pair123 assert cs.matched_chain_pair
124 assert cs.matched_chain_pair[0].end_time == 1029826800L124 assert cs.matched_chain_pair[0].end_time == 1029826800
125 assert len(cs.all_backup_chains) == 1, cs.all_backup_chains125 assert len(cs.all_backup_chains) == 1, cs.all_backup_chains
126126
127 cs = collections.CollectionsStatus(self.real_backend, globals.archive_dir).set_values()127 cs = collections.CollectionsStatus(self.real_backend, globals.archive_dir).set_values()
@@ -153,7 +153,7 @@
153 for op in orphaned_paths: print op153 for op in orphaned_paths: print op
154 assert 0154 assert 0
155 assert len(chains) == 1, chains155 assert len(chains) == 1, chains
156 assert chains[0].end_time == 1029826800L156 assert chains[0].end_time == 1029826800
157157
158 def sigchain_fileobj_get(self, local):158 def sigchain_fileobj_get(self, local):
159 """Return chain, local if local is true with filenames added"""159 """Return chain, local if local is true with filenames added"""
160160
=== modified file 'testing/tests/test_filenaming.py'
--- testing/tests/test_filenaming.py 2014-04-16 02:43:43 +0000
+++ testing/tests/test_filenaming.py 2014-04-17 22:26:47 +0000
@@ -88,13 +88,13 @@
88 pr = file_naming.parse(globals.file_prefix + globals.file_prefix_signature + "dns.h112bi.h14rg0.st.g")88 pr = file_naming.parse(globals.file_prefix + globals.file_prefix_signature + "dns.h112bi.h14rg0.st.g")
89 assert pr, pr89 assert pr, pr
90 assert pr.type == "new-sig"90 assert pr.type == "new-sig"
91 assert pr.end_time == 1029826800L91 assert pr.end_time == 1029826800
9292
93 if not globals.short_filenames:93 if not globals.short_filenames:
94 pr = file_naming.parse(globals.file_prefix + globals.file_prefix_signature + "duplicity-new-signatures.2002-08-18T00:04:30-07:00.to.2002-08-20T00:00:00-07:00.sigtar.gpg")94 pr = file_naming.parse(globals.file_prefix + globals.file_prefix_signature + "duplicity-new-signatures.2002-08-18T00:04:30-07:00.to.2002-08-20T00:00:00-07:00.sigtar.gpg")
95 assert pr, pr95 assert pr, pr
96 assert pr.type == "new-sig"96 assert pr.type == "new-sig"
97 assert pr.end_time == 1029826800L97 assert pr.end_time == 1029826800
9898
99 pr = file_naming.parse(globals.file_prefix + globals.file_prefix_signature + "dfs.h5dixs.st.g")99 pr = file_naming.parse(globals.file_prefix + globals.file_prefix_signature + "dfs.h5dixs.st.g")
100 assert pr, pr100 assert pr, pr
@@ -108,14 +108,14 @@
108 assert pr, pr108 assert pr, pr
109 assert pr.partial109 assert pr.partial
110 assert pr.type == "new-sig"110 assert pr.type == "new-sig"
111 assert pr.end_time == 1029826800L111 assert pr.end_time == 1029826800
112112
113 if not globals.short_filenames:113 if not globals.short_filenames:
114 pr = file_naming.parse(globals.file_prefix + globals.file_prefix_signature + "duplicity-new-signatures.2002-08-18T00:04:30-07:00.to.2002-08-20T00:00:00-07:00.sigtar.part.gpg")114 pr = file_naming.parse(globals.file_prefix + globals.file_prefix_signature + "duplicity-new-signatures.2002-08-18T00:04:30-07:00.to.2002-08-20T00:00:00-07:00.sigtar.part.gpg")
115 assert pr, pr115 assert pr, pr
116 assert pr.partial116 assert pr.partial
117 assert pr.type == "new-sig"117 assert pr.type == "new-sig"
118 assert pr.end_time == 1029826800L118 assert pr.end_time == 1029826800
119119
120 pr = file_naming.parse(globals.file_prefix + globals.file_prefix_signature + "dfs.h5dixs.st.p.g")120 pr = file_naming.parse(globals.file_prefix + globals.file_prefix_signature + "dfs.h5dixs.st.p.g")
121 assert pr, pr121 assert pr, pr
122122
=== modified file 'testing/tests/test_lazy.py'
--- testing/tests/test_lazy.py 2014-04-16 02:43:43 +0000
+++ testing/tests/test_lazy.py 2014-04-17 22:26:47 +0000
@@ -21,6 +21,7 @@
2121
22import helper22import helper
23import unittest, pickle, sys23import unittest, pickle, sys
24from functools import reduce
2425
25from duplicity.lazy import * #@UnusedWildImport26from duplicity.lazy import * #@UnusedWildImport
2627
@@ -33,7 +34,7 @@
33 empty = lambda s: iter([])34 empty = lambda s: iter([])
3435
35 def __init__(self, *args):36 def __init__(self, *args):
36 apply (unittest.TestCase.__init__, (self,) + args)37 unittest.TestCase.__init__(self, *args)
37 self.falseerror = self.falseerror_maker()38 self.falseerror = self.falseerror_maker()
38 self.trueerror = self.trueerror_maker()39 self.trueerror = self.trueerror_maker()
39 self.emptygen = self.emptygen_maker()40 self.emptygen = self.emptygen_maker()
4041
=== modified file 'testing/tests/test_patchdir.py'
--- testing/tests/test_patchdir.py 2014-04-16 02:43:43 +0000
+++ testing/tests/test_patchdir.py 2014-04-17 22:26:47 +0000
@@ -209,12 +209,12 @@
209 self.out = out209 self.out = out
210210
211 def snapshot(self):211 def snapshot(self):
212 """Make a snapshot ROPath, permissions 0600"""212 """Make a snapshot ROPath, permissions 0o600"""
213 ss = self.out.append("snapshot")213 ss = self.out.append("snapshot")
214 fout = ss.open("wb")214 fout = ss.open("wb")
215 fout.write("hello, world!")215 fout.write("hello, world!")
216 assert not fout.close()216 assert not fout.close()
217 ss.chmod(0600)217 ss.chmod(0o600)
218 ss.difftype = "snapshot"218 ss.difftype = "snapshot"
219 return ss219 return ss
220220
@@ -230,24 +230,24 @@
230 return deltabuf230 return deltabuf
231231
232 def delta1(self):232 def delta1(self):
233 """Make a delta ROPath, permissions 0640"""233 """Make a delta ROPath, permissions 0o640"""
234 delta1 = self.out.append("delta1")234 delta1 = self.out.append("delta1")
235 fout = delta1.open("wb")235 fout = delta1.open("wb")
236 fout.write(self.get_delta("hello, world!",236 fout.write(self.get_delta("hello, world!",
237 "aonseuth aosetnuhaonsuhtansoetuhaoe"))237 "aonseuth aosetnuhaonsuhtansoetuhaoe"))
238 assert not fout.close()238 assert not fout.close()
239 delta1.chmod(0640)239 delta1.chmod(0o640)
240 delta1.difftype = "diff"240 delta1.difftype = "diff"
241 return delta1241 return delta1
242242
243 def delta2(self):243 def delta2(self):
244 """Make another delta ROPath, permissions 0644"""244 """Make another delta ROPath, permissions 0o644"""
245 delta2 = self.out.append("delta1")245 delta2 = self.out.append("delta1")
246 fout = delta2.open("wb")246 fout = delta2.open("wb")
247 fout.write(self.get_delta("aonseuth aosetnuhaonsuhtansoetuhaoe",247 fout.write(self.get_delta("aonseuth aosetnuhaonsuhtansoetuhaoe",
248 "3499 34957839485792357 458348573"))248 "3499 34957839485792357 458348573"))
249 assert not fout.close()249 assert not fout.close()
250 delta2.chmod(0644)250 delta2.chmod(0o644)
251 delta2.difftype = "diff"251 delta2.difftype = "diff"
252 return delta2252 return delta2
253253
254254
=== added file 'testing/tests/test_python3.py'
--- testing/tests/test_python3.py 1970-01-01 00:00:00 +0000
+++ testing/tests/test_python3.py 2014-04-17 22:26:47 +0000
@@ -0,0 +1,61 @@
1# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
2#
3# Copyright 2014 Michael Terry <michael.terry@canonical.com>
4#
5# This file is part of duplicity.
6#
7# Duplicity is free software; you can redistribute it and/or modify it
8# under the terms of the GNU General Public License as published by the
9# Free Software Foundation; either version 2 of the License, or (at your
10# option) any later version.
11#
12# Duplicity is distributed in the hope that it will be useful, but
13# WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15# General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with duplicity; if not, write to the Free Software Foundation,
19# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21import helper
22import os
23import subprocess
24import unittest
25
26helper.setup()
27
28
29class Python3ReadinessTest(unittest.TestCase):
30 def test_2to3(self):
31 _top_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)),
32 "..", "..")
33
34 # As we modernize the source code, we can remove more and more nofixes
35 process = subprocess.Popen(["2to3",
36 "--nofix=dict",
37 "--nofix=filter",
38 "--nofix=map",
39 "--nofix=next",
40 "--nofix=print",
41 "--nofix=types",
42 "--nofix=unicode",
43 "--nofix=xrange",
44 # The following fixes we don't want to remove, since they are false
45 # positives, things we don't care about, or real incompatibilities
46 # but which 2to3 can fix for us better automatically.
47 "--nofix=callable",
48 "--nofix=future",
49 "--nofix=imports",
50 "--nofix=raw_input",
51 "--nofix=urllib",
52 _top_dir],
53 stdout=subprocess.PIPE,
54 stderr=subprocess.PIPE)
55 output = process.communicate()[0]
56 self.assertEqual(0, process.returncode)
57 self.assertEqual("", output, output)
58
59
60if __name__ == "__main__":
61 unittest.main()
062
=== modified file 'testing/tests/test_restart.py'
--- testing/tests/test_restart.py 2014-04-16 02:43:43 +0000
+++ testing/tests/test_restart.py 2014-04-17 22:26:47 +0000
@@ -326,7 +326,7 @@
326 self.backup("full", "testfiles/blocktartest")326 self.backup("full", "testfiles/blocktartest")
327 # Create an exact clone of the snapshot folder in the sigtar already.327 # Create an exact clone of the snapshot folder in the sigtar already.
328 # Permissions and mtime must match.328 # Permissions and mtime must match.
329 os.mkdir("testfiles/snapshot", 0755)329 os.mkdir("testfiles/snapshot", 0o755)
330 os.utime("testfiles/snapshot", (1030384548, 1030384548))330 os.utime("testfiles/snapshot", (1030384548, 1030384548))
331 # Adjust the sigtar.gz file to have a bogus second snapshot/ entry331 # Adjust the sigtar.gz file to have a bogus second snapshot/ entry
332 # at the beginning.332 # at the beginning.

Subscribers

People subscribed via source and target branches

to all changes: