Your IP : 18.191.233.198


Current Path : /opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/__pycache__/ftplib.cpython-39.opt-2.pyc

a

R�f���@sHddlZddlZddlmZgd�ZdZdZdZGdd�de�ZGd	d
�d
e�Z	Gdd�de�Z
Gd
d�de�ZGdd�de�Zee
efZdZdZGdd�d�ZzddlZWney�dZYn00ejZGdd�de�Ze�d�ee
eejfZdadd�Zdadd�Zdd�Zdd�Zdd �Z d(d#d$�Z!d%d&�Z"e#d'k�rDe"�dS))�N)�_GLOBAL_DEFAULT_TIMEOUT)�FTP�error_reply�
error_temp�
error_perm�error_proto�
all_errors��� c@seZdZdS)�ErrorN��__name__�
__module__�__qualname__�rr�+/opt/alt/python39/lib64/python3.9/ftplib.pyr9�rc@seZdZdS)rNr
rrrrr:rrc@seZdZdS)rNr
rrrrr;rrc@seZdZdS)rNr
rrrrr<rrc@seZdZdS)rNr
rrrrr=rr�
s
c@s�eZdZdZdZeZeZdZ	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(dad<d=�Z)dbd>d?�Z*dcd@dA�Z+dBdC�Z,dDdE�Z-dFdG�Z.dgfdHdI�Z/dJdK�Z0dLdM�Z1dNdO�Z2dPdQ�Z3dRdS�Z4dTdU�Z5dVdW�Z6dXdY�Z7dZd[�Z8dS)drr�NTF�utf-8��encodingcCs6||_||_||_|r2|�|�|r2|�|||�dS�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	Gs^|jdurZz:z|��Wnttfy.Yn0W|jdurZ|��n|jdurX|��0dSr)�sock�quit�OSError�EOFError�close)r�argsrrr�__exit__�s


�
zFTP.__exit__����cCs�|dkr||_|dkr||_|dkr*||_|jdurB|jsBtd��|durP||_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)rrr0rrrrrr�s$�

zFTP.connectcCs|jrtd|�|j��|jS)Nz	*welcome*)�	debugging�print�sanitizer;r$rrr�
getwelcome�szFTP.getwelcomecCs
||_dSr)r<)r�levelrrr�set_debuglevel�szFTP.set_debuglevelcCs
||_dSr)�
passiveserver)r�valrrr�set_pasv�szFTP.set_pasvcCsJ|dd�dvrBt|�d��}|dd�d|d||d�}t|�S)N�>zpass �PASS r�*)�len�rstrip�repr)r�s�irrrr>�s$zFTP.sanitizecCs`d|vsd|vrtd��t�d||�|t}|jdkrHtd|�|��|j�|�	|j
��dS)N�
�
z4an illegal newline character should not be containedzftplib.sendcmdr	z*put*)r1r2r3�CRLFr<r=r>r&�sendall�encoder�r�linerrr�putline�s
zFTP.putlinecCs$|jrtd|�|��|�|�dS)Nz*cmd*)r<r=r>rTrRrrr�putcmd�sz
FTP.putcmdcCs�|j�|jd�}t|�|jkr.td|j��|jdkrHtd|�|��|sPt�|dd�t	krn|dd�}n|dd�t	vr�|dd�}|S)Nr	�got more than %d bytesz*get*������)
r9�readline�maxlinerHrr<r=r>r)rOrRrrr�getline�s
zFTP.getlinecCs`|��}|dd�dkr\|dd�}|��}|d|}|dd�|kr$|dd�dkr$q\q$|S)N���-rN)r[)rrS�codeZnextlinerrr�getmultiline�s�zFTP.getmultilinecCsp|��}|jrtd|�|��|dd�|_|dd�}|dvrD|S|dkrTt|��|dkrdt|��t|��dS)Nz*resp*r\r	>�3�2�1�4�5)r`r<r=r>Zlastresprrr)r�resp�crrrr:�szFTP.getrespcCs$|��}|dd�dkr t|��|S)Nr	rb)r:r�rrfrrr�voidrespszFTP.voidrespcCsTdt}|jdkr"td|�|��|j�|t�|��}|dd�dvrPt|��|S)N�ABORr	z*put urgent*r\�Z225Z426Z226)	�B_CRLFr<r=r>r&rP�MSG_OOBr`r�rrSrfrrr�aborts
z	FTP.abortcCs|�|�|��Sr)rUr:�r�cmdrrr�sendcmds
zFTP.sendcmdcCs|�|�|��Sr)rUrirprrr�voidcmds
zFTP.voidcmdcCsB|�d�}t|d�t|d�g}||}dd�|�}|�|�S)N�.�zPORT �,)�splitrJ�joinrs)rrr0ZhbytesZpbytes�bytesrqrrr�sendport s

zFTP.sendportcCsbd}|jtjkrd}|jtjkr$d}|dkr4td��dt|�|t|�dg}dd�|�}|�|�S)Nrr	�zunsupported address familyrzEPRT �|)r7r4�AF_INETZAF_INET6rrJrxrs)rrr0r7�fieldsrqrrr�sendeprt*szFTP.sendeprtcCsltjd|jdd�}|��d}|j��d}|jtjkrF|�||�}n|�||�}|jt	urh|�
|j�|S)N)rrr	)r6Zbacklogr)r4Z
create_serverr7Zgetsocknamer&r}rzrrr�
settimeout)rr&r0rrfrrr�makeport7s
zFTP.makeportcCs\|jtjkr:t|�d��\}}|jr*|}qT|j��d}nt|�d�|j���\}}||fS)N�PASVrZEPSV)	r7r4r}�parse227rr�trust_server_pasv_ipv4_addressr&Zgetpeername�parse229)rZuntrusted_hostr0rrrr�makepasvDszFTP.makepasvc
CsLd}|jr�|��\}}tj||f|j|jd�}zL|durF|�d|�|�|�}|ddkrd|��}|ddkrxt|��Wn|�	��Yn0n�|�
��|}|dur�|�d|�|�|�}|ddkr�|��}|ddkr�t|��|��\}}	|jtu�r
|�
|j�Wd�n1�s 0Y|dd�dk�rDt|�}||fS)Nr.zREST %srrbrcr\�150)rBr�r4r5rrrrr:rr*r�Zacceptrr��parse150)
rrq�rest�sizerr0�connrfr&Zsockaddrrrr�ntransfercmdPs>�



,zFTP.ntransfercmdcCs|�||�dS)Nr)r�)rrqr�rrr�transfercmd�szFTP.transfercmdcCs�|sd}|sd}|sd}|dkr0|dvr0|d}|�d|�}|ddkrX|�d|�}|ddkrr|�d	|�}|dd
kr�t|��|S)NZ	anonymousr>rr^z
anonymous@zUSER rrarF�ACCT rb�rrr)rr r!r"rfrrrr�s z	FTP.loginrcCsr|�d�|�||��D}|�|�}|s(q2||�qtdurLt|t�rL|��Wd�n1s`0Y|��S�NzTYPE I)rsr�Zrecv�
_SSLSocket�
isinstance�unwrapri)rrq�callback�	blocksizer�r��datarrr�
retrbinary�s


&zFTP.retrbinaryc	Cs"|durt}|�d�}|�|���}|jd|jd���}|�|jd�}t|�|jkr`td|j��|j	dkrxt
dt|��|s~q�|dd�tkr�|dd�}n|d	d�d
kr�|dd	�}||�q4t
dur�t|t
�r�|��Wd�n1s�0YWd�n1�s0Y|��S)N�TYPE Ar/rr	rVr{z*retr*rWrXrN)�
print_linerrr�r8rrYrZrHrr<r=rJrOr�r�r�ri)rrqr�rfr��fprSrrr�	retrlines�s,
�

Fz
FTP.retrlinescCs�|�d�|�||��R}|�|�}|s(q@|�|�|r||�qtdurZt|t�rZ|��Wd�n1sn0Y|��Sr�)rsr��readrPr�r�r�ri)rrqr�r�r�r�r��bufrrr�
storbinary�s



&zFTP.storbinarycCs�|�d�|�|���}|�|jd�}t|�|jkrBtd|j��|sHq�|dd�tkrx|dtvrp|dd�}|t}|�|�|r||�qtdur�t	|t�r�|�
�Wd�n1s�0Y|��S)Nr�r	rVrWrX)rsr�rYrZrHrrlrPr�r�r�ri)rrqr�r�r�r�rrr�	storlines�s 


&z
FTP.storlinescCsd|}|�|�S)Nr��rs)rZpasswordrqrrrr"szFTP.acctcGs0d}|D]}|d|}qg}|�||j�|S)NZNLST� )r��append)rr+rq�arg�filesrrr�nlst#szFTP.nlstcGshd}d}|dd�r>t|d�td�kr>|dd�|d}}|D]}|rB|d|}qB|�||�dS)NZLISTrXrr�)�typer�)rr+rq�funcr�rrr�dir,s zFTP.dirc
cs�|r|�dd�|�d�|r*d|}nd}g}|�||j�|D]\}|�t��d�\}}}i}	|dd��d�D] }
|
�d�\}}}||	|��<qt||	fVqDdS)Nz
OPTS MLST �;zMLSD %sZMLSDr�rX�=)	rrrxr�r�rIrO�	partitionrw�lower)
r�pathZfactsrq�linesrSZfacts_found�_�name�entryZfact�key�valuerrr�mlsd;s
zFTP.mlsdcCs0|�d|�}|ddkr"t|��|�d|�S)NzRNFR rrazRNTO )rrrrs)rZfromnameZtonamerfrrr�renameWsz
FTP.renamecCs.|�d|�}|dd�dvr"|St|��dS)NzDELE r\>Z250Z200r�)r�filenamerfrrr�delete^sz
FTP.deletec
Csr|dkrTz|�d�WStyP}z$|jddd�dkr<�WYd}~q`d}~00n|dkr`d}d|}|�|�S)	Nz..ZCDUPrr\�500rrtzCWD )rsrr+)r�dirname�msgrqrrr�cwdfszFTP.cwdcCs:|�d|�}|dd�dkr6|dd���}t|�SdS)NzSIZE r\Z213)rr�strip�int)rr�rfrKrrrr�sszFTP.sizecCs$|�d|�}|�d�sdSt|�S)NzMKD �257r�rs�
startswith�parse257)rr�rfrrr�mkd{s
zFTP.mkdcCs|�d|�S)NzRMD r�)rr�rrr�rmd�szFTP.rmdcCs |�d�}|�d�sdSt|�S)NZPWDr�rr�rhrrr�pwd�s

zFTP.pwdcCs|�d�}|��|S)NZQUIT)rsr*rhrrrr'�s
zFTP.quitcCs`z<|j}d|_|dur|��W|j}d|_|dur\|��n|j}d|_|durZ|��0dSr)r9r*r&)rr9r&rrrr*�s

�z	FTP.close)rrr-N)N)N)rrr)rN)N)rNN)N)9rrrr<r�FTP_PORTr0�MAXLINErZr&r9r;rBr�rr#r%r,rr?rA�debugrDr>rTrUr[r`r:rirorrrsrzrr�r�r�r�rr�r�r�r�r"r�r�r�r�r�r�r�r�r�r�r'r*rrrrrJsn��






7



#

	
		rc	s�eZdZejZdddddddedf	dd��fdd�Zd�fdd	�	Zd
d�Z	dd
�Z
dd�Zdd�Zd�fdd�	Z
dd�Z�ZS)�FTP_TLSrNrrc
	s�|dur|durtd��|dur0|dur0td��|dus@|durVddl}|�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)
r1�warnings�warn�DeprecationWarningr�r��sslZ_create_stdlib_context�ssl_version�context�_prot_p�superr#)rrr r!r"r�r�r�rrrr���	__class__rrr#�s*���zFTP_TLS.__init__Tcs*|rt|jtj�s|��t��|||�Sr)r�r&r��	SSLSocket�authr�r)rr r!r"Zsecurer�rrr�sz
FTP_TLS.logincCsft|jtj�rtd��|jtjkr.|�d�}n
|�d�}|jj	|j|j
d�|_|jjd|jd�|_
|S)NzAlready using TLSzAUTH TLSzAUTH SSL�Zserver_hostnamer/)�moder)r�r&r�r�r1r�ZPROTOCOL_TLSrsr��wrap_socketrr8rr9rhrrrr��s
zFTP_TLS.authcCs0t|jtj�std��|�d�}|j��|_|S)Nz
not using TLSZCCC)r�r&r�r�r1rsr�rhrrr�ccc�s

zFTP_TLS.ccccCs|�d�|�d�}d|_|S)NzPBSZ 0zPROT PT�rsr�rhrrr�prot_ps

zFTP_TLS.prot_pcCs|�d�}d|_|S)NzPROT CFr�rhrrr�prot_cs
zFTP_TLS.prot_ccs2t��||�\}}|jr*|jj||jd�}||fS)Nr�)r�r�r�r�r�r)rrqr�r�r�r�rrr�s�zFTP_TLS.ntransfercmdcCs8dt}|j�|�|��}|dd�dvr4t|��|S)Nrjr\rk)rlr&rPr`rrnrrrrosz
FTP_TLS.abort)rrrT)N)rrrr�ZPROTOCOL_TLS_CLIENTr�rr#rr�r�r�r�r�ro�
__classcell__rrr�rr��s!��r�cCs\|dd�dkrt|��tdur<ddl}|�d|j|jB�at�|�}|sNdSt|�d��S)Nr\r�rz150 .* \((\d+) bytes\)r	)	r�_150_re�re�compile�
IGNORECASE�ASCII�matchr��group)rfr��mrrrr�.s�
r�cCs�|dd�dkrt|��tdur6ddl}|�d|j�at�|�}|sLt|��|��}d�|dd��}t	|d�d>t	|d�}||fS)	Nr\Z227rz#(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)rtr]�rE)
r�_227_rer�r�r��searchr�groupsrxr�)rfr�r�Znumbersrr0rrrr�Bs
r�cCs�|dd�dkrt|��|�d�}|dkr2t|��|�d|d�}|dkrRt|��||d||dkrrt|��||d|��||d�}t|�dkr�t|��|d}t|d�}||fS)Nr\Z229�(r�)r	rE)r�findrrwrHr�)rfZpeer�left�right�partsrr0rrrr�Us
r�cCs�|dd�dkrt|��|dd�dkr,dSd}d}t|�}||kr�||}|d}|dkrz||ks�||dkrrq�|d}||}q<|S)Nr\r�rEz "rr	�")rrH)rfr�rL�nrgrrrr�js 
r�cCst|�dSr)r=)rSrrrr��sr�r�Ic	Cs�|s|}d|}|�|�|�|�t|�d��\}}|�||�|�d|�}|dd�dvrdt�|�d|�}|dd�dvr�t�|��|��dS)NzTYPE r�zSTOR r\>Z125r��RETR )rsr�rrrzrri)	�sourceZ
sourcename�targetZ
targetnamer�Z
sourcehostZ
sourceportZtreplyZsreplyrrr�ftpcp�s

r�cCs�ttj�dkr"ttj�t�d�ddl}d}d}tjddkrR|d}tjd=q2tjddd�dkr�tjddd�}tjd=tjd}t|�}|�	|�d}}}z|�|�}Wn&t
y�|dur�tj�d�Yn80z|�
|�\}}}Wn t�ytj�d�Yn0|�|||�tjdd�D]�}	|	dd�d	k�r\|�|	dd��nt|	dd�dk�r�d
}
|	dd��r�|
d|	dd�}
|�|
�}n0|	dk�r�|�|j�n|�d
|	tjjd��q2|��dS)Nr{rr	z-dz-rrz5Could not open account file -- using anonymous login.z$No account -- using anonymous login.z-lZCWDr�z-pr�i)rHr2�argvr=�test�__doc__�exit�netrcrrAr(�stderr�writeZauthenticators�KeyErrorrr�rrrDrBr��stdoutr')r�r<ZrcfilerZftpZuseridr!r"Znetrcobjr9rqrfrrrr��sR	




�
"

�r��__main__)rr�)$r2r4r�__all__rmr�r��	Exceptionrrrrrr(r)rrOrlrr��ImportErrorr�r�r�r�ZSSLErrorr�r�r�r�r�r�r�r�r�rrrrr�<module>'sL
^
}

9


?>