%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/paramiko/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/paramiko/__pycache__/sftp_client.cpython-312.pyc

�

�ecJ���x�ddlmZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
ddlmZmZmZddlmZmZmZddlmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5dd	l6m7Z7dd
l8m9Z9ddl:m;Z;ddl<m=Z=d
�Z>dZ?Gd�dee=�Z@Gd�de@�ZAy)�)�hexlifyN)�util)�Channel)�Message)�INFO�DEBUG�o777)�b�u�long)�BaseSFTP�CMD_OPENDIR�
CMD_HANDLE�	SFTPError�CMD_READDIR�CMD_NAME�	CMD_CLOSE�SFTP_FLAG_READ�SFTP_FLAG_WRITE�SFTP_FLAG_CREATE�SFTP_FLAG_TRUNC�SFTP_FLAG_APPEND�SFTP_FLAG_EXCL�CMD_OPEN�
CMD_REMOVE�
CMD_RENAME�	CMD_MKDIR�	CMD_RMDIR�CMD_STAT�	CMD_ATTRS�	CMD_LSTAT�CMD_SYMLINK�CMD_SETSTAT�CMD_READLINK�CMD_REALPATH�
CMD_STATUS�CMD_EXTENDED�SFTP_OK�SFTP_EOF�SFTP_NO_SUCH_FILE�SFTP_PERMISSION_DENIED)�SFTPAttributes)�SSHException)�SFTPFile)�ClosingContextManagerc��	|jd�S#ttf$r(	|jd�cYS#t$r|cYcYSwxYwwxYw)z�
    decode a string as ascii or utf8 if possible (as required by the sftp
    protocol).  if neither works, just return a byte string because the server
    probably doesn't know the filename's encoding.
    �asciizutf-8)�encode�UnicodeError�AttributeError�decode)�ss �6/usr/lib/python3/dist-packages/paramiko/sftp_client.py�_to_unicoder8HsR����x�x�� � ���.�)��	��8�8�G�$�$���	��H�	���s)��A
�6�A
�A�A
�A�A
�/c� ��eZdZdZd�Zed&d��Z�fd�Zd�Zd�Z	d'd�Z
d'd�Zd(d	�Zd)d
�Z
e
Zd�ZeZd�Zd
�Zefd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd*d�Zd�Z d�Z!d+d�Z"d,d�Z#d,d�Z$d,d�Z%d �Z&d!�Z'd*d"�Z(d#�Z)d$�Z*d%�Z+�xZ,S)-�
SFTPClientz�
    SFTP client object.

    Used to open an SFTP session across an open SSH `.Transport` and perform
    remote file operations.

    Instances of this class may be used as context managers.
    c�<�tj|�||_d|_d|_tj�|_d|_tj�|_t|�turZ|jj�}tj |j#�dz�|_|j'�|_	|j)�}|j/t0dj3|��y#t*$rt-d��wxYw)a�
        Create an SFTP client from an existing `.Channel`.  The channel
        should already have requested the ``"sftp"`` subsystem.

        An alternate way to create an SFTP client context is by using
        `from_transport`.

        :param .Channel sock: an open `.Channel` using the ``"sftp"`` subsystem

        :raises:
            `.SSHException` -- if there's an exception while negotiating sftp
        F�Nz.sftpzEOF during negotiationz*Opened sftp connection (server version {}))r
�__init__�sock�ultra_debug�request_number�	threading�Lock�_lock�_cwd�weakref�WeakValueDictionary�
_expecting�typer�
get_transportr�
get_logger�get_log_channel�logger�get_hexdump�
_send_version�EOFErrorr-�_logr�format)�selfr?�	transport�server_versions    r7r>zSFTPClient.__init__ds���	���$����	� �������^�^�%��
���	�!�5�5�7�����:�� ��	�	�/�/�1�I��/�/��)�)�+�g�5��D�K� )�4�4�6�D��	9�!�/�/�1�N�	
�	�	��8�?�?��
�	
���	9��7�8�8�	9�s�D�Dc�`�|j||��}|�y|jd�||�S)a\
        Create an SFTP client channel from an open `.Transport`.

        Setting the window and packet sizes might affect the transfer speed.
        The default settings in the `.Transport` class are the same as in
        OpenSSH and should work adequately for both files transfers and
        interactive sessions.

        :param .Transport t: an open `.Transport` which is already
            authenticated
        :param int window_size:
            optional window size for the `.SFTPClient` session.
        :param int max_packet_size:
            optional max packet size for the `.SFTPClient` session..

        :return:
            a new `.SFTPClient` object, referring to an sftp session (channel)
            across the transport

        .. versionchanged:: 1.15
            Added the ``window_size`` and ``max_packet_size`` arguments.
        )�window_size�max_packet_sizeN�sftp)�open_session�invoke_subsystem)�cls�trWrX�chans     r7�from_transportzSFTPClient.from_transport�s>��0�~�~�#�_��
���<�����f�%��4�y��c���t|t�r|D]}|j||g|����y|jdd�}t	t
|�
|d|zg|jj�gt|�z���y)N�%z%%z
[chan %s] )�
isinstance�listrQ�replace�superr;r?�get_name)rS�level�msg�args�m�	__class__s     �r7rQzSFTPClient._log�s�����c�4� ��
+����	�	�%��*�T�*�
+��+�+�c�4�(�C��*�d�(���s�"�
��9�9�%�%�'�(�4��:�5�
r`c�d�|jtd�|jj�y)zc
        Close the SFTP session and its underlying channel.

        .. versionadded:: 1.4
        zsftp session closed.N)rQrr?�close�rSs r7rnzSFTPClient.close�s!��	
�	�	�$�.�/��	�	���r`c��|jS)z�
        Return the underlying `.Channel` object for this SFTP session.  This
        might be useful for doing things like setting a timeout on the channel.

        .. versionadded:: 1.7.1
        )r?ros r7�get_channelzSFTPClient.get_channel�s���y�y�r`c�^�|j|�D�cgc]}|j��c}Scc}w)a�
        Return a list containing the names of the entries in the given
        ``path``.

        The list is in arbitrary order.  It does not include the special
        entries ``'.'`` and ``'..'`` even if they are present in the folder.
        This method is meant to mirror ``os.listdir`` as closely as possible.
        For a list of full `.SFTPAttributes` objects, see `listdir_attr`.

        :param str path: path to list (defaults to ``'.'``)
        )�listdir_attr�filename)rS�path�fs   r7�listdirzSFTPClient.listdir�s'��%)�$5�$5�d�$;�<�q��
�
�<�<��<s�*c��|j|�}|jtdj|��|j	t
|�\}}|tk7rtd��|j�}g}		|j	t|�\}}|tk7rtd��|j�}t|�D]V}|j�}|j�}	tj |||	�}
|dk7s�@|dk7s�F|j#|
��X��#t$rYnwxYw|j	t$|�|S)a�
        Return a list containing `.SFTPAttributes` objects corresponding to
        files in the given ``path``.  The list is in arbitrary order.  It does
        not include the special entries ``'.'`` and ``'..'`` even if they are
        present in the folder.

        The returned `.SFTPAttributes` objects will each have an additional
        field: ``longname``, which may contain a formatted string of the file's
        attributes, in unix format.  The content of this string will probably
        depend on the SFTP server implementation.

        :param str path: path to list (defaults to ``'.'``)
        :return: list of `.SFTPAttributes` objects

        .. versionadded:: 1.2
        �
listdir({!r})�Expected handle�Expected name response�.�..)�_adjust_cwdrQrrR�_requestrrr�
get_binaryrrPr�get_int�range�get_textr,�	_from_msg�appendr)rSrur]ri�handle�filelist�count�irt�longname�attrs           r7rszSFTPClient.listdir_attr�s&��"����%���	�	�%��/�/��5�6����{�D�1���3��
�?��-�.�.����!�����
����{�F�;���3��H�}�� 8�9�9��K�K�M�E��5�\�
*���<�<�>���<�<�>��%�/�/��X�x�H����O�(�d�*:��O�O�D�)�
*����
��
��	
�
�
�i��(��s�8D�	D&�%D&c#�bK�|j|�}|jtdj|��|j	t
|�\}}|tk7rtd��|j�}t�}		t|�D]3}|jtd�t|�}|j|��5|D]�}|j�\}}	t!|	�}|j#�}
||
k(r|t$k(r|j'|�|j#�}t|�D]I}|j)�}|j)�}
t+j,|||
�}|dk7s�@|dk7s�F|���K��t�}��	#t.$r|j	t0|�YywxYw�w)a�
        Generator version of `.listdir_attr`.

        See the API docs for `.listdir_attr` for overall details.

        This function adds one more kwarg on top of `.listdir_attr`:
        ``read_aheads``, an integer controlling how many
        ``SSH_FXP_READDIR`` requests are made to the server. The default of 50
        should suffice for most file listings as each request/response cycle
        may contain multiple files (dependent on server implementation.)

        .. versionadded:: 1.15
        ryrzNr|r})r~rQrrRrrrr�
get_stringrdr��_async_requestrIrr��_read_packetrr�r&�_convert_statusr�r,r�rPr)rSru�read_aheadsr]rir��numsr��num�pkt_data�new_numr�rtr�r�s               r7�listdir_iterzSFTPClient.listdir_iters���������%���	�	�%��/�/��5�6����{�D�1���3��
�?��-�.�.����!���v���%
�
�{�+�%�A��-�-�d�4�j�+�v�N�C��K�K��$�%� �'�C�"&�"3�"3�"5�K�A�x�!�(�+�C�!�k�k�m�G��g�~��
�?� �0�0��5��K�K�M�E�"�5�\�'��#&�<�<�>��#&�<�<�>��-�7�7���8� ��%��O�(�d�2B�"&�J�'�'�$�v��E��H�
��
�
�i��0��
�s7�A?F/�C-F
�0F
�6F
�F/�
F,�)F/�+F,�,F/c�X�|j|�}|jtdj||��d}d|vsd|vr	|tz}d|vsd|vsd|vr	|t
z}d|vr|ttzz}d|vr|ttzz}d|vr|ttzz}t�}|jt|||�\}}|tk7rtd��|j�}|jtd	j||t!t#|����t%||||�S)
aT
        Open a file on the remote server.  The arguments are the same as for
        Python's built-in `python:file` (aka `python:open`).  A file-like
        object is returned, which closely mimics the behavior of a normal
        Python file object, including the ability to be used as a context
        manager.

        The mode indicates how the file is to be opened: ``'r'`` for reading,
        ``'w'`` for writing (truncating an existing file), ``'a'`` for
        appending, ``'r+'`` for reading/writing, ``'w+'`` for reading/writing
        (truncating an existing file), ``'a+'`` for reading/appending.  The
        Python ``'b'`` flag is ignored, since SSH treats all files as binary.
        The ``'U'`` flag is supported in a compatible way.

        Since 1.5.2, an ``'x'`` flag indicates that the operation should only
        succeed if the file was created and did not previously exist.  This has
        no direct mapping to Python's file flags, but is commonly known as the
        ``O_EXCL`` flag in posix.

        The file will be buffered in standard Python style by default, but
        can be altered with the ``bufsize`` parameter.  ``<=0`` turns off
        buffering, ``1`` uses line buffering, and any number greater than 1
        (``>1``) uses that specific buffer size.

        :param str filename: name of the file to open
        :param str mode: mode (Python-style) to open in
        :param int bufsize: desired buffering (default: ``-1``)
        :return: an `.SFTPFile` object representing the open file

        :raises: ``IOError`` -- if the file could not be opened.
        zopen({!r}, {!r})r�r�+�w�a�xrzzopen({!r}, {!r}) -> {})r~rQrrRrrrrrrr,rrrrr�rrr.)	rSrt�mode�bufsize�imode�	attrblockr]rir�s	         r7�openzSFTPClient.openFs/��@�#�#�H�-���	�	�%�+�2�2�8�T�B�C����4�K�S�D�[��^�#�E��4�K�S�D�[�c�T�k��_�$�E��$�;��%��7�7�E��$�;��%�(8�8�8�E��$�;��%��6�6�E�"�$�	����x��5�)�D���3��
�?��-�.�.����!���	�	��$�+�+��$��'�&�/� 2�
�	
���f�d�G�4�4r`c��|j|�}|jtdj|��|j	t
|�y)a 
        Remove the file at the given path.  This only works on files; for
        removing folders (directories), use `rmdir`.

        :param str path: path (absolute or relative) of the file to remove

        :raises: ``IOError`` -- if the path refers to a folder (directory)
        zremove({!r})N)r~rQrrRrr�rSrus  r7�removezSFTPClient.remove�s;������%���	�	�%��.�.�t�4�5��
�
�j�$�'r`c���|j|�}|j|�}|jtdj||��|j	t
||�y)a3
        Rename a file or folder from ``oldpath`` to ``newpath``.

        .. note::
            This method implements 'standard' SFTP ``RENAME`` behavior; those
            seeking the OpenSSH "POSIX rename" extension behavior should use
            `posix_rename`.

        :param str oldpath:
            existing name of the file or folder
        :param str newpath:
            new name for the file or folder, must not exist already

        :raises:
            ``IOError`` -- if ``newpath`` is a folder, or something else goes
            wrong
        zrename({!r}, {!r})N)r~rQrrRrr�rS�oldpath�newpaths   r7�renamezSFTPClient.rename�sP��$�"�"�7�+���"�"�7�+���	�	�%�-�4�4�W�g�F�G��
�
�j�'�7�3r`c���|j|�}|j|�}|jtdj||��|j	t
d||�y)a�
        Rename a file or folder from ``oldpath`` to ``newpath``, following
        posix conventions.

        :param str oldpath: existing name of the file or folder
        :param str newpath: new name for the file or folder, will be
            overwritten if it already exists

        :raises:
            ``IOError`` -- if ``newpath`` is a folder, posix-rename is not
            supported by the server or something else goes wrong

        :versionadded: 2.2
        zposix_rename({!r}, {!r})zposix-rename@openssh.comN)r~rQrrRrr'r�s   r7�posix_renamezSFTPClient.posix_rename�sV���"�"�7�+���"�"�7�+���	�	�%�3�:�:�7�G�L�M��
�
��4�g�w�	
r`c���|j|�}|jtdj||��t	�}||_|j
t||�y)as
        Create a folder (directory) named ``path`` with numeric mode ``mode``.
        The default mode is 0777 (octal).  On some systems, mode is ignored.
        Where it is used, the current umask value is first masked out.

        :param str path: name of the folder to create
        :param int mode: permissions (posix-style) for the newly-created folder
        zmkdir({!r}, {!r})N)r~rQrrRr,�st_moderr�rSrur�r�s    r7�mkdirzSFTPClient.mkdir�sO������%���	�	�%�,�3�3�D�$�?�@��������
�
�i��t�,r`c��|j|�}|jtdj|��|j	t
|�y)zj
        Remove the folder named ``path``.

        :param str path: name of the folder to remove
        zrmdir({!r})N)r~rQrrRrrr�s  r7�rmdirzSFTPClient.rmdir�s;������%���	�	�%��-�-�d�3�4��
�
�i��&r`c���|j|�}|jtdj|��|j	t
|�\}}|tk7rtd��tj|�S)a8
        Retrieve information about a file on the remote system.  The return
        value is an object whose attributes correspond to the attributes of
        Python's ``stat`` structure as returned by ``os.stat``, except that it
        contains fewer fields.  An SFTP server may return as much or as little
        info as it wants, so the results may vary from server to server.

        Unlike a Python `python:stat` object, the result may not be accessed as
        a tuple.  This is mostly due to the author's slack factor.

        The fields supported are: ``st_mode``, ``st_size``, ``st_uid``,
        ``st_gid``, ``st_atime``, and ``st_mtime``.

        :param str path: the filename to stat
        :return:
            an `.SFTPAttributes` object containing attributes about the given
            file
        z
stat({!r})�Expected attributes)
r~rQrrRrrr rr,r��rSrur]ris    r7�statzSFTPClient.stat�se��&����%���	�	�%��,�,�T�2�3����x��.���3��	�>��1�2�2��'�'��,�,r`c���|j|�}|jtdj|��|j	t
|�\}}|tk7rtd��tj|�S)aZ
        Retrieve information about a file on the remote system, without
        following symbolic links (shortcuts).  This otherwise behaves exactly
        the same as `stat`.

        :param str path: the filename to stat
        :return:
            an `.SFTPAttributes` object containing attributes about the given
            file
        zlstat({!r})r�)
r~rQrrRrr!r rr,r�r�s    r7�lstatzSFTPClient.lstat�se������%���	�	�%��-�-�d�3�4����y�$�/���3��	�>��1�2�2��'�'��,�,r`c��|j|�}|jtdj||��t	|�}|jt||�y)z�
        Create a symbolic link to the ``source`` path at ``destination``.

        :param str source: path of the original file
        :param str dest: path of the newly created symlink
        zsymlink({!r}, {!r})N)r~rQrrRr
rr")rS�source�dests   r7�symlinkzSFTPClient.symlinksI������%���	�	�%�.�5�5�f�d�C�D��6����
�
�k�6�4�0r`c���|j|�}|jtdj||��t	�}||_|j
t||�y)a
        Change the mode (permissions) of a file.  The permissions are
        unix-style and identical to those used by Python's `os.chmod`
        function.

        :param str path: path of the file to change the permissions of
        :param int mode: new permissions
        zchmod({!r}, {!r})N)r~rQrrRr,r�rr#r�s    r7�chmodzSFTPClient.chmodsO������%���	�	�%�,�3�3�D�$�?�@��������
�
�k�4��.r`c���|j|�}|jtdj|||��t	�}||c|_|_|jt||�y)a�
        Change the owner (``uid``) and group (``gid``) of a file.  As with
        Python's `os.chown` function, you must pass both arguments, so if you
        only want to change one, use `stat` first to retrieve the current
        owner and group.

        :param str path: path of the file to change the owner and group of
        :param int uid: new owner's uid
        :param int gid: new group id
        zchown({!r}, {!r}, {!r})N)	r~rQrrRr,�st_uid�st_gidrr#)rSru�uid�gidr�s     r7�chownzSFTPClient.chownsZ������%���	�	�%�2�9�9�$��S�I�J����#&�� ���T�[��
�
�k�4��.r`c�&�|j|�}|�(tj�tj�f}|jtdj	||��t�}|\|_|_|jt||�y)a�
        Set the access and modified times of the file specified by ``path``.
        If ``times`` is ``None``, then the file's access and modified times
        are set to the current time.  Otherwise, ``times`` must be a 2-tuple
        of numbers, of the form ``(atime, mtime)``, which is used to set the
        access and modified times, respectively.  This bizarre API is mimicked
        from Python for the sake of consistency -- I apologize.

        :param str path: path of the file to modify
        :param tuple times:
            ``None`` or a tuple of (access time, modified time) in standard
            internet epoch time (seconds since 01 January 1970 GMT)
        Nzutime({!r}, {!r}))
r~�timerQrrRr,�st_atime�st_mtimerr#)rSru�timesr�s    r7�utimezSFTPClient.utime0sq������%���=��Y�Y�[�$�)�)�+�.�E��	�	�%�,�3�3�D�%�@�A����',�$��
�t�}��
�
�k�4��.r`c���|j|�}|jtdj||��t	�}||_|j
t||�y)a0
        Change the size of the file specified by ``path``.  This usually
        extends or shrinks the size of the file, just like the `~file.truncate`
        method on Python file objects.

        :param str path: path of the file to modify
        :param int size: the new size of the file
        ztruncate({!r}, {!r})N)r~rQrrRr,�st_sizerr#)rSru�sizer�s    r7�truncatezSFTPClient.truncateFsO������%���	�	�%�/�6�6�t�T�B�C��������
�
�k�4��.r`c�d�|j|�}|jtdj|��|j	t
|�\}}|tk7rtd��|j�}|dk(ry|dk7rtdj|���t|j��S)a
        Return the target of a symbolic link (shortcut).  You can use
        `symlink` to create these.  The result may be either an absolute or
        relative pathname.

        :param str path: path of the symbolic link file
        :return: target path, as a `str`
        zreadlink({!r})r{rNr=zReadlink returned {} results)r~rQrrRrr$rrr�r8r��rSrur]rir�s     r7�readlinkzSFTPClient.readlinkUs�������%���	�	�%�)�0�0��6�7����|�T�2���3���=��4�5�5����
���A�:���A�:��:�A�A�%�H�I�I��3�>�>�+�,�,r`c�F�|j|�}|jtdj|��|j	t
|�\}}|tk7rtd��|j�}|dk7rtdj|���|j�S)a�
        Return the normalized path (on the server) of a given path.  This
        can be used to quickly resolve symbolic links or determine what the
        server is considering to be the "current folder" (by passing ``'.'``
        as ``path``).

        :param str path: path to be normalized
        :return: normalized form of the given path (as a `str`)

        :raises: ``IOError`` -- if the path can't be resolved on the server
        znormalize({!r})r{r=zRealpath returned {} results)
r~rQrrRrr%rrr�r�r�s     r7�	normalizezSFTPClient.normalizejs�������%���	�	�%�*�1�1�$�7�8����|�T�2���3���=��4�5�5����
���A�:��:�A�A�%�H�I�I��|�|�~�r`c�0�|�d|_ytj|j|�j�s?tj
}t
|djtj|�|���t|j|��|_y)aS
        Change the "current directory" of this SFTP session.  Since SFTP
        doesn't really have the concept of a current working directory, this is
        emulated by Paramiko.  Once you use this method to set a working
        directory, all operations on this `.SFTPClient` object will be relative
        to that path. You can pass in ``None`` to stop using a current working
        directory.

        :param str path: new current working directory

        :raises:
            ``IOError`` -- if the requested path doesn't exist on the server

        .. versionadded:: 1.4
        Nz{}: {})rEr��S_ISDIRr��errno�ENOTDIRrrR�os�strerrorr
r�)rSru�codes   r7�chdirzSFTPClient.chdir�sl�� �<��D�I���|�|�D�I�I�d�O�3�3�4��=�=�D��D�(�/�/�"�+�+�d�2C�T�"J�K�K��d�n�n�T�*�+��	r`c�H�|jxrt|j�S)z�
        Return the "current working directory" for this SFTP session, as
        emulated by Paramiko.  If no directory has been set with `chdir`,
        this method will return ``None``.

        .. versionadded:: 1.4
        )rErros r7�getcwdzSFTPClient.getcwd�s���y�y�)�Q�t�y�y�\�)r`c��d}	|jd�}|j|�|t|�z
}t|�dk(r	|S|�	|||��M)Nri�)�read�write�len)rS�reader�writer�	file_size�callbackr��datas       r7�_transfer_with_callbackz"SFTPClient._transfer_with_callback�s^������;�;�u�%�D��L�L����C��I��D��4�y�A�~�����#���y�)�r`c�F�|j|d�5}|jd�|j||||��}ddd�|rG|j|�}|jk7r%tdj
|j|���|St�}|S#1swY�^xYw)a�
        Copy the contents of an open file object (``fl``) to the SFTP server as
        ``remotepath``. Any exception raised by operations will be passed
        through.

        The SFTP operations use pipelining for speed.

        :param fl: opened file or file-like object to copy
        :param str remotepath: the destination path on the SFTP server
        :param int file_size:
            optional size parameter passed to callback. If none is specified,
            size defaults to 0
        :param callable callback:
            optional callback function (form: ``func(int, int)``) that accepts
            the bytes transferred so far and the total bytes to be transferred
            (since 1.7.4)
        :param bool confirm:
            whether to do a stat() on the file afterwards to confirm the file
            size (since 1.7.7)

        :return:
            an `.SFTPAttributes` object containing attributes about the given
            file.

        .. versionadded:: 1.10
        �wbT�r�r�r�r�Nzsize mismatch in put!  {} != {})�file�
set_pipelinedr�r�r��IOErrorrRr,)	rS�fl�
remotepathr�r��confirm�frr�r6s	         r7�putfozSFTPClient.putfo�s���6�Y�Y�z�4�
(�	�B����T�"��/�/��"�	�H�0��D�	�
��	�	�*�%�A��y�y�D� ��5�<�<�Q�Y�Y��M���
��� �A���	�	�s�'B�B c��tj|�j}t|d�5}|j	|||||�cddd�S#1swYyxYw)an
        Copy a local file (``localpath``) to the SFTP server as ``remotepath``.
        Any exception raised by operations will be passed through.  This
        method is primarily provided as a convenience.

        The SFTP operations use pipelining for speed.

        :param str localpath: the local file to copy
        :param str remotepath: the destination path on the SFTP server. Note
            that the filename should be included. Only specifying a directory
            may result in an error.
        :param callable callback:
            optional callback function (form: ``func(int, int)``) that accepts
            the bytes transferred so far and the total bytes to be transferred
        :param bool confirm:
            whether to do a stat() on the file afterwards to confirm the file
            size

        :return: an `.SFTPAttributes` object containing attributes about the
            given file

        .. versionadded:: 1.4
        .. versionchanged:: 1.7.4
            ``callback`` and rich attribute return value added.
        .. versionchanged:: 1.7.7
            ``confirm`` param added.
        �rbN)r�r�r�r�r�)rS�	localpathr�r�r�r�r�s       r7�putzSFTPClient.put�sQ��8�G�G�I�&�.�.�	�
�)�T�
"�	L�b��:�:�b�*�i��7�K�	L�	L�	L�s�A�Ac���|j|�j}|j|d�5}|r|j|�|j	||||��cddd�S#1swYyxYw)a�
        Copy a remote file (``remotepath``) from the SFTP server and write to
        an open file or file-like object, ``fl``.  Any exception raised by
        operations will be passed through.  This method is primarily provided
        as a convenience.

        :param object remotepath: opened file or file-like object to copy to
        :param str fl:
            the destination path on the local host or open file object
        :param callable callback:
            optional callback function (form: ``func(int, int)``) that accepts
            the bytes transferred so far and the total bytes to be transferred
        :param bool prefetch:
            controls whether prefetching is performed (default: True)
        :return: the `number <int>` of bytes written to the opened file object

        .. versionadded:: 1.10
        .. versionchanged:: 2.8
            Added the ``prefetch`` keyword argument.
        r�r�N)r�r�r��prefetchr�)rSr�r�r�r�r�r�s       r7�getfozSFTPClient.getfo�sh��*�I�I�j�)�1�1�	�
�Y�Y�z�4�
(�	�B�����I�&��/�/��"�	�H�0��	�	�	�s�(A � A)c��t|d�5}|j||||�}ddd�tj|�}|jk7r%tdj
|j|���y#1swY�SxYw)aO
        Copy a remote file (``remotepath``) from the SFTP server to the local
        host as ``localpath``.  Any exception raised by operations will be
        passed through.  This method is primarily provided as a convenience.

        :param str remotepath: the remote file to copy
        :param str localpath: the destination path on the local host
        :param callable callback:
            optional callback function (form: ``func(int, int)``) that accepts
            the bytes transferred so far and the total bytes to be transferred
        :param bool prefetch:
            controls whether prefetching is performed (default: True)

        .. versionadded:: 1.4
        .. versionchanged:: 1.7.4
            Added the ``callback`` param
        .. versionchanged:: 2.8
            Added the ``prefetch`` keyword argument.
        r�Nzsize mismatch in get!  {} != {})r�r�r�r�r�r�rR)rSr�r�r�r�r�r�r6s        r7�getzSFTPClient.gets}��(�)�T�
"�	B�b��:�:�j�"�h��A�D�	B��G�G�I����9�9����1�8�8����D�I��
��	B�	B�s�A4�4A=c�^�|jtd�|g|���}|j|�S�N)r�rI�_read_response)rSr]�argr�s    r7rzSFTPClient._request4s0��!�d�!�!�$�t�*�a�6�#�6���"�"�3�'�'r`c�x�|jj�	t�}|j|j�|D]y}t|t�r|j|��%t|t�r|j|��Gt|t�r|j|��i|j|��{|j}||j|<|xjdz
c_|jj�|j||�|S#|jj�wxYw)Nr=)rD�acquirer�add_intrArcr�	add_int64�intr,�_pack�
add_stringrH�release�_send_packet)rS�fileobjr]r�ri�itemr�s       r7r�zSFTPClient._async_request8s����
�
����	!��)�C��K�K��+�+�,��

)���d�D�)��M�M�$�'���c�*��K�K��%���n�5��J�J�s�O��N�N�4�(�

)��%�%�C�#*�D�O�O�C� ����1�$���J�J��� ����!�S�!��
��
�J�J��� �s�CD�D9c��		|j�\}}t	|�}|j�}|jj�	||jvr_|jtdj|��|�	|jj�y	|jj���|j|}|j|=|jj�||k(r|tk(r|j|�||fS|td�ur|j|||�|�	y��6#t$r}tdj|���d}~wwxYw#|jj�wxYw)NzServer connection dropped: {}zUnexpected response #{}�NN)r�rPr-rRrr�rDrrHrQrrr&r�rI�_async_response)rS�waitforr]r��erir�rs        r7r�zSFTPClient._read_responseQsf���
N��+�+�-���4��$�-�C��+�+�-�C��J�J��� �
%��d�o�o�-��I�I�e�%>�%E�%E�c�%J�K����
�
�
�"�"�$��%��
�
�"�"�$��/�/�#�.���O�O�C�(��
�
�"�"�$��g�~��
�?��(�(��-��#�v�
��d�4�j�(��'�'��3��4�����E���
N�"�#B�#I�#I�!�#L�M�M��
N��"�
�
�"�"�$�s)�D8�5E#�9E#�8	E �E�E �#E?c��||jj�vr>|j�|j�||jj�vr�=yyr�)rH�valuesr��_check_exception)rSrs  r7�_finish_responseszSFTPClient._finish_responsesvsF������/�/�1�1����!��$�$�&�����/�/�1�1r`c� �|j�}|j�}|tk(ry|tk(rt	|��|t
k(rt
tj|��|tk(rt
tj|��t
|��)zU
        Raises EOFError or IOError on error status; otherwise does nothing.
        N)r�r�r(r)rPr*r�r��ENOENTr+�EACCES)rSrir��texts    r7r�zSFTPClient._convert_status{st���{�{�}���|�|�~���7�?��
�X�
��4�.� �
�&�
&��%�,�,��-�-�
�+�
+��%�,�,��-�-��$�-�r`c���t|�}|j�|St|�r|ddtk(r|S|jtk(r|j|zS|jtz|zS)zr
        Return an adjusted path if we're emulating a "current working
        directory" for the server.
        rr=)r
rEr��b_slashr�s  r7r~zSFTPClient._adjust_cwd�sd��
��w���9�9���K��t�9��a���g�-��K��9�9����9�9�t�#�#��y�y�7�"�T�)�)r`r)r|)r|�2)r����r�)rNT)NT)-�__name__�
__module__�__qualname__�__doc__r>�classmethodr_rQrnrqrwrsr�r�r�r��unlinkr�r�r	r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�rr�r~�
__classcell__)rls@r7r;r;Zs�����&
�P����>� ��=�(�T>�@85�v�D�(��F�4�.
�, $�
-�'�-�4-�$
1�
/�/�"/�,
/�-�*�,,�0	*�
�(�TL�@�:�<(��2#�J'�
 �$
*r`r;c��eZdZdZy)�SFTPzA
    An alias for `.SFTPClient` for backwards compatibility.
    N)rrrr�r`r7r#r#�s���	r`r#)B�binasciirr�r�r�rBr�rF�paramikor�paramiko.channelr�paramiko.messager�paramiko.commonrrr	�paramiko.py3compatr
rr�
paramiko.sftpr
rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+�paramiko.sftp_attrr,�paramiko.ssh_exceptionr-�paramiko.sftp_filer.�
paramiko.utilr/r8rr;r#r$r`r7�<module>r0s���(��	������$�$�-�-�)�)� � � � � � � � � �D.�/�'�/����@
*��0�@
*�F	�:�	r`

Zerion Mini Shell 1.0