duplicity-team team mailing list archive
-
duplicity-team team
-
Mailing list archive
-
Message #00600
[Merge] lp:~mterry/duplicity/797758 into lp:duplicity
Michael Terry has proposed merging lp:~mterry/duplicity/797758 into lp:duplicity.
Requested reviews:
duplicity-team (duplicity-team)
Related bugs:
Bug #797758 in Duplicity: "Duplicity ignores some FatalErrors"
https://bugs.launchpad.net/duplicity/+bug/797758
For more details, see:
https://code.launchpad.net/~mterry/duplicity/797758/+merge/64942
>From bug 797758:
1) Duplicity calls self.last_backup.delete() during a restart
2) Which executes the following:
try:
self.backend.delete(rfn)
except:
log.Debug("BackupSet.delete: missing %s" % rfn)
pass
3) If the backend.delete function encounters a FatalError, sys.exit will be called, which should close duplicity.
4) But the way that except clause is written, it won't. Blanket "except:" clauses will catch even SystemExit exceptions. See http://stackoverflow.com/questions/730764/try-catch-in-python
The fix is to use "except Exception:" instead. This branch does that for all except: lines. I assume that is correct, that we never intentionally want to block SystemExit or KeyboardInterrupt?
--
https://code.launchpad.net/~mterry/duplicity/797758/+merge/64942
Your team duplicity-team is requested to review the proposed merge of lp:~mterry/duplicity/797758 into lp:duplicity.
=== modified file 'duplicity-bin'
--- duplicity-bin 2011-06-13 21:59:26 +0000
+++ duplicity-bin 2011-06-17 06:26:31 +0000
@@ -895,7 +895,7 @@
def next(self, size):
try:
res = Block(self.fileobj.read(size))
- except:
+ except Exception:
if hasattr(self.fileobj, 'name'):
name = self.fileobj.name
else:
@@ -1011,7 +1011,7 @@
tempfs = os.path.sep.join(tempname.split(os.path.sep)[:-2])
try:
stats = os.statvfs(tempfs)
- except:
+ except Exception:
log.FatalError(_("Unable to get free space on temp."),
log.ErrorCode.get_freespace_failed)
# Calculate space we need for at least 2 volumes of full or inc
=== modified file 'duplicity/backend.py'
--- duplicity/backend.py 2011-06-13 15:41:28 +0000
+++ duplicity/backend.py 2011-06-17 06:26:31 +0000
@@ -76,7 +76,7 @@
try:
__import__(imp)
res = "Succeeded"
- except:
+ except Exception:
res = "Failed: " + str(sys.exc_info()[1])
log.Info("Import of %s %s" % (imp, res))
else:
@@ -216,27 +216,27 @@
try:
pu = urlparser.urlparse(url_string)
- except:
+ except Exception:
raise InvalidBackendURL("Syntax error in: %s" % url_string)
try:
self.scheme = pu.scheme
- except:
+ except Exception:
raise InvalidBackendURL("Syntax error (scheme) in: %s" % url_string)
try:
self.netloc = pu.netloc
- except:
+ except Exception:
raise InvalidBackendURL("Syntax error (netloc) in: %s" % url_string)
try:
self.path = pu.path
- except:
+ except Exception:
raise InvalidBackendURL("Syntax error (path) in: %s" % url_string)
try:
self.username = pu.username
- except:
+ except Exception:
raise InvalidBackendURL("Syntax error (username) in: %s" % url_string)
if self.username:
self.username = urllib.unquote(pu.username)
@@ -245,7 +245,7 @@
try:
self.password = pu.password
- except:
+ except Exception:
raise InvalidBackendURL("Syntax error (password) in: %s" % url_string)
if self.password:
self.password = urllib.unquote(self.password)
@@ -254,14 +254,14 @@
try:
self.hostname = pu.hostname
- except:
+ except Exception:
raise InvalidBackendURL("Syntax error (hostname) in: %s" % url_string)
# init to None, overwrite with actual value on success
self.port = None
try:
self.port = pu.port
- except:
+ except Exception:
# old style rsync://host::[/]dest, are still valid, though they contain no port
if not ( self.scheme in ['rsync'] and re.search('::[^:]*$', self.url_string)):
raise InvalidBackendURL("Syntax error (port) in: %s A%s B%s C%s" % (url_string, (self.scheme in ['rsync']), re.search('::[^:]+$', self.netloc), self.netloc ) )
=== modified file 'duplicity/backends/ftpbackend.py'
--- duplicity/backends/ftpbackend.py 2011-06-12 11:36:26 +0000
+++ duplicity/backends/ftpbackend.py 2011-06-17 06:26:31 +0000
@@ -38,7 +38,7 @@
p = os.popen("ncftpls -v")
fout = p.read()
ret = p.close()
- except:
+ except Exception:
pass
# the expected error is 8 in the high-byte and some output
if ret != 0x0800 or not fout:
=== modified file 'duplicity/backends/ftpsbackend.py'
--- duplicity/backends/ftpsbackend.py 2011-03-06 15:12:33 +0000
+++ duplicity/backends/ftpsbackend.py 2011-06-17 06:26:31 +0000
@@ -41,7 +41,7 @@
p = os.popen("lftp --version")
fout = p.read()
ret = p.close()
- except:
+ except Exception:
pass
# there is no output if lftp not found
if not fout:
=== modified file 'duplicity/backends/hsibackend.py'
--- duplicity/backends/hsibackend.py 2010-07-22 19:15:11 +0000
+++ duplicity/backends/hsibackend.py 2011-06-17 06:26:31 +0000
@@ -41,7 +41,7 @@
commandline = '%s "put %s : %s%s"' % (hsi_command,source_path.name,self.remote_prefix,remote_filename)
try:
self.run_command(commandline)
- except:
+ except Exception:
print commandline
def get(self, remote_filename, local_path):
=== modified file 'duplicity/backends/imapbackend.py'
--- duplicity/backends/imapbackend.py 2010-07-22 19:15:11 +0000
+++ duplicity/backends/imapbackend.py 2011-06-17 06:26:31 +0000
@@ -75,7 +75,7 @@
# Try to close the connection cleanly
try:
self._conn.close()
- except:
+ except Exception:
pass
if (parsed_url.scheme == "imap"):
=== modified file 'duplicity/backends/localbackend.py'
--- duplicity/backends/localbackend.py 2011-06-12 11:12:30 +0000
+++ duplicity/backends/localbackend.py 2011-06-17 06:26:31 +0000
@@ -87,7 +87,7 @@
"""List files in that directory"""
try:
os.makedirs(self.remote_pathdir.base)
- except:
+ except Exception:
pass
try:
return self.remote_pathdir.listdir()
=== modified file 'duplicity/collections.py'
--- duplicity/collections.py 2010-11-20 15:39:00 +0000
+++ duplicity/collections.py 2011-06-17 06:26:31 +0000
@@ -137,7 +137,7 @@
rfn.reverse()
try:
self.backend.delete(rfn)
- except:
+ except Exception:
log.Debug("BackupSet.delete: missing %s" % rfn)
pass
for lfn in globals.archive_dir.listdir():
@@ -153,7 +153,7 @@
# which is bad if running non-interactive with encrypt-key
try:
globals.archive_dir.append(lfn).delete()
- except:
+ except Exception:
log.Debug("BackupSet.delete: missing %s" % lfn)
pass
=== modified file 'duplicity/commandline.py'
--- duplicity/commandline.py 2011-06-12 11:05:30 +0000
+++ duplicity/commandline.py 2011-06-17 06:26:31 +0000
@@ -518,7 +518,7 @@
elif cmd == "remove-older-than":
try:
arg = args.pop(0)
- except:
+ except Exception:
command_line_error("Missing time string for remove-older-than")
globals.remove_time = dup_time.genstrtotime(arg)
num_expect = 1
@@ -529,7 +529,7 @@
globals.remove_all_inc_of_but_n_full_mode = True
try:
arg = args.pop(0)
- except:
+ except Exception:
command_line_error("Missing count for " + cmd)
globals.keep_chains = int(arg)
if not globals.keep_chains > 0:
@@ -767,7 +767,7 @@
if not os.path.exists(dirstring):
try:
os.makedirs(dirstring)
- except:
+ except Exception:
pass
archive_dir = path.Path(dirstring)
if not archive_dir.isdir():
=== modified file 'duplicity/dup_temp.py'
--- duplicity/dup_temp.py 2011-04-16 20:25:01 +0000
+++ duplicity/dup_temp.py 2011-06-17 06:26:31 +0000
@@ -244,7 +244,7 @@
def next(self, size):
try:
res = Block(self.fp.read(size))
- except:
+ except Exception:
log.FatalError(_("Failed to read %s: %s") %
(self.src.name, sys.exc_info()),
log.ErrorCode.generic)
=== modified file 'duplicity/gpg.py'
--- duplicity/gpg.py 2011-04-16 20:25:01 +0000
+++ duplicity/gpg.py 2011-06-17 06:26:31 +0000
@@ -150,7 +150,7 @@
def write(self, buf):
try:
res = self.gpg_input.write(buf)
- except:
+ except Exception:
self.gpg_failed()
return res
@@ -171,13 +171,13 @@
if self.encrypt:
try:
self.gpg_input.close()
- except:
+ except Exception:
self.gpg_failed()
if self.status_fp:
self.set_signature()
try:
self.gpg_process.wait()
- except:
+ except Exception:
self.gpg_failed()
else:
res = 1
@@ -185,17 +185,17 @@
# discard remaining output to avoid GPG error
try:
res = self.gpg_output.read(blocksize)
- except:
+ except Exception:
self.gpg_failed()
try:
self.gpg_output.close()
- except:
+ except Exception:
self.gpg_failed()
if self.status_fp:
self.set_signature()
try:
self.gpg_process.wait()
- except:
+ except Exception:
self.gpg_failed()
self.logger_fp.close()
self.stderr_fp.close()
=== modified file 'duplicity/manifest.py'
--- duplicity/manifest.py 2011-03-06 16:19:53 +0000
+++ duplicity/manifest.py 2011-06-17 06:26:31 +0000
@@ -132,7 +132,7 @@
"""
try:
del self.volume_info_dict[vol_num]
- except:
+ except Exception:
raise ManifestError("Volume %d not present in manifest" % (vol_num,))
def to_string(self):
=== modified file 'duplicity/pexpect.py'
--- duplicity/pexpect.py 2010-07-22 19:15:11 +0000
+++ duplicity/pexpect.py 2011-06-17 06:26:31 +0000
@@ -534,7 +534,7 @@
try:
self.child_fd = sys.stdout.fileno() # used by setwinsize()
self.setwinsize(24, 80)
- except:
+ except Exception:
# Some platforms do not like setwinsize (Cygwin).
# This will cause problem when running applications that
# are very picky about window size.
@@ -624,7 +624,7 @@
if fd >= 0:
os.close(fd)
raise ExceptionPexpect, "Error! We are not disconnected from a controlling tty."
- except:
+ except Exception:
# Good! We are disconnected from a controlling tty.
pass
@@ -1407,7 +1407,7 @@
self.match = None
self.match_index = None
raise TIMEOUT (str(e) + '\n' + str(self))
- except:
+ except Exception:
self.before = incoming
self.after = None
self.match = None
=== modified file 'duplicity/selection.py'
--- duplicity/selection.py 2011-06-12 10:16:35 +0000
+++ duplicity/selection.py 2011-06-17 06:26:31 +0000
@@ -457,7 +457,7 @@
assert include == 0 or include == 1
try:
regexp = re.compile(regexp_string)
- except:
+ except Exception:
log.Warn(_("Error compiling regular expression %s") % regexp_string)
raise
=== modified file 'duplicity/tempdir.py'
--- duplicity/tempdir.py 2009-06-06 17:35:19 +0000
+++ duplicity/tempdir.py 2011-06-17 06:26:31 +0000
@@ -231,12 +231,12 @@
try:
log.Debug(_("Removing still remembered temporary file %s") % (file,))
os.unlink(file)
- except:
+ except Exception:
log.Info(_("Cleanup of temporary file %s failed") % (file,))
pass
try:
os.rmdir(self.__dir)
- except:
+ except Exception:
log.Warn(_("Cleanup of temporary directory %s failed - this is probably a bug.") % (self.__dir,))
pass
self.__pending = None
=== modified file 'testing/backendtest.py'
--- testing/backendtest.py 2011-03-08 19:45:47 +0000
+++ testing/backendtest.py 2011-06-17 06:26:31 +0000
@@ -27,7 +27,7 @@
try:
import duplicity.backends.giobackend
gio_available = True
-except:
+except Exception:
gio_available = False
from duplicity.errors import * #@UnusedWildImport
from duplicity import path, file_naming, dup_time, globals, gpg
=== modified file 'testing/config.py.tmpl'
--- testing/config.py.tmpl 2010-11-20 15:39:00 +0000
+++ testing/config.py.tmpl 2011-06-17 06:26:31 +0000
@@ -112,5 +112,5 @@
else:
try:
del os.environ[varname]
- except:
+ except Exception:
pass
Follow ups