summaryrefslogtreecommitdiff
path: root/rdiff-backup/rdiff_backup/connection.py
diff options
context:
space:
mode:
authorbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2005-11-19 03:10:03 +0000
committerbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2005-11-19 03:10:03 +0000
commit3f6a251faf324209247a868c91a9bacdea427db1 (patch)
treee8789dd5b97a4d62c342016c045210df03865ed8 /rdiff-backup/rdiff_backup/connection.py
parent3f7215648bac76bbdba0ac6dcbf608db2919877c (diff)
downloadrdiff-backup-3f6a251faf324209247a868c91a9bacdea427db1.tar.gz
Error reporting cleanup
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@684 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/connection.py')
-rw-r--r--rdiff-backup/rdiff_backup/connection.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/rdiff-backup/rdiff_backup/connection.py b/rdiff-backup/rdiff_backup/connection.py
index 99b8f72..dadbcd5 100644
--- a/rdiff-backup/rdiff_backup/connection.py
+++ b/rdiff-backup/rdiff_backup/connection.py
@@ -31,6 +31,7 @@ except ImportError: pass
class ConnectionError(Exception): pass
class ConnectionReadError(ConnectionError): pass
+class ConnectionWriteError(ConnectionError): pass
class ConnectionQuit(Exception): pass
@@ -197,14 +198,17 @@ class LowLevelPipeConnection(Connection):
def _write(self, headerchar, data, req_num):
"""Write header and then data to the pipe"""
- self.outpipe.write(headerchar + chr(req_num) +
- C.long2str(long(len(data))))
- self.outpipe.write(data)
- self.outpipe.flush()
+ try:
+ self.outpipe.write(headerchar + chr(req_num) +
+ C.long2str(long(len(data))))
+ self.outpipe.write(data)
+ self.outpipe.flush()
+ except IOError: raise ConnectionWriteError()
def _read(self, length):
"""Read length bytes from inpipe, returning result"""
- return self.inpipe.read(length)
+ try: return self.inpipe.read(length)
+ except IOError: raise ConnectionReadError()
def _s2l_old(self, s):
"""Convert string to long int"""
@@ -228,11 +232,9 @@ class LowLevelPipeConnection(Connection):
if not len(header_string) == 9:
raise ConnectionReadError("Truncated header string (problem "
"probably originated remotely)")
- try:
- format_string, req_num, length = (header_string[0],
- ord(header_string[1]),
- C.str2long(header_string[2:]))
- except IndexError: raise ConnectionError()
+ format_string, req_num, length = (header_string[0],
+ ord(header_string[1]),
+ C.str2long(header_string[2:]))
if format_string == "q": raise ConnectionQuit("Received quit signal")
data = self._read(length)
@@ -337,6 +339,8 @@ class PipeConnection(LowLevelPipeConnection):
def extract_exception(self):
"""Return active exception"""
+ if robust.is_routine_fatal(sys.exc_info()[1]):
+ raise # Fatal error--No logging necessary, but connection down
if log.Log.verbosity >= 5 or log.Log.term_verbosity >= 5:
log.Log("Sending back exception %s of type %s: \n%s" %
(sys.exc_info()[1], sys.exc_info()[0],