Your IP : 18.224.38.176


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/ftplib.cpython-310.opt-2.pyc

o

6��f���@sL	ddlZddlZddlmZgd�ZdZdZdZGdd�de�ZGd	d
�d
e�Z	Gdd�de�Z
Gd
d�de�ZGdd�de�Zee
efZdZdZGdd�d�ZzddlZWneybdZYnwejZGdd�de�Ze�d�ee
eejfZdadd�Zdadd�Zdd�Zdd�Zdd �Z d(d#d$�Z!d%d&�Z"e#d'kr�e"�dSdS))�N)�_GLOBAL_DEFAULT_TIMEOUT)�FTP�error_reply�
error_temp�
error_perm�error_proto�
all_errors��� c@�eZdZdS)�ErrorN��__name__�
__module__�__qualname__�rr�-/opt/alt/python310/lib64/python3.10/ftplib.pyr
9�r
c@r)rNrrrrrr:rrc@r)rNrrrrrr;rrc@r)rNrrrrrr<rrc@r)rNrrrrrr=rr�
s
c@s�eZdZ	dZdZeZeZdZ	dZ
dZdZdZ
ddddedfdd�dd	�Zd
d�Zdd
�Zd\dd�Zdd�Zdd�ZeZdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Z d+d,�Z!d-d.�Z"d/d0�Z#d1d2�Z$d]d3d4�Z%d]d5d6�Z&d^d7d8�Z'd_d:d;�Z(d]d<d=�Z)d`d>d?�Z*d]d@dA�Z+dBdC�Z,dDdE�Z-dFdG�Z.dgfdHdI�Z/dJdK�Z0dLdM�Z1dNdO�Z2dPdQ�Z3dRdS�Z4dTdU�Z5dVdW�Z6dXdY�Z7dZd[�Z8dS)arr�NTF�utf-8��encodingcCs@	||_||_||_|r|�|�|r|�|||�dSdSdS�N)r�source_address�timeout�connect�login)�self�host�user�passwd�acctrrrrrr�__init__ms
�zFTP.__init__cCs|Srr�rrrr�	__enter__}sz
FTP.__enter__c	Gsf|jdur1z z|��WnttfyYnwW|jdur$|��dSdS|jdur0|��wwdSr)�sock�quit�OSError�EOFError�close)r�argsrrr�__exit__�s
��
�
��zFTP.__exit__����cCs�	|dkr||_|dkr||_|dkr||_|jdur"|js"td��|dur)||_t�d||j|j�tj|j|jf|j|jd�|_	|j	j
|_|j	jd|j
d�|_|��|_|jS)	Nrrr.z0Non-blocking socket (timeout=0) is not supportedzftplib.connect�r�rr)r �portr�
ValueErrorr�sys�audit�socket�create_connectionr'�family�af�makefiler�file�getresp�welcome)rr r1rrrrrr�s&�

zFTP.connectcCs 	|jr
td|�|j��|jS)Nz	*welcome*)�	debugging�print�sanitizer<r%rrr�
getwelcome�szFTP.getwelcomecC�	||_dSr)r=)r�levelrrr�set_debuglevel�s
zFTP.set_debuglevelcCrAr)�
passiveserver)r�valrrr�set_pasv�s
zFTP.set_pasvcCsJ|dd�dvr!t|�d��}|dd�d|d||d�}t|�S)N�>zpass �PASS r�*)�len�rstrip�repr)r�s�irrrr?�s$zFTP.sanitizecCs`d|vsd|vrtd��t�d||�|t}|jdkr$td|�|��|j�|�	|j
��dS)N�
�
z4an illegal newline character should not be containedzftplib.sendcmdr	z*put*)r2r3r4�CRLFr=r>r?r'�sendall�encoder�r�linerrr�putline�s
zFTP.putlinecCs$|jrtd|�|��|�|�dS)Nz*cmd*)r=r>r?rVrTrrr�putcmd�sz
FTP.putcmdcCs�|j�|jd�}t|�|jkrtd|j��|jdkr$td|�|��|s(t�|dd�t	kr8|dd�}|S|dd�t	vrF|dd�}|S)Nr	�got more than %d bytesz*get*������)
r:�readline�maxlinerJr
r=r>r?r*rQrTrrr�getline�s
�zFTP.getlinecCsf|��}|dd�dkr1|dd�}	|��}|d|}|dd�|kr0|dd�dkr0	|Sq|S)N���-r	rP)r])rrU�codeZnextlinerrr�getmultiline�s�zFTP.getmultilinecCsl|��}|jrtd|�|��|dd�|_|dd�}|dvr"|S|dkr*t|��|dkr2t|��t|��)Nz*resp*r^r	>�1�2�3�4�5)rbr=r>r?Zlastresprrr)r�resp�crrrr;�szFTP.getrespcCs&	|��}|dd�dkrt|��|S)Nr	rd)r;r�rrhrrr�voidresps
zFTP.voidrespcCsV	dt}|jdkrtd|�|��|j�|t�|��}|dd�dvr)t|��|S)N�ABORr	z*put urgent*r^�Z426Z225Z226)	�B_CRLFr=r>r?r'rR�MSG_OOBrbr�rrUrhrrr�aborts
z	FTP.abortcC�	|�|�|��Sr)rWr;�r�cmdrrr�sendcmd�
zFTP.sendcmdcCrrr)rWrkrsrrr�voidcmdrvzFTP.voidcmdcCsD	|�d�}t|d�t|d�g}||}dd�|�}|�|�S)N�.�zPORT �,)�splitrL�joinrw)rr r1ZhbytesZpbytes�bytesrtrrr�sendport s

zFTP.sendportcCsd	d}|jtjkrd}|jtjkrd}|dkrtd��dt|�|t|�dg}dd�|�}|�|�S)Nrr	�zunsupported address familyrzEPRT �|)r8r5�AF_INETZAF_INET6rrLr|rw)rr r1r8Zfieldsrtrrr�sendeprt*s
zFTP.sendeprtcCsn	tjd|jdd�}|��d}|j��d}|jtjkr$|�||�}n|�||�}|jt	ur5|�
|j�|S)N)rrr	)r7Zbacklogr)r5Z
create_serverr8Zgetsocknamer'r�r~r�rr�
settimeout)rr'r1r rhrrr�makeport7s
zFTP.makeportcCsj	|jtjkr$t|�d��\}}|jr|}||fS|j��d}||fSt|�d�|j���\}}||fS)N�PASVrZEPSV)	r8r5r��parse227ru�trust_server_pasv_ipv4_addressr'Zgetpeername�parse229)rZuntrusted_hostr1r rrr�makepasvDs��zFTP.makepasvc
Cs@	d}|jrG|��\}}tj||f|j|jd�}z&|dur$|�d|�|�|�}|ddkr3|��}|ddkr=t|��WnQ|�	��|�
��=}|durW|�d|�|�|�}|ddkrf|��}|ddkrpt|��|��\}}	|jtur�|�
|j�Wd�n1s�wY|dd�dkr�t|�}||fS)Nr/zREST %srrdrcr^�150)rDr�r5r6rrrur;rr+r�Zacceptrr��parse150)
rrt�rest�sizer r1�connrhr'Zsockaddrrrr�ntransfercmdPsF�
�


��zFTP.ntransfercmdcCs	|�||�dS)Nr)r�)rrtr�rrr�transfercmd�szFTP.transfercmdcCs�	|sd}|s	d}|s
d}|dkr|dvr|d}|�d|�}|ddkr-|�d|�}|ddkr:|�d	|�}|dd
krDt|��|S)NZ	anonymousr>rr`z
anonymous@zUSER rrerH�ACCT rd�rur)rr!r"r#rhrrrr�s"z	FTP.loginrcCs�	|�d�|�||��:}	|�|�}|sn||�qtdur2t|t�r<|��Wd�|��SWd�|��SWd�|��S1sIwY|��S�NzTYPE I)rwr�Zrecv�
_SSLSocket�
isinstance�unwraprk)rrt�callback�	blocksizer�r��datarrr�
retrbinary�s*


�

�	�
�	�
�	�	zFTP.retrbinaryc	Cs>	|durt}|�d�}|�|���}|jd|jd��]}	|�|jd�}t|�|jkr2td|j��|j	dkr>t
dt|��|sAn"|dd�tkrP|dd�}n|d	d�d
kr^|dd	�}||�qt
durpt|t
�rp|��Wd�n1szwYWd�|��SWd�|��S1s�wY|��S)N�TYPE Ar0rr	rXrz*retr*rYrZrP)�
print_linerur�r9rr[r\rJr
r=r>rLrQr�r�r�rk)rrtr�rhr��fprUrrr�	retrlines�s>
�
��(���z
FTP.retrlinescCs�	|�d�|�||��A}	|�|�}|sn|�|�|r!||�qtdur9t|t�rC|��Wd�|��SWd�|��SWd�|��S1sPwY|��Sr�)rwr��readrRr�r�r�rk)rrtr�r�r�r�r��bufrrr�
storbinary�s.


�

��
��
��zFTP.storbinarycCs	|�d�|�|��j}	|�|jd�}t|�|jkr#td|j��|s&n$|dd�tkr>|dtvr:|dd�}|t}|�|�|rI||�q
tdurat	|t�rk|�
�Wd�|��SWd�|��SWd�|��S1sxwY|��S)Nr�r	rXrYrZ)rwr�r[r\rJr
rnrRr�r�r�rk)rrtr�r�r�r�rrr�	storlines�s8

�

��
��
��z
FTP.storlinescCs	d|}|�|�S)Nr��rw)rZpasswordrtrrrr#s
zFTP.acctcGs2	d}|D]}|d|}qg}|�||j�|S)NZNLST� )r��append)rr,rt�arg�filesrrr�nlst#szFTP.nlstcGsj	d}d}|dd�r t|d�td�kr |dd�|d}}|D]
}|r,|d|}q"|�||�dS)NZLISTrZrr�)�typer�)rr,rt�funcr�rrr�dir,s �zFTP.dirc
cs��	|r|�dd�|�d�|rd|}nd}g}|�||j�|D].}|�t��d�\}}}i}	|dd��d�D]}
|
�d�\}}}||	|��<q<||	fVq$dS)Nz
OPTS MLST �;zMLSD %sZMLSDr�rZ�=)	rur|r�r�rKrQ�	partitionr{�lower)
r�pathZfactsrt�linesrUZfacts_found�_�name�entryZfact�key�valuerrr�mlsd;s"�
�zFTP.mlsdcCs2	|�d|�}|ddkrt|��|�d|�S)NzRNFR rrezRNTO )rurrw)rZfromnameZtonamerhrrr�renameWs
z
FTP.renamecCs,	|�d|�}|dd�dvr|St|��)NzDELE r^>Z250Z200r�)r�filenamerhrrr�delete^s
z
FTP.deletec
Csr	|dkr*z|�d�WSty)}z|jddd�dkr�WYd}~nd}~ww|dkr0d}d|}|�|�S)	Nz..ZCDUPrr^�500rrxzCWD )rwrr,)r�dirname�msgrtrrr�cwdfs���
zFTP.cwdcCs<	|�d|�}|dd�dkr|dd���}t|�SdS)NzSIZE r^Z213)ru�strip�int)rr�rhrMrrrr�ss�zFTP.sizecCs&	|�d|�}|�d�sdSt|�S)NzMKD �257r�rw�
startswith�parse257)rr�rhrrr�mkd{s

zFTP.mkdcCs	|�d|�S)NzRMD r�)rr�rrr�rmd�szFTP.rmdcCs"	|�d�}|�d�s
dSt|�S)NZPWDr�rr�rjrrr�pwd�s


zFTP.pwdcCs	|�d�}|��|S)NZQUIT)rwr+rjrrrr(�s
zFTP.quitcCsf	z!|j}d|_|dur|��W|j}d|_|dur!|��dSdS|j}d|_|dur2|��wwr)r:r+r')rr:r'rrrr+�s"���
�z	FTP.close)rrr.Nr)rrr)rN)rNN)9rrrr=r �FTP_PORTr1�MAXLINEr\r'r:r<rDr�rr$r&r-rr@rC�debugrFr?rVrWr]rbr;rkrqrurwr~r�r�r�r�r�rr�r�r�r�r#r�r�r�r�r�r�r�r�r�r�r(r+rrrrrJsr��






7



#
	
		rc	s�eZdZ	ejZdddddddedf	dd��fdd�Zd�fdd	�	Zd
d�Z	dd
�Z
dd�Zdd�Zd�fdd�	Z
dd�Z�ZS)�FTP_TLSrNrrc
	s�|dur|durtd��|dur|durtd��|dus |dur+ddl}|�dtd�||_||_|dur>tj|j||d�}||_	d|_
t�j||||||	|
d�dS)	Nz4context and keyfile arguments are mutually exclusivez5context and certfile arguments are mutually exclusiverzAkeyfile and certfile are deprecated, use a custom context insteadr)�certfile�keyfileFr)
r2�warnings�warn�DeprecationWarningr�r��sslZ_create_stdlib_context�ssl_version�context�_prot_p�superr$)rr r!r"r#r�r�r�rrrr���	__class__rrr$�s*��
�zFTP_TLS.__init__Tcs*|r
t|jtj�s
|��t��|||�Sr)r�r'r��	SSLSocket�authr�r)rr!r"r#Zsecurer�rrr�sz
FTP_TLS.logincCsh	t|jtj�rtd��|jtjkr|�d�}n|�d�}|jj	|j|j
d�|_|jjd|jd�|_
|S)NzAlready using TLSzAUTH TLSzAUTH SSL�Zserver_hostnamer0)�moder)r�r'r�r�r2r�ZPROTOCOL_TLSrwr��wrap_socketr r9rr:rjrrrr��s
zFTP_TLS.authcCs2	t|jtj�std��|�d�}|j��|_|S)Nz
not using TLSZCCC)r�r'r�r�r2rwr�rjrrr�ccc�s
zFTP_TLS.ccccCs 	|�d�|�d�}d|_|S)NzPBSZ 0zPROT PT�rwr�rjrrr�prot_ps



zFTP_TLS.prot_pcCs	|�d�}d|_|S)NzPROT CFr�rjrrr�prot_cs
zFTP_TLS.prot_ccs2t��||�\}}|jr|jj||jd�}||fS)Nr�)r�r�r�r�r�r )rrtr�r�r�r�rrr�s�zFTP_TLS.ntransfercmdcCs8dt}|j�|�|��}|dd�dvrt|��|S)Nrlr^rm)rnr'rRrbrrprrrrqsz
FTP_TLS.abort)rrrTr)rrrr�ZPROTOCOL_TLS_CLIENTr�rr$rr�r�r�r�r�rq�
__classcell__rrr�rr��s  ��r�cCs^	|dd�dkr
t|��tdurddl}|�d|j|jB�at�|�}|s(dSt|�d��S)Nr^r�rz150 .* \((\d+) bytes\)r	)	r�_150_re�re�compile�
IGNORECASE�ASCII�matchr��group)rhr��mrrrr�.s�
r�cCs�	|dd�dkr
t|��tdurddl}|�d|j�at�|�}|s't|��|��}d�|dd��}t	|d�d>t	|d�}||fS)	Nr^Z227rz#(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)rxr_�rG)
r�_227_rer�r�r��searchr�groupsr|r�)rhr�r�Znumbersr r1rrrr�Bs
r�cCs�	|dd�dkr
t|��|�d�}|dkrt|��|�d|d�}|dkr*t|��||d||dkr:t|��||d|��||d�}t|�dkrSt|��|d}t|d�}||fS)Nr^Z229�(r�)r	rG)r�findrr{rJr�)rhZpeer�left�right�partsr r1rrrr�Us 
r�cCs�	|dd�dkr
t|��|dd�dkrdSd}d}t|�}||krH||}|d}|dkr@||ks9||dkr<	|S|d}||}||ks#|S)Nr^r�rGz "rr	�")rrJ)rhr�rN�nrirrrr�js&��r�cCs	t|�dSr)r>)rUrrrr��sr�r�Ic	Cs�	|s|}d|}|�|�|�|�t|�d��\}}|�||�|�d|�}|dd�dvr3t�|�d|�}|dd�dvrDt�|��|��dS)NzTYPE r�zSTOR r^>Z125r��RETR )rwr�rur~rrk)	�sourceZ
sourcename�targetZ
targetnamer�Z
sourcehostZ
sourceportZtreplyZsreplyrrr�ftpcp�s 

r�cCs�	ttj�dkrttj�t�d�ddl}d}d}tjddkr0|d}tjd=tjddks!tjddd�dkrHtjddd�}tjd=tjd}t|�}|�	|�d}}}z|�|�}Wnt
yv|durttj�d�Ynwz
|�
|�\}}}Wnty�tj�d�Ynw|�|||�tjdd�D]K}	|	dd�d	kr�|�|	dd��q�|	dd�dkr�d
}
|	dd�r�|
d|	dd�}
|�|
�}q�|	dkr�|�|j�q�|�d
|	tjjd�q�|��dS)Nrrr	z-dz-rrz5Could not open account file -- using anonymous login.z$No account -- using anonymous login.z-lZCWDr�z-pr�i)rJr3�argvr>�test�__doc__�exit�netrcrrCr)�stderr�writeZauthenticators�KeyErrorrr�rurFrDr��stdoutr()r�r=Zrcfiler ZftpZuseridr"r#Znetrcobjr:rtrhrrrr��s\

�

���� 
�r��__main__)rr�)$r3r5r�__all__ror�r��	Exceptionr
rrrrr)r*rrQrnrr��ImportErrorr�r�r�r�ZSSLErrorr�r�r�r�r�r�r�r�r�rrrrr�<module>sT&
^�
}
9
�

?>