Package paramiko :: Module sftp_server :: Class SFTPServer
[frames] | no frames]

Class SFTPServer

source code

                object --+    
                         |    
             sftp.BaseSFTP --+
                             |
        object --+           |
                 |           |
threading._Verbose --+       |
                     |       |
      threading.Thread --+   |
                         |   |
   server.SubsystemHandler --+
                             |
                            SFTPServer

Server-side SFTP subsystem support. Since this is a `.SubsystemHandler`, it can be (and is meant to be) set as the handler for ``"sftp"`` requests. Use `.Transport.set_subsystem_handler` to activate this class.

Instance Methods
 
__init__(self, channel, name, server, sftp_si=<class 'paramiko.sftp_si.SFTPServerInterface'>, *largs, **kwargs)
The constructor for SFTPServer is meant to be called from within the `.Transport` as a subsystem handler.
source code
 
start_subsystem(self, name, transport, channel)
Process an ssh subsystem in server mode.
source code
 
finish_subsystem(self)
Perform any cleanup at the end of a subsystem.
source code

Inherited from server.SubsystemHandler: get_server

Inherited from threading.Thread: __repr__, getName, isAlive, isDaemon, is_alive, join, run, setDaemon, setName, start

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods
 
convert_errno(e)
Convert an errno value (as from an ``OSError`` or ``IOError``) into a standard SFTP result code.
source code
 
set_file_attr(filename, attr)
Change a file's attributes on the local filesystem.
source code
Properties

Inherited from threading.Thread: daemon, ident, name

Inherited from object: __class__

Method Details

__init__(self, channel, name, server, sftp_si=<class 'paramiko.sftp_si.SFTPServerInterface'>, *largs, **kwargs)
(Constructor)

source code 

The constructor for SFTPServer is meant to be called from within the
`.Transport` as a subsystem handler.  ``server`` and any additional
parameters or keyword parameters are passed from the original call to
`.Transport.set_subsystem_handler`.

:param .Channel channel: channel passed from the `.Transport`.
:param str name: name of the requested subsystem.
:param .ServerInterface server:
    the server object associated with this channel and subsystem
:param class sftp_si:
    a subclass of `.SFTPServerInterface` to use for handling individual
    requests.

Overrides: object.__init__

start_subsystem(self, name, transport, channel)

source code 

Process an ssh subsystem in server mode. This method is called on a new object (and in a new thread) for each subsystem request. It is assumed that all subsystem logic will take place here, and when the subsystem is finished, this method will return. After this method returns, the channel is closed.

The combination of ``transport`` and ``channel`` are unique; this handler corresponds to exactly one `.Channel` on one `.Transport`.

.. note:

   It is the responsibility of this method to exit if the underlying
   `.Transport` is closed.  This can be done by checking
   `.Transport.is_active` or noticing an EOF on the `.Channel`.  If
   this method loops forever without checking for this case, your
   Python interpreter may refuse to exit because this thread will
   still be running.

:param str name: name of the requested subsystem. :param .Transport transport: the server-mode `.Transport`. :param .Channel channel: the channel associated with this subsystem request.

Overrides: server.SubsystemHandler.start_subsystem
(inherited documentation)

finish_subsystem(self)

source code 

Perform any cleanup at the end of a subsystem. The default implementation just closes the channel.

.. versionadded:: 1.1

Overrides: server.SubsystemHandler.finish_subsystem
(inherited documentation)

convert_errno(e)
Static Method

source code 

Convert an errno value (as from an ``OSError`` or ``IOError``) into a standard SFTP result code. This is a convenience function for trapping exceptions in server code and returning an appropriate result.

:param int e: an errno code, as from ``OSError.errno``. :return: an `int` SFTP error code like ``SFTP_NO_SUCH_FILE``.

set_file_attr(filename, attr)
Static Method

source code 

Change a file's attributes on the local filesystem.  The contents of
``attr`` are used to change the permissions, owner, group ownership,
and/or modification & access time of the file, depending on which
attributes are present in ``attr``.

This is meant to be a handy helper function for translating SFTP file
requests into local file operations.

:param str filename:
    name of the file to alter (should usually be an absolute path).
:param .SFTPAttributes attr: attributes to change.