Rev 5000: Fix imports in bzrlib/tests/stub_sftp.py. in file:///home/vila/src/bzr/bugs/516183-test-server/

Vincent Ladeuil v.ladeuil+lp at free.fr
Wed Feb 3 08:56:04 GMT 2010


At file:///home/vila/src/bzr/bugs/516183-test-server/

------------------------------------------------------------
revno: 5000
revision-id: v.ladeuil+lp at free.fr-20100203085603-twucfxnev4luy1na
parent: pqm at pqm.ubuntu.com-20100202152315-dzbzbhpwun9xpnj6
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 516183-test-server
timestamp: Wed 2010-02-03 09:56:03 +0100
message:
  Fix imports in bzrlib/tests/stub_sftp.py.
-------------- next part --------------
=== modified file 'bzrlib/tests/stub_sftp.py'
--- a/bzrlib/tests/stub_sftp.py	2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/stub_sftp.py	2010-02-03 08:56:03 +0000
@@ -20,51 +20,54 @@
 """
 
 import os
-from paramiko import ServerInterface, SFTPServerInterface, SFTPServer, SFTPAttributes, \
-    SFTPHandle, SFTP_OK, AUTH_SUCCESSFUL, OPEN_SUCCEEDED
+import paramiko
 import sys
 
-from bzrlib.osutils import pathjoin
-from bzrlib.trace import mutter
-
-
-class StubServer (ServerInterface):
+from bzrlib import (
+    osutils,
+    trace,
+    )
+
+
+class StubServer (paramiko.ServerInterface):
 
     def __init__(self, test_case):
-        ServerInterface.__init__(self)
+        paramiko.ServerInterface.__init__(self)
         self._test_case = test_case
 
     def check_auth_password(self, username, password):
         # all are allowed
         self._test_case.log('sftpserver - authorizing: %s' % (username,))
-        return AUTH_SUCCESSFUL
+        return paramiko.AUTH_SUCCESSFUL
 
     def check_channel_request(self, kind, chanid):
-        self._test_case.log('sftpserver - channel request: %s, %s' % (kind, chanid))
-        return OPEN_SUCCEEDED
-
-
-class StubSFTPHandle (SFTPHandle):
+        self._test_case.log(
+            'sftpserver - channel request: %s, %s' % (kind, chanid))
+        return paramiko.OPEN_SUCCEEDED
+
+
+class StubSFTPHandle (paramiko.SFTPHandle):
     def stat(self):
         try:
-            return SFTPAttributes.from_stat(os.fstat(self.readfile.fileno()))
+            return paramiko.SFTPAttributes.from_stat(
+                os.fstat(self.readfile.fileno()))
         except OSError, e:
-            return SFTPServer.convert_errno(e.errno)
+            return paramiko.SFTPServer.convert_errno(e.errno)
 
     def chattr(self, attr):
         # python doesn't have equivalents to fchown or fchmod, so we have to
         # use the stored filename
-        mutter('Changing permissions on %s to %s', self.filename, attr)
+        trace.mutter('Changing permissions on %s to %s', self.filename, attr)
         try:
-            SFTPServer.set_file_attr(self.filename, attr)
+            paramiko.SFTPServer.set_file_attr(self.filename, attr)
         except OSError, e:
-            return SFTPServer.convert_errno(e.errno)
-
-
-class StubSFTPServer (SFTPServerInterface):
+            return paramiko.SFTPServer.convert_errno(e.errno)
+
+
+class StubSFTPServer (paramiko.SFTPServerInterface):
 
     def __init__(self, server, root, home=None):
-        SFTPServerInterface.__init__(self, server)
+        paramiko.SFTPServerInterface.__init__(self, server)
         # All paths are actually relative to 'root'.
         # this is like implementing chroot().
         self.root = root
@@ -113,10 +116,10 @@
 
     def chattr(self, path, attr):
         try:
-            SFTPServer.set_file_attr(path, attr)
+            paramiko.SFTPServer.set_file_attr(path, attr)
         except OSError, e:
-            return SFTPServer.convert_errno(e.errno)
-        return SFTP_OK
+            return paramiko.SFTPServer.convert_errno(e.errno)
+        return paramiko.SFTP_OK
 
     def list_folder(self, path):
         path = self._realpath(path)
@@ -130,26 +133,27 @@
             else:
                 flist = os.listdir(path)
             for fname in flist:
-                attr = SFTPAttributes.from_stat(os.stat(pathjoin(path, fname)))
+                attr = paramiko.SFTPAttributes.from_stat(
+                    os.stat(osutils.pathjoin(path, fname)))
                 attr.filename = fname
                 out.append(attr)
             return out
         except OSError, e:
-            return SFTPServer.convert_errno(e.errno)
+            return paramiko.SFTPServer.convert_errno(e.errno)
 
     def stat(self, path):
         path = self._realpath(path)
         try:
-            return SFTPAttributes.from_stat(os.stat(path))
+            return paramiko.SFTPAttributes.from_stat(os.stat(path))
         except OSError, e:
-            return SFTPServer.convert_errno(e.errno)
+            return paramiko.SFTPServer.convert_errno(e.errno)
 
     def lstat(self, path):
         path = self._realpath(path)
         try:
-            return SFTPAttributes.from_stat(os.lstat(path))
+            return paramiko.SFTPAttributes.from_stat(os.lstat(path))
         except OSError, e:
-            return SFTPServer.convert_errno(e.errno)
+            return paramiko.SFTPServer.convert_errno(e.errno)
 
     def open(self, path, flags, attr):
         path = self._realpath(path)
@@ -162,11 +166,11 @@
                 # an odd default mode for files
                 fd = os.open(path, flags, 0666)
         except OSError, e:
-            return SFTPServer.convert_errno(e.errno)
+            return paramiko.SFTPServer.convert_errno(e.errno)
 
         if (flags & os.O_CREAT) and (attr is not None):
             attr._flags &= ~attr.FLAG_PERMISSIONS
-            SFTPServer.set_file_attr(path, attr)
+            paramiko.SFTPServer.set_file_attr(path, attr)
         if flags & os.O_WRONLY:
             fstr = 'wb'
         elif flags & os.O_RDWR:
@@ -177,7 +181,7 @@
         try:
             f = os.fdopen(fd, fstr)
         except (IOError, OSError), e:
-            return SFTPServer.convert_errno(e.errno)
+            return paramiko.SFTPServer.convert_errno(e.errno)
         fobj = StubSFTPHandle()
         fobj.filename = path
         fobj.readfile = f
@@ -189,8 +193,8 @@
         try:
             os.remove(path)
         except OSError, e:
-            return SFTPServer.convert_errno(e.errno)
-        return SFTP_OK
+            return paramiko.SFTPServer.convert_errno(e.errno)
+        return paramiko.SFTP_OK
 
     def rename(self, oldpath, newpath):
         oldpath = self._realpath(oldpath)
@@ -198,8 +202,8 @@
         try:
             os.rename(oldpath, newpath)
         except OSError, e:
-            return SFTPServer.convert_errno(e.errno)
-        return SFTP_OK
+            return paramiko.SFTPServer.convert_errno(e.errno)
+        return paramiko.SFTP_OK
 
     def mkdir(self, path, attr):
         path = self._realpath(path)
@@ -212,18 +216,18 @@
                 os.mkdir(path)
             if attr is not None:
                 attr._flags &= ~attr.FLAG_PERMISSIONS
-                SFTPServer.set_file_attr(path, attr)
+                paramiko.SFTPServer.set_file_attr(path, attr)
         except OSError, e:
-            return SFTPServer.convert_errno(e.errno)
-        return SFTP_OK
+            return paramiko.SFTPServer.convert_errno(e.errno)
+        return paramiko.SFTP_OK
 
     def rmdir(self, path):
         path = self._realpath(path)
         try:
             os.rmdir(path)
         except OSError, e:
-            return SFTPServer.convert_errno(e.errno)
-        return SFTP_OK
+            return paramiko.SFTPServer.convert_errno(e.errno)
+        return paramiko.SFTP_OK
 
     # removed: chattr, symlink, readlink
     # (nothing in bzr's sftp transport uses those)



More information about the bazaar-commits mailing list