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

Class SFTPServer

source code

                object --+    
                         |    
                  BaseSFTP --+
                             |
        object --+           |
                 |           |
threading._Verbose --+       |
                     |       |
      threading.Thread --+   |
                         |   |
          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.SFTPServerInterface'>, *largs, **kwargs)
The constructor for SFTPServer is meant to be called from within the Transport as a subsystem handler.
source code
 
finish_subsystem(self)
Perform any cleanup at the end of a subsystem.
source code
 
start_subsystem(self, name, transport, channel)
Process an ssh subsystem in server mode.
source code

Inherited from 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
int
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.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.

Parameters:
  • channel (Channel) - channel passed from the Transport.
  • name (str) - name of the requested subsystem.
  • server (ServerInterface) - the server object associated with this channel and subsystem
  • sftp_si (class) - a subclass of SFTPServerInterface to use for handling individual requests.
Overrides: object.__init__

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.

Parameters:
  • e (int) - an errno code, as from OSError.errno.
Returns: int
an SFTP error code like SFTP_NO_SUCH_FILE.

finish_subsystem(self)

source code 

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

Overrides: SubsystemHandler.finish_subsystem
(inherited documentation)

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.

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

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.

Parameters:
  • name - name of the requested subsystem.
  • transport - the server-mode Transport.
  • channel - the channel associated with this subsystem request.
Overrides: SubsystemHandler.start_subsystem
(inherited documentation)