File: //usr/local/CyberCP/lib64/python3.10/site-packages/paramiko/__pycache__/sftp_client.cpython-310.pyc
o
�h� � @ sf d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlm Z d dl
mZ d dlm
Z
d dlmZmZmZ d dlmZmZmZmZmZmZmZmZmZmZmZmZmZm 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/m0Z0m1Z1m2Z2 d dl3m4Z4 d d l5m6Z6 d d
l7m8Z8 d dl9m:Z:m;Z;m<Z< dd
� Z=dZ>G dd� dee:�Z?G dd� de?�Z@dS )� )�hexlifyN)�util)�Channel)�Message)�INFO�DEBUG�o777) �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�int64)�SFTPAttributes)�SSHException)�SFTPFile)�ClosingContextManager�b�uc C sL z| � d�W S ttfy% z| �d�W Y S ty$ | Y Y S w w )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)�s� r5 �G/usr/local/CyberCP/lib/python3.10/site-packages/paramiko/sftp_client.py�_to_unicodeH s ��r7 � /c sj e Zd ZdZdd� ZedQdd��Z� fdd�Zd d
� Zdd� Z dRdd�Z
dRdd�ZdSdd�ZdTdd�Z
e
Zdd� ZeZdd� Zdd� Zefdd �Zd!d"� Zd#d$� Zd%d&� Zd'd(� Zd)d*� Zd+d,� Zd-d.� Zd/d0� Zd1d2� Zd3d4� ZdUd5d6�Zd7d8� Z d9d:� Z!dVd=d>�Z"dWd?d@�Z# < dXdAdB�Z$ < dXdCdD�Z%dEdF� Z&dGdH� Z'dUdIdJ�Z(dKdL� Z)dMdN� Z*dOdP� Z+� Z,S )Y�
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 C s� t �| � || _d| _d| _t�� | _d| _t �
� | _t|�t
u r5| j�� }t�|�� d �| _|�� | _z| �� }W n tyF td��w | �td�|�� dS )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<