%PDF- %PDF-
Direktori : /lib/python3/dist-packages/paramiko/__pycache__/ |
Current File : //lib/python3/dist-packages/paramiko/__pycache__/sftp_si.cpython-312.pyc |
� �ec#1 � �: � d Z ddlZddlZddlmZ G d� de� Zy)z3 An interface to override for SFTP server support. � N��SFTP_OP_UNSUPPORTEDc �| � � e Zd ZdZ� fd�Zd� Zd� Zd� Zd� Zd� Z d� Z d � Zd � Zd� Z d� Zd � Zd� Zd� Zd� Zd� Z� xZS )�SFTPServerInterfacea� This class defines an interface for controlling the behavior of paramiko when using the `.SFTPServer` subsystem to provide an SFTP server. Methods on this class are called from the SFTP session's thread, so you can block as long as necessary without affecting other sessions (even other SFTP sessions). However, raising an exception will usually cause the SFTP session to abruptly end, so you will usually want to catch exceptions and return an appropriate error code. All paths are in string form instead of unicode because not all SFTP clients & servers obey the requirement that paths be encoded in UTF-8. c �, �� t t | � |i |�� y)a Create a new SFTPServerInterface object. This method does nothing by default and is meant to be overridden by subclasses. :param .ServerInterface server: the server object associated with this channel and SFTP subsystem N)�superr �__init__)�self�server�largs�kwargs� __class__s ��2/usr/lib/python3/dist-packages/paramiko/sftp_si.pyr zSFTPServerInterface.__init__+ s �� � �!�4�1�5�C�F�C� c � � y)z� The SFTP server session has just started. This method is meant to be overridden to perform any necessary setup before handling callbacks from SFTP operations. N� �r s r �session_startedz#SFTPServerInterface.session_started5 s � � r c � � y)z� The SFTP server session has just ended, either cleanly or via an exception. This method is meant to be overridden to perform any necessary cleanup before this `.SFTPServerInterface` object is destroyed. Nr r s r � session_endedz!SFTPServerInterface.session_ended= s � � r c � � t S )a Open a file on the server and create a handle for future operations on that file. On success, a new object subclassed from `.SFTPHandle` should be returned. This handle will be used for future operations on the file (read, write, etc). On failure, an error code such as ``SFTP_PERMISSION_DENIED`` should be returned. ``flags`` contains the requested mode for opening (read-only, write-append, etc) as a bitset of flags from the ``os`` module: - ``os.O_RDONLY`` - ``os.O_WRONLY`` - ``os.O_RDWR`` - ``os.O_APPEND`` - ``os.O_CREAT`` - ``os.O_TRUNC`` - ``os.O_EXCL`` (One of ``os.O_RDONLY``, ``os.O_WRONLY``, or ``os.O_RDWR`` will always be set.) The ``attr`` object contains requested attributes of the file if it has to be created. Some or all attribute fields may be missing if the client didn't specify them. .. note:: The SFTP protocol defines all files to be in "binary" mode. There is no equivalent to Python's "text" mode. :param str path: the requested path (relative or absolute) of the file to be opened. :param int flags: flags or'd together from the ``os`` module indicating the requested mode for opening the file. :param .SFTPAttributes attr: requested attributes of the file if it is newly created. :return: a new `.SFTPHandle` or error code. r )r �path�flags�attrs r �openzSFTPServerInterface.openF s � �L #�"r c � � t S )ab Return a list of files within a given folder. The ``path`` will use posix notation (``"/"`` separates folder names) and may be an absolute or relative path. The list of files is expected to be a list of `.SFTPAttributes` objects, which are similar in structure to the objects returned by ``os.stat``. In addition, each object should have its ``filename`` field filled in, since this is important to a directory listing and not normally present in ``os.stat`` results. The method `.SFTPAttributes.from_stat` will usually do what you want. In case of an error, you should return one of the ``SFTP_*`` error codes, such as ``SFTP_PERMISSION_DENIED``. :param str path: the requested path (relative or absolute) to be listed. :return: a list of the files in the given folder, using `.SFTPAttributes` objects. .. note:: You should normalize the given ``path`` first (see the `os.path` module) and check appropriate permissions before returning the list of files. Be careful of malicious clients attempting to use relative paths to escape restricted folders, if you're doing a direct translation from the SFTP server path to your local filesystem. r �r r s r �list_folderzSFTPServerInterface.list_foldern s � �<