Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
ftplib.cpython-314.pyc314 linesDownload Raw Back to __pycache__
1+
2��i�����Rt^RIt^RIt^RIHt.ROt^t^tRt!R	R3]4t	!RR]	4t4!RR]	4t!R
R]	4t!RR]	4t
]	]]3tRtRt!RR4t^RIt]P*t!RR]4t]P1R4]	]]]P23tRsRtRsRtRtRt Rt!RRlt"Rt#]$R8Xd5]#!4R#R# ]dRtL8i;i)aSAn FTP client class and some helper functions.6 7Based on RFC 959: File Transfer Protocol (FTP), by J. Postel and J. Reynolds8 9Example:10 11>>> from ftplib import FTP12>>> ftp = FTP('ftp.python.org') # connect to host, default port13>>> ftp.login() # default, i.e.: user anonymous, passwd anonymous@14'230 Guest login ok, access restrictions apply.'15>>> ftp.retrlines('LIST') # list directory contents16total 917drwxr-xr-x   8 root     wheel        1024 Jan  3  1994 .18drwxr-xr-x   8 root     wheel        1024 Jan  3  1994 ..19drwxr-xr-x   2 root     wheel        1024 Jan  3  1994 bin20drwxr-xr-x   2 root     wheel        1024 Jan  3  1994 etc21d-wxrwxr-x   2 ftp      wheel        1024 Sep  5 13:43 incoming22drwxr-xr-x   2 root     wheel        1024 Nov 17  1993 lib23drwxr-xr-x   6 1094     wheel        1024 Sep 13 19:07 pub24drwxr-xr-x   3 root     wheel        1024 Jan  3  1994 usr25-rw-r--r--   1 root     root          312 Aug  1  1994 welcome.msg26'226 Transfer complete.'27>>> ftp.quit()28'221 Goodbye.'29>>>30 31A nice test that reveals some of the network dialogue would be:32python ftplib.py -d localhost -l -p -l33N)�_GLOBAL_DEFAULT_TIMEOUT�FTP�error_reply�34error_temp�35error_perm�error_proto� c��]tRt^9tRtR#)�Error�N��__name__�36__module__�__qualname__�__firstlineno__�__static_attributes__r��
Lib\ftplib.pyr37r389s��rr39c��]tRt^:tRtR#)rrNrrrrrr:���$rc��]tRt^;tRtR#)rrNrrrrrr;���rc��]tRt^<tRtR#)rrNrrrrrr<rrc��]tRt^=tRtR#)rrNrrrrrr=rr�
40s
41c�a�]tRt^JtoRt^tRt]t]	t42RtRtRt
RtRtRRRR]R3RR/RlltR	tR43tR2RltRtR
t]tRtRtRtRtRtRtRtRtRt Rt!Rt"Rt#Rt$Rt%Rt&R3Rlt'R3Rlt(R4Rlt)R5R lt*R3R!lt+R6R"lt,R3R#lt-R$t.R%t/R&t0R.3R'lt1R(t2R)t3R*t4R+t5R,t6R-t7R.t8R/t9R0t:R1t;Vt<R#)7ru�An FTP client class.44 45To create a connection, call the class using these arguments:46        host, user, passwd, acct, timeout, source_address, encoding47 48The first four arguments are all strings, and have default value ''.49The parameter ´timeout´ must be numeric and defaults to None if not50passed, meaning that no timeout will be set on any ftp socket(s).51If a timeout is passed, then this is now the default timeout for all ftp52socket operations for this instance.53The last parameter is the encoding of filenames, which defaults to utf-8.54 55Then use self.connect() with optional host and port argument.56 57To download a file, use ftp.retrlines('RETR ' + filename),58or ftp.retrbinary() with slightly different arguments.59To upload a file, use ftp.storlines() or ftp.storbinary(),60which have an open file as argument (see their definitions61below for details).62The download/upload functions first issue appropriate TYPE63and PORT or PASV commands.64�NTF�encoding�utf-8c��WpnW`nWPnV'd0VPV4V'dVP	W#V4R#R#R#)z�Initialization method (called by class instantiation).65Initialize host to localhost, port to standard ftp port.66Optional arguments are host (for connect()),67and user, passwd, acct (for login()).68N)r�source_address�timeout�connect�login)�self�host�user�passwd�acctr!r rs&&&&&&&$r�__init__�FTP.__init__ms>��!�
�,������L�L�����69�70�4��.��rc��V#�Nr�r$s&r�	__enter__�
FTP.__enter__}s���rc���VPe4VP4VPeVP	4R#R#R# \\3dL7i;i TPeTP	4ii;ir,)�sock�quit�OSError�EOFError�close)r$�argss&*r�__exit__�FTP.__exit__�sm���9�9� �
!��	�	���9�9�(��J�J�L�)�
!���X�&�
��
���9�9�(��J�J�L�)�s#�A�A�A�A�A�!A<c�r�VR8wdWnV^8�dW nVR8wdW0nVPeVP'g\R4hVeW@n\71P!RWPVP4\P!VPVP3VPVPR7Vn	VPPVnVPPRVPR7VnVP4VnVP #)aBConnect to host.  Arguments are:72- host: hostname to connect to (string, default previous host)73- port: port to connect to (integer, default previous port)74- timeout: the timeout to set against the ftp socket(s)75- source_address: a 2-tuple (host, port) for the socket to bind76  to as its source address before connecting.77rz0Non-blocking socket (timeout=0) is not supportedzftplib.connect�r �r�r����)r%�portr!�78ValueErrorr �sys�audit�socket�create_connectionr1�family�af�makefiler�file�getresp�welcome)r$r%r>r!r s&&&&&rr"�FTP.connect�s����2�:��I��!�8��I��d�?�"�L��<�<�#�D�L�L�L��O�P�P��%�"0���	�	�"�D�)�)�T�Y�Y�?��,�,�d�i�i����-C�T�\�\�<@�<O�<O�Q��	��)�)�"�"����I�I�&�&�s�T�]�]�&�C��	��|�|�~����|�|�rc��VP'd&\RVPVP44VP#)zXGet the welcome message from the server.79(this is read and squirreled away by connect())z	*welcome*)�	debugging�print�sanitizerIr-s&r�80getwelcome�FTP.getwelcome�s.���>�>�>��+�t�}�}�T�\�\�:�;��|�|�rc��WnR#)z�Set the debugging level.81The required argument level means:820: no debugging output (default)831: print commands and responses but not body text etc.842: also print raw lines read and sent before stripping CR/LFN)rL)r$�levels&&r�set_debuglevel�FTP.set_debuglevel�s	���rc��WnR#)z�Use passive or active mode for data transfers.85With a false argument, use the normal PORT mode,86With a true argument, use the PASV command.N)�
passiveserver)r$�vals&&r�set_pasv�FTP.set_pasv�s87��!�rc��VR,R9dB\VPR44pVR,RV^,88,,WR,p\V4#):N�Nr�*N>�PASS �pass )�len�rstrip�repr)r$�s�is&& rrN�FTP.sanitize�sJ���R�5�&�&��A�H�H�V�$�%�A��"���Q�q�S�	�!�A�b�E�)�A��A�w�rc�@�RV9gRV9d\R4h\P!RW4V\,pVP^8�d\RVP
V44VPPVPVP44R#)�
�89z4an illegal newline character should not be containedzftplib.sendcmdz*put*N)r?r@rA�CRLFrLrMrNr1�sendall�encoder�r$�lines&&r�putline�FTP.putline�sq���4�<�4�4�<��S�T�T��	�	�"�D�/��d�{���>�>�A���'�4�=�=��.�/��	�	���$�+�+�d�m�m�4�5rc��VP'd\RVPV44VPV4R#)z*cmd*N)rLrMrNrmrks&&r�putcmd�90FTP.putcmd�s)���>�>�>�5��$�-�-��*=�>����T�rc��VPPVP^,4p\V4VP8�d\	RVP,4hVP91^8�d\
RVPV44V'g\hVRR\8XdVRRpV#VRR\9dVRRpV#)��got more than %d bytesz*get*N����������)92rG�readline�maxliner_r93rLrMrNr4rhrks& r�getline�FTP.getline�s����y�y�!�!�$�,�,��"2�3���t�9�t�|�|�#��0�4�<�<�?�@�@��>�>�A���'�4�=�=��.�/���N����9������9�D����"�#�Y�$�
����9�D��rc���VP4pVR,R8XdNVR,pVP4pVRV,,pVR,V8XgK1VR,R8wgKAV#V#):��N�-�Nr|Nrg)ry)r$rl�code�nextlines&   r�getmultiline�FTP.getmultiline�sb���|�|�~����9�����8�D���<�<�>���t�h��/���B�<�4�'� ��
��,����t�rc��VP4pVP'd\RVPV44VR,VnVR,pVR9dV#VR8Xd\V4hVR8Xd\
V4h\V4h)z*resp*r�NrsN�4�5>�1�2�3)r�rLrMrN�lastresprrr)r$�resp�cs&  rrH�FTP.getresp�s|��� � �"���>�>�>��(�D�M�M�$�/�0��R���
���H������K���8��T�"�"���8��T�"�"��$��rc�X�VP4pVR,R8wd\V4hV#)z%Expect a response beginning with '2'.r�r�)rHr�r$r�s& r�voidresp�FTP.voidresps(���|�|�~����8�s�?��d�#�#��rc�94�R\,pVP^8�d\RVPV44VPPV\4VP4pVR,R9d\V4hV#)z�Abort a file transfer.  Uses out-of-band data.95This does not follow the procedure from the RFC to send Telnet96IP and Synch; that doesn't seem to work with the servers I've97tried.  Instead, just send the ABOR command as OOB data.�ABORz*put urgent*r��225�226�426)	�B_CRLFrLrMrNr1ri�MSG_OOBr�r�r$rlr�s&  r�abort�	FTP.abortsl��98�����>�>�A���.�$�-�-��"5�6��	�	���$��(�� � �"����8�0�0��d�#�#��rc�D�VPV4VP4#)z'Send a command and return the response.)rprH�r$�cmds&&r�sendcmd�FTP.sendcmds�����C���|�|�~�rc�D�VPV4VP4#)z8Send a command and expect a response beginning with '2'.)rpr�r�s&&r�voidcmd�FTP.voidcmds�����C���}�}��rc���VPR4p\VR,4\VR,4.pW4,pRRPV4,pVPV4#)zESend a PORT command with the current host and the given99port number.100�.�zPORT �,)�splitra�joinr�)r$r%r>�hbytes�pbytes�bytesr�s&&&    r�sendport�FTP.sendport sS�����C����t�S�y�/�4��S��>�2�����������'���|�|�C� � rc�2�^pVP\P8Xd^pVP\P8Xd^pV^8Xd\	R4hR\V4V\V4R.pRRP
V4,pVPV4#)zESend an EPRT command with the current host and the given port number.zunsupported address familyrzEPRT �|)rErB�AF_INET�AF_INET6rrar�r�)r$r%r>rE�fieldsr�s&&&   r�sendeprt�FTP.sendeprt*s~��
���7�7�f�n�n�$��B��7�7�f�o�o�%��B�
��7��:�;�;��d�2�h��d�4�j�"�5�������(�(���|�|�C� � rc��\P!RVP^R7pVP4^,pVPP4^,pVP\P1018XdVP
W24pMVPW24pVP\JdVPVP4V#)z3Create a new socket and send a PORT command for it.)rD�backlog)r�)rB�
create_serverrE�getsocknamer1r�r�r�r!r�102settimeout)r$r1r>r%r�s&    r�makeport�FTP.makeport7s����#�#�G�D�G�G�Q�G�����!�!�$���y�y�$�$�&�q�)���7�7�f�n�n�$��=�=��,�D��=�=��,�D��<�<�6�6��O�O�D�L�L�)��rc�`�VP\P8XdY\VP	R44wrVP103'dTpW23#VPP4^,pW23#\VP	R4VPP44wr2W23#)z<Internal: Does the PASV or EPSV handshake -> (address, port)�PASV�EPSV)	rErBr��parse227r��trust_server_pasv_ipv4_addressr1�getpeername�parse229)r$�untrusted_hostr>r%s&   r�makepasv�FTP.makepasvDs����7�7�f�n�n�$�#+�D�L�L��,@�#A� �N��2�2�2�%��104�z���y�y�,�,�.�q�1���z��"�$�,�,�v�"6��	�	�8M�8M�8O�P�J�D��z�rc��RpVP'd�VP4wrE\P!WE3VPVP105R7pVeVP
RV,4VP
V4pV^,R8XdVP4pV^,R8wd\V4hM�VP4;_uu_4pVeVP
RV,4VP
V4pV^,R8XdVP4pV^,R8wd\V4hVP4wriVP\JdVPVP4RRR4XR,R8Xd\V4pXV3# TP4h;i +'giLC;i)aNInitiate a transfer over the data connection.106 107If the transfer is active, send a port command and the108transfer command, and accept the connection.  If the server is109passive, send a pasv command, connect to it, and start the110transfer command.  Either way, return the socket for the111connection and the expected size of the transfer.  The112expected size may be None if it could not be determined.113 114Optional 'rest' argument can be a string that is sent as the115argument to a REST command.  This is essentially a server116marker used to tell the server to skip over any data up to the117given marker.118Nr:zREST %sr�r�r�150)rVr�rBrCr!r r�rHrr5r��acceptrr��parse150)119r$r��rest�sizer%r>�connr�r1�sockaddrs120&&&       r�ntransfercmd�FTP.ntransfercmdPsl������������J�D��+�+�T�L�$�,�,�;?�;N�;N�P�D�
��#��L�L��T�!1�2��|�|�C�(����7�c�>��<�<�>�D���7�c�>�%�d�+�+�"������D��#��L�L��T�!1�2��|�|�C�(����7�c�>��<�<�>�D���7�c�>�%�d�+�+�!%�������<�<�'>�>��O�O�D�L�L�1�!���8�u���D�>�D��T�z���'
��121�122���� ��s�A$F�B&F4�F1�4G	c�2�VPW4^,#)z0Like ntransfercmd() but returns only the socket.)r�)r$r�r�s&&&r�transfercmd�FTP.transfercmd�s��� � ��+�A�.�.rc�j�V'gRpV'gRpV'gRpVR8XdVR	9d123VR,pVPRV,4pV^,R8XdVPRV,4pV^,R8XdVPRV,4pV^,R8wd\V4hV#)124zLogin, default anonymous.�	anonymousrz125anonymous@zUSER r�r]�ACCT r�>rr~�r�r)r$r&r'r(r�s&&&& rr#�	FTP.login�s�����D���F���D��;��6�Y�#6��l�*�F��|�|�G�d�N�+����7�c�>��<�<��&� 0�1�D���7�c�>��<�<��$��/�D���7�c�>��d�#�#��rc�n�VPR4VPW4;_uu_4pVPV4;p'dV!V4K#\e'\	V\4'dVP4RRR4VP
4# +'giTP
4#;i)avRetrieve data in binary mode.  A new port is created for you.126 127Args:128  cmd: A RETR command.129  callback: A single parameter callable to be called on each130            block of data read.131  blocksize: The maximum number of bytes to read from the132             socket at one time.  [default: 8192]133  rest: Passed to transfercmd().  [default: None]134 135Returns:136  The response code.137�TYPE IN)r�r��recv�138_SSLSocket�139isinstance�unwrapr�)r$r��callback�	blocksizer�r��datas&&&&&  r�140retrbinary�FTP.retrbinary�s���	
���X��
�
�
�c�
(�
(�D��)�)�I�.�.�$�.�����%�*�T�:�*F�*F����
�)��}�}���
)�
(��}�}���s�B�8B�B4	c141�(�Vf\pVPR4pVPV4;_uu_4pVPRVPR7;_uu_4pVPVP^,4p\V4VP8�d\RVP,4hVP^8�d\R\V44V'gM-VRR\8XdVRRpMVR	RR8XdVRR	pV!V4K�\e'\V\4'dVP4RRR4RRR4VP!4# +'giL(;i +'giTP!4#;i)142a(Retrieve data in line mode.  A new port is created for you.143 144Args:145  cmd: A RETR, LIST, or NLST command.146  callback: An optional single parameter callable that is called147            for each line with the trailing CRLF stripped.148            [default: print_line()]149 150Returns:151  The response code.152N�TYPE Ar;r<rtz*retr*rgrurv)�153print_liner�r�rFrrwrxr_r154rLrMrarhr�r�r�r�)r$r�r�r�r��fprls&&&    r�	retrlines�
FTP.retrlines�s4����!�H��|�|�H�%��
�
�
�c�
"�
"�d����s�T�]�]��;�;�r���{�{�4�<�<�!�#3�4���t�9�t�|�|�+�� 8�4�<�<� G�H�H��>�>�A�%��(�D��J�/������9��$����9�D��"�#�Y�$�&����9�D�����%�*�T�:�*F�*F����
�!<�#�$�}�}���#<�;��#�
"�$�}�}���s+�&E2�BE	�#AE	�?E2�E/
�*E2�2F	c��VPR4VPW4;_uu_4pVPV4;p'd&VPV4V'gK4V!V4K>\e'\V\4'dVP
4RRR4VP4# +'giTP4#;i)a�Store a file in binary mode.  A new port is created for you.155 156Args:157  cmd: A STOR command.158  fp: A file-like object with a read(num_bytes) method.159  blocksize: The maximum data size to read from fp and send over160             the connection at once.  [default: 8192]161  callback: An optional single parameter callable that is called on162            each block of data after it is sent.  [default: None]163  rest: Passed to transfercmd().  [default: None]164 165Returns:166  The response code.167r�N)r�r��readrir�r�r�r�)r$r�r�r�r�r�r��bufs&&&&&&  r�168storbinary�FTP.storbinary�s���	
���X��
�
�
�c�
(�
(�D�����+�+�#�+����S�!��8��S�M��%�*�T�:�*F�*F����
�)��}�}���)�
(��}�}���s�B0�B0� 8B0�0C	c��VPR4VPV4;_uu_4pVPVP^,4p\	V4VP8�d\RVP,4hV'gMWVRR\8wd%VR,\9dVRRpV\,pVPV4V'gK�V!V4K�\e'\V\4'dVP4RRR4VP4# +'giTP4#;i)a(Store a file in line mode.  A new port is created for you.169 170Args:171  cmd: A STOR command.172  fp: A file-like object with a readline() method.173  callback: An optional single parameter callable that is called on174            each line after it is sent.  [default: None]175 176Returns:177  The response code.178r�rtNrurv)r�r�rwrxr_r179r�rir�r�r�r�)r$r�r�r�r�r�s&&&&  r�	storlines�
FTP.storlines�s���	
���X��
�
�
�c�
"�
"�d���k�k�$�,�,��"2�3���s�8�d�l�l�*�� 8�4�<�<� G�H�H����r�s�8�v�%��2�w�&�(��C�R��#���,�C����S�!��8��S�M��%�*�T�:�*F�*F����
�#� �}�}���!#�
"� �}�}���s�A!D+�
A	D+�8D+�+E180	c�6�RV,pVPV4#)zSend new account name.r��r�)r$�passwordr�s&& rr(�FTP.accts���� ���|�|�C� � rc�v�RpVFpVRV,,pK	.pVPW$P4V#)zBReturn a list of files in a given directory (default the current).�NLST� )r��append)r$r6r��arg�filess&*   r�nlst�FTP.nlsts9�����C���s��#�C�������s�L�L�)��rc���RpRpVRR'd+\VR,\4'gVRRVR,r1VFpV'gK
VRV,,pK	VPW#4R#)z�List a directory in long form.181By default list current directory to stdout.182Optional last argument is callback function; all183non-empty arguments before it are concatenated to the184LIST command.  (This *should* only be used for a pathname.)�LISTNr�rv)r��strr�)r$r6r��funcr�s&*   r�dir�FTP.dir&sc���������9�Z��R��#�6�6��c�r��D��H�$��C��s��S�3�Y�'���	
���s�!rc#��"�V'd/VPRRPV4,R,4V'dRV,pMRp.pVPW4P4VFrpVP	\1854P
R4wrgp/p	VRRPR4F)p186V187P
R4wr�pW�VP4&K+	W�3x�Kt	R#5i)	a�List a directory in a standardized format by using MLSD188command (RFC-3659). If path is omitted the current directory189is assumed. "facts" is a list of strings representing the type190of information desired (e.g. ["type", "size", "perm"]).191 192Return a generator object yielding a tuple of two elements193for every file found in path.194First element is the file name, the second one is a dictionary195including a variable number of "facts" depending on the server196and whether "facts" argument has been provided.197z198OPTS MLST �;zMLSD %s�MLSDr�N�=rv)	r�r�r�r�r`rh�	partitionr��lower)
r$�path�factsr��linesrl�facts_found�_�name�entry�fact�key�values
&&&          r�mlsd�FTP.mlsd5s������L�L�������7�#�=�>���d�"�C��C������s�L�L�)��D�#'�;�;�t�#4�#>�#>�s�#C� �K�D��E�#�C�R�(�.�.�s�3�� $���s� 3�
���%*�c�i�i�k�"�4��-��
�s�>C$�B#C$c��VPRV,4pV^,R8wd\V4hVPRV,4#)zRename a file.zRNFR r�zRNTO )r�rr�)r$�fromname�tonamer�s&&& r�rename�199FTP.renameQs?���|�|�G�h�.�/����7�c�>��d�#�#��|�|�G�f�,�-�-rc�h�VPRV,4pVR,R9dV#\V4h)zDelete a file.zDELE r>�200�250r�)r$�filenamer�s&& r�delete�200FTP.deleteXs1���|�|�G�h�.�/����8�~�%��K��d�#�#rc���VR8XdVPR4#VR8XdRpRV,pVPV4# \d+pTP^,R,R8wdhRp?LJRp?ii;i)	zChange to a directory.z..�CDUPr�500Nrr�zCWD )r�rr6)r$�dirname�msgr�s&&  r�cwd�FTP.cwd`sr���d�?�
��|�|�F�+�+���]��G��w����|�|�C� � ��
�
��8�8�A�;�r�?�e�+��,��
�s�=�A2� A-�-A2c��VPRV,4pVR,R8Xd#VR,P4p\V4#R#)zRetrieve the size of a file.zSIZE r�213:r|NNN)r��strip�int)r$r!r�rbs&&  rr��FTP.sizemsA���|�|�G�h�.�/����8�u���R���� �A��q�6�M�rc�z�VPRV,4pVPR4'gR#\V4#)z+Make a directory, return its full pathname.zMKD �257r�r��201startswith�parse257)r$r'r�s&& r�mkd�FTP.mkdus3���|�|�F�W�,�-�����u�%�%����~�rc�2�VPRV,4#)zRemove a directory.zRMD r�)r$r's&&r�rmd�FTP.rmd~s���|�|�F�W�,�-�-rc�l�VPR4pVPR4'gR#\V4#)z!Return current working directory.�PWDr1rr2r�s& r�pwd�FTP.pwd�s.���|�|�E�"�����u�%�%����~�rc�H�VPR4pVP4V#)zQuit, and close the connection.�QUIT)r�r5r�s& rr2�FTP.quit�s���|�|�F�#���202�203���rc��VPpRVnVeVP4VPpRVnVeVP4R#R# TPpRTnTeTP4ii;i)z8Close the connection without assuming anything about it.N)rGr5r1)r$rGr1s&  rr5�	FTP.close�sr��		��9�9�D��D�I����204�205���9�9�D��D�I����206�207�� ���9�9�D��D�I����208�209�� �s�'A�*A>)rErLrrGr%r�rVr>r1r r!rI)rr�r=Nr,)rrr)rN)rNN)=r
rrr�__doc__rLr%�FTP_PORTr>�MAXLINErxr1rGrIrVr�rr)r.r7r"rOrS�debugrXrNrmrpryr�rHr�r�r�r�r�r�r�r�r�r�r#r�r�r�r�r(r�rrrr"r)r�r5r8r<r2r5r�__classdictcell__)�
__classdict__s@rrrJs2�����.�I�
�D��D��G��D��D��G��M�%*�"��R���0��/�!�/� �!��4��
�E�!��6���$210� ����211�212!�!��213�5�n/��4�.!�F�4�>!�214�
"��"� �8.�$�!���.����rc	�aa�]tRtRtoRtRRRR]RRRR/V3R	llltRV3R215lltRtRt	R
t216RtRV3RlltRt
RtVtV;t#)�FTP_TLSi�a�A FTP subclass which adds TLS support to FTP as described217in RFC-4217.218 219Connect as usual to port 21 implicitly securing the FTP control220connection before authenticating.221 222Securing the data connection requires user to explicitly ask223for it by calling prot_p() method.224 225Usage example:226>>> from ftplib import FTP_TLS227>>> ftps = FTP_TLS('ftp.python.org')228>>> ftps.login()  # login anonymously previously securing control channel229'230 Guest login ok, access restrictions apply.'230>>> ftps.prot_p()  # switch to secure data connection231'200 Protection level set to P'232>>> ftps.retrlines('LIST')  # list directory content securely233total 9234drwxr-xr-x   8 root     wheel        1024 Jan  3  1994 .235drwxr-xr-x   8 root     wheel        1024 Jan  3  1994 ..236drwxr-xr-x   2 root     wheel        1024 Jan  3  1994 bin237drwxr-xr-x   2 root     wheel        1024 Jan  3  1994 etc238d-wxrwxr-x   2 ftp      wheel        1024 Sep  5 13:43 incoming239drwxr-xr-x   2 root     wheel        1024 Nov 17  1993 lib240drwxr-xr-x   6 1094     wheel        1024 Sep 13 19:07 pub241drwxr-xr-x   3 root     wheel        1024 Jan  3  1994 usr242-rw-r--r--   1 root     root          312 Aug  1  1994 welcome.msg243'226 Transfer complete.'244>>> ftps.quit()245'221 Goodbye.'246>>>247�contextNr!r rrc248�z<�Vf\P!4pWPnRVn\S	V`WW4WgVR7R#)NFr<)�ssl�_create_stdlib_contextrK�_prot_p�superr))249r$r%r&r'r(rKr!r r�	__class__s250&&&&&$$$$�rr)�FTP_TLS.__init__�s@������4�4�6��"�L� �D�L��G��T��$�x�
�
Irc�<�V'd;\VP\P4'gVP	4\251SV`WV4#r,)r�r1rM�	SSLSocket�authrPr#)r$r&r'r(�securerQs&&&&&�rr#�
FTP_TLS.login�s4����j����C�M�M�B�B��	�	���7�=��t�4�4rc���\VP\P4'd\	R4hVP252P\P8�dVPR4pMVPR4pVP253PVPVPR7VnVPPRVPR7Vn
V#)z2Set up secure control connection by using TLS/SSL.zAlready using TLSzAUTH TLSzAUTH SSL��server_hostnamer;)�moder)r�r1rMrTr?rK�protocol�PROTOCOL_TLSr��wrap_socketr%rFrrGr�s& rrU�FTP_TLS.auth�s����$�)�)�S�]�]�3�3� �!4�5�5��|�|�$�$��(8�(8�8��|�|�J�/���|�|�J�/�����0�0����D�I�I�0�V�D�I��	�	�*�*��d�m�m�*�L�D�I��Krc���\VP\P4'g\	R4hVPR4pVPP
4VnV#)z/Switch back to a clear-text control connection.z
not using TLS�CCC)r�r1rMrTr?r�r�r�s& r�ccc�FTP_TLS.ccc�sI���d�i�i����7�7� ��1�1��<�<��&�D��	�	�(�(�*�D�I��Krc�X�VPR4VPR4pRVnV#)zSet up secure data connection.zPBSZ 0zPROT PT�r�rOr�s& r�prot_p�FTP_TLS.prot_p�s*��
�L�L��"��<�<��)�D��D�L��Krc�6�VPR4pRVnV#)z"Set up clear text data connection.zPROT CFrer�s& r�prot_c�FTP_TLS.prot_c�s���<�<��)�D� �D�L��Krc�<�\SV`W4wr4VP'd(VPP	VVP254R7pW43#)rY)rPr�rOrKr^r%)r$r�r�r�r�rQs&&&  �rr��FTP_TLS.ntransfercmdsH�����-�c�8�J�D��|�|�|��|�|�/�/��@D�	�	�0�K���:�rc��R\,pVPPV4VP4pVR,R9d\	V4hV#)r�rr�)r�r1rir�rr�s&  rr��
FTP_TLS.abort	sI���V�#�D��I�I���d�#��$�$�&�D��B�x�4�4�!�$�'�'��Kr)rOrKrGr1)rrrr)rrrTr,)r
rrrrCrr)r#rUrbrfrir�r�rrG�
__classcell__)rQrHs@@rrJrJ�sc����	�B	I� $�	I�.E�	I�$(�	I�3:�	I�	I�	5�255 256	�	�	� 	�	�	�	rrJc��VR,R8wd\V4h\f2^RIpVPRVPVP257,4s\P
V4pV'gR#\VP^44#)z�Parse the '150' response for a RETR request.258Returns the expected transfer size or None; size is not guaranteed to259be present in the 150 message.260rr�Nz150 .* \((\d+) bytes\))	r�_150_re�re�compile�261IGNORECASE�ASCII�matchr.�group)r�rr�ms&  rr�r�sj��262�B�x�5���$�������*�*�%�r�}�}�r�x�x�'?�A���
�
�d��A����q�w�w�q�z�?�rc��VR,R8wd\V4h\f!^RIpVPRVP4s\PV4pV'g\
V4hVP4pRPVR,4p\V^,4^,\V^,4,pWE3#)z�Parse the '227' response for a PASV request.263Raises error_proto if it does not contain '(h1,h2,h3,h4,p1,p2)'264Return ('host.addr.as.numbers', port#) tuple.r�227Nz#(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)r�:Nr}N)265r�_227_rerrrsru�searchr�groupsr�r.)r�rrrx�numbersr%r>s&     rr�r�,s����B�x�5���$�������*�*�C�R�X�X�N�����t��A���$����h�h�j�G��8�8�G�B�K� �D����266�O�q� �C���267�O�3�D��:�rc���VR,R8wd\V4hVPR4pV^8d\V4hVPRV^,4pV^8d\V4hW^,,W^,268,8wd\V4hW^,VPW^,,4p\	V4^8wd\V4hV^,p\V^,4pWV3#)z�Parse the '229' response for an EPSV request.269Raises error_proto if it does not contain '(|||port|)'270Return ('host.addr.as.numbers', port#) tuple.r�229�(�))r�findrr�r_r.)r��peer�left�right�partsr%r>s&&     rr�r�?s����B�x�5���$����9�9�S�>�D��a�x�{�4�(�(��I�I�c�4�!�8�$�E��q�y��$����1�H�~��a�i��(��$������%� �&�&�t��F�|�4�E�271�5�z�Q���$�����7�D��u�Q�x�=�D��:�rc��VR,R8wd\V4hVR,R8wdR#Rp^p\V4pW#8dBW,pV^,pVR8Xd W#8�gW,R8wdV#V^,pW,pKGV#)z�Parse the '257' response for a MKD or PWD request.272This is a response to a MKD or PWD request: a directory name.273Returns the directoryname in the 257 reply.rr1:r|r[Nz "r�")rr_)r�r'rc�nr�s&    rr4r4Ts����B�x�5���$����C�y�D����G�	�A��D�	�A�274�%��G��
�a�C����8��v���C����N��!��A��+���Nrc��\V4R#)z+Default retrlines callback to print a line.N)rM)rls&rr�r�js	��	�$�Krc��V'gTpRV,pVPV4VPV4\VPR44wrVVPWV4VPRV,4pVR,R9d\hVPRV,4pVR,R9d\hVP4VP4R#)z+Copy file from one FTP-instance to another.zTYPE r�zSTOR r�RETR N>�125r�)r�r�r�r�rr�)	�source�275sourcename�target�276targetname�type�277sourcehost�278sourceport�treply�sreplys	&&&&&    r�ftpcpr�os�����279��T�>�D�280�N�N�4��281�N�N�4��%�f�n�n�V�&<�=��J�282�O�O�J�+��^�^�G�j�0�
1�F�
�b�z��'���
�^�^�G�j�0�
1�F�
�b�z��'���283�O�O��284�O�O�rc��\\P4^8d0\\P2854\P!^4^RIp^pRp\P^,R8XdV^,p\P^K8\P^,R,R8Xd0\P^,R,p\P^\P^,p\V4pVPV4R;p;rgVPV4pVPV4wrWpTPYVT4\PR,EFp	T	R,R2868XdTP!T	R,4M�T	R,R8Xd;Rp287T	R,'dT288R,T	R,,p289TP#T2904pM�T	R
8Xd"TP%TP&'*4MdTP)RT	,\P*P,P.R4\P*P,P14\P*P14EK 	TP34R# \\3d \R\PR7EL�i;i \d$Te\R	\PR7EL�i;i)a[Test program.291Usage: ftplib [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...292 293Options:294  -d        increase debugging level295  -r[file]  set alternate ~/.netrc file296 297Commands:298  -l[dir]   list directory299  -d[dir]   change the current directory300  -p        toggle passive and active mode301  file      retrieve the file and write it to stdout302Nz-d:N�Nz-r:r�NNrz$No account -- using anonymous login.)rGz5Could not open account file -- using anonymous login.z-l�CWDr�z-pr�i)r_r@�argvrM�testrC�exit�netrcrrS�authenticators�KeyError�	TypeError�stderrr3r#rr�rXrVr��stdout�buffer�write�flushr2)r�rL�rcfiler%�ftp�useridr'r(�netrcobjrGr�r�s            rr�r��s,���3�8�8�}�q��
�d�l�l���������I�
�F�303
�(�(�1�+��304��a�K�	��H�H�Q�K�305�x�x��{�2��$�����!��R����H�H�Q�K��8�8�A�;�D�306
�d�)�C����y�!���F��V�K��;�;�v�&��	K�#+�#:�#:�4�#@� �F�&��I�I�f�d�#����������8�t���G�G�D��H��
�"�X��
��C��B�x�x�s�S�y�4��8�3���;�;�s�#�D�
�T�\��L�L�S�.�.�.�/��N�N�7�T�>��:�:�,�,�2�2�D�
:��J�J���#�#�%��307�308������H�H�J��%�)�$�	K��8�s�z�z�J�J�	K���#����I��z�z�
#��#�s$�K�+J�,K�K�*K=�<K=�__main__)rrrrr�309all_errors)r�I)%rCr@rBr�__all__r�rDrE�	Exceptionr310rrrrr3r4r�rhr�rrMrTr�rJr��SSLError�ImportErrorrqr�r{r�r�r4r�r�r�r
rrr�<module>r�s!���L�
�*�������311���I���%���������%��312�W�h�
'�313���	��R	�R	�hu:�����J�k�#�k�Z�N�N�9����(�C�L�L�9�J����$���&�*�,�314�,=�@�z���F���K	���J��s�&C�	C�C
codekingpro/portable-devtools · Team Ai