Rev 2056: Tidier SFTP code (feedback from Aaron). in http://people.ubuntu.com/~robertc/baz2.0/transport

Robert Collins robertc at robertcollins.net
Thu Jul 5 00:42:44 BST 2007


At http://people.ubuntu.com/~robertc/baz2.0/transport

------------------------------------------------------------
revno: 2056
revision-id: robertc at robertcollins.net-20070704234240-v5z830d3eev730si
parent: robertc at robertcollins.net-20070704080912-h81ahk975cf52kg0
committer: Robert Collins <robertc at robertcollins.net>
branch nick: transport-get-file
timestamp: Thu 2007-07-05 09:42:40 +1000
message:
  Tidier SFTP code (feedback from Aaron).
modified:
  bzrlib/transport/sftp.py       sftp.py-20051019050329-ab48ce71b7e32dfe
=== modified file 'bzrlib/transport/sftp.py'
--- a/bzrlib/transport/sftp.py	2007-07-04 08:08:13 +0000
+++ b/bzrlib/transport/sftp.py	2007-07-04 23:42:40 +0000
@@ -50,7 +50,6 @@
 from bzrlib.osutils import pathjoin, fancy_rename, getcwd
 from bzrlib.trace import mutter, warning
 from bzrlib.transport import (
-    LateReadError,
     local,
     register_urlparse_netloc_protocol,
     Server,
@@ -395,9 +394,7 @@
             return f
         except (IOError, paramiko.SSHException), e:
             self._translate_io_exception(e, path, ': error retrieving',
-                raise_on_failure=False)
-            # a paramiko generic failure occured.
-            return LateReadError(relpath)
+                failure_exc=errors.ReadError)
 
     def readv(self, relpath, offsets):
         """See Transport.readv()"""
@@ -686,9 +683,8 @@
         """Create a directory at the given path."""
         self._mkdir(self._remote_path(relpath), mode=mode)
 
-    def _translate_io_exception(self, e, path, more_info='', 
-                                failure_exc=PathError,
-                                raise_on_failure=True):
+    def _translate_io_exception(self, e, path, more_info='',
+                                failure_exc=PathError):
         """Translate a paramiko or IOError into a friendlier exception.
 
         :param e: The original exception
@@ -700,8 +696,6 @@
                            no more information.
                            If this parameter is set, it defines the exception 
                            to raise in these cases.
-        :param raise_on_failure: When False do not raise on a generic paramiko
-            'Failure', rather return to the caller to dispatch differently.
         """
         # paramiko seems to generate detailless errors.
         self._translate_error(e, path, raise_generic=False)
@@ -713,10 +707,7 @@
                 raise FileExists(path, str(e) + more_info)
             # strange but true, for the paramiko server.
             if (e.args == ('Failure',)):
-                if raise_on_failure:
-                    raise failure_exc(path, str(e) + more_info)
-                else:
-                    return
+                raise failure_exc(path, str(e) + more_info)
             mutter('Raising exception with args %s', e.args)
         if getattr(e, 'errno', None) is not None:
             mutter('Raising exception with errno %s', e.errno)



More information about the bazaar-commits mailing list