AlkantarClanX12

Your IP : 3.22.42.189


Current Path : /proc/thread-self/root/opt/alt/python33/lib64/python3.3/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python33/lib64/python3.3/__pycache__/ftplib.cpython-33.pyo

�
��f=�c@s�dZddlZddlZddlZddlmZddgZdZdZdZGd	d
�d
e	�Z
Gdd�de
�ZGd
d�de
�ZGdd�de
�Z
Gdd�de
�Ze
eefZdZdZGdd�d�ZyddlZWnek
rYn9XGdd�de�Zejd�e
eeejfZeadd�Zeadd�Zdd�Zdd�Z d d!�Z!d"d#d$d%�Z"Gd&d�d�Z#d'd(�Z$e%d)kr�e$�ndS(*uSAn FTP client class and some helper functions.

Based on RFC 959: File Transfer Protocol (FTP), by J. Postel and J. Reynolds

Example:

>>> from ftplib import FTP
>>> ftp = FTP('ftp.python.org') # connect to host, default port
>>> ftp.login() # default, i.e.: user anonymous, passwd anonymous@
'230 Guest login ok, access restrictions apply.'
>>> ftp.retrlines('LIST') # list directory contents
total 9
drwxr-xr-x   8 root     wheel        1024 Jan  3  1994 .
drwxr-xr-x   8 root     wheel        1024 Jan  3  1994 ..
drwxr-xr-x   2 root     wheel        1024 Jan  3  1994 bin
drwxr-xr-x   2 root     wheel        1024 Jan  3  1994 etc
d-wxrwxr-x   2 ftp      wheel        1024 Sep  5 13:43 incoming
drwxr-xr-x   2 root     wheel        1024 Nov 17  1993 lib
drwxr-xr-x   6 1094     wheel        1024 Sep 13 19:07 pub
drwxr-xr-x   3 root     wheel        1024 Jan  3  1994 usr
-rw-r--r--   1 root     root          312 Aug  1  1994 welcome.msg
'226 Transfer complete.'
>>> ftp.quit()
'221 Goodbye.'
>>>

A nice test that reveals some of the network dialogue would be:
python ftplib.py -d localhost -l -p -l
iN(u_GLOBAL_DEFAULT_TIMEOUTuFTPuNetrciii cBs|EeZdZdS(uErrorN(u__name__u
__module__u__qualname__(u
__locals__((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuError9suErrorcBs|EeZdZdS(uerror_replyN(u__name__u
__module__u__qualname__(u
__locals__((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuerror_reply:suerror_replycBs|EeZdZdS(u
error_tempN(u__name__u
__module__u__qualname__(u
__locals__((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu
error_temp;su
error_tempcBs|EeZdZdS(u
error_permN(u__name__u
__module__u__qualname__(u
__locals__((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu
error_perm<su
error_permcBs|EeZdZdS(uerror_protoN(u__name__u
__module__u__qualname__(u
__locals__((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuerror_proto=suerror_protou
s
cBs�|EeZdZdZdZdZeZeZ	dZZdZZdZZ
dZdZddddedZdd�Zdd	�Zd
d�Zddd[dZd
d�Zdd�Zdd�ZeZdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Z d%d&�Z!d'd(�Z"d)d*�Z#d+d,�Z$d-d.�Z%d/d0�Z&dZd1d2�Z'dZd3d4�Z(dddd5d6�Z)d7dZd8d9�Z*dZd:d;�Z+d7dZdZd<d=�Z,dZd>d?�Z-d@dA�Z.dBdC�Z/dDdE�Z0dgdFdG�Z1dHdI�Z2dJdK�Z3dLdM�Z4dNdO�Z5dPdQ�Z6dRdS�Z7dTdU�Z8dVdW�Z9dXdY�Z:dZS(\uFTPuyAn FTP client class.

    To create a connection, call the class using these arguments:
            host, user, passwd, acct, timeout

    The first four arguments are all strings, and have default value ''.
    timeout must be numeric and defaults to None if not passed,
    meaning that no timeout will be set on any ftp socket(s)
    If a timeout is passed, then this is now the default timeout for all ftp
    socket operations for this instance.

    Then use self.connect() with optional host and port argument.

    To download a file, use ftp.retrlines('RETR ' + filename),
    or ftp.retrbinary() with slightly different arguments.
    To upload a file, use ftp.storlines() or ftp.storbinary(),
    which have an open file as argument (see their definitions
    below for details).
    The download/upload functions first issue appropriate TYPE
    and PORT or PASV commands.
    iuiulatin-1cCsH||_||_|rD|j|�|rD|j|||�qDndS(N(usource_addressutimeoutuconnectulogin(uselfuhostuuserupasswduacctutimeoutusource_address((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu__init__ps		
uFTP.__init__cCs|S(N((uself((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu	__enter__ysu
FTP.__enter__cGsf|jdk	rbz0y|j�Wntjtfk
r=YnXWd|jdk	r^|j�nXndS(N(usockuNoneuquitusocketuerroruEOFErroruclose(uselfuargs((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu__exit__}s	uFTP.__exit__i�cCs�|dkr||_n|dkr0||_n|dkrH||_n|dk	r`||_ntj|j|jf|jd|j�|_|jj|_	|jj
dd|j�|_|j
�|_|jS(	u6Connect to host.  Arguments are:
         - host: hostname to connect to (string, default previous host)
         - port: port to connect to (integer, default previous port)
         - source_address: a 2-tuple (host, port) for the socket to bind
           to as its source address before connecting.
        uii�usource_addressuruencodingi���N(uhostuportutimeoutuNoneusource_addressusocketucreate_connectionusockufamilyuafumakefileuencodingufileugetrespuwelcome(uselfuhostuportutimeoutusource_address((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuconnect�suFTP.connectcCs,|jr%td|j|j��n|jS(u`Get the welcome message from the server.
        (this is read and squirreled away by connect())u	*welcome*(u	debugginguprintusanitizeuwelcome(uself((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu
getwelcome�s	uFTP.getwelcomecCs
||_dS(u�Set the debugging level.
        The required argument level means:
        0: no debugging output (default)
        1: print commands and responses but not body text etc.
        2: also print raw lines read and sent before stripping CR/LFN(u	debugging(uselfulevel((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuset_debuglevel�suFTP.set_debuglevelcCs
||_dS(u�Use passive or active mode for data transfers.
        With a false argument, use the normal PORT mode,
        With a true argument, use the PASV command.N(u
passiveserver(uselfuval((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuset_pasv�suFTP.set_pasvcCsb|dd�dkrXt|jd��}|dd�d|d||d�}nt|�S(Niupass uPASS u
u*>uPASS upass (ulenurstripurepr(uselfusui((u+/opt/alt/python33/lib64/python3.3/ftplib.pyusanitize�s-uFTP.sanitizecCsyd|ksd|kr'td��n|t}|jdkrYtd|j|��n|jj|j|j��dS(Nu
u
u4an illegal newline character should not be containediu*put*(	u
ValueErroruCRLFu	debugginguprintusanitizeusockusendalluencodeuencoding(uselfuline((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuputline�s
uFTP.putlinecCs3|jr"td|j|��n|j|�dS(Nu*cmd*(u	debugginguprintusanitizeuputline(uselfuline((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuputcmd�s	u
FTP.putcmdcCs�|jj|jd�}t|�|jkrDtd|j��n|jdkrltd|j|��n|s{t�n|dd�t	kr�|dd�}n)|dd�t	kr�|dd�}n|S(	Niugot more than %d bytesu*get*ii����i����i����i����(
ufileureadlineumaxlineulenuErroru	debugginguprintusanitizeuEOFErroruCRLF(uselfuline((u+/opt/alt/python33/lib64/python3.3/ftplib.pyugetline�s	uFTP.getlinecCs�|j�}|dd�dkr�|dd�}xP|j�}|d|}|dd�|kr5|dd�dkr5Pq5q5n|S(Niiu-u
(ugetline(uselfulineucodeunextline((u+/opt/alt/python33/lib64/python3.3/ftplib.pyugetmultiline�s
uFTP.getmultilinecCs�|j�}|jr.td|j|��n|dd�|_|dd�}|d	kra|S|dkr|t|��n|dkr�t|��nt|��dS(
Nu*resp*iiu1u2u3u4u5>u3u2u1(ugetmultilineu	debugginguprintusanitizeulastrespu
error_tempu
error_permuerror_proto(uselfurespuc((u+/opt/alt/python33/lib64/python3.3/ftplib.pyugetresp�s	uFTP.getrespcCs5|j�}|dd�dkr1t|��n|S(u%Expect a response beginning with '2'.Niu2(ugetrespuerror_reply(uselfuresp((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuvoidresp�suFTP.voidrespcCszdt}|jdkr2td|j|��n|jj|t�|j�}|dd�d	krvt|��n|S(
u�Abort a file transfer.  Uses out-of-band data.
        This does not follow the procedure from the RFC to send Telnet
        IP and Synch; that doesn't seem to work with the servers I've
        tried.  Instead, just send the ABOR command as OOB data.sABORiu*put urgent*Niu426u225u226>u225u226u426(	uB_CRLFu	debugginguprintusanitizeusockusendalluMSG_OOBugetmultilineuerror_proto(uselfulineuresp((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuabort�s
u	FTP.abortcCs|j|�|j�S(u'Send a command and return the response.(uputcmdugetresp(uselfucmd((u+/opt/alt/python33/lib64/python3.3/ftplib.pyusendcmds
uFTP.sendcmdcCs|j|�|j�S(u8Send a command and expect a response beginning with '2'.(uputcmduvoidresp(uselfucmd((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuvoidcmds
uFTP.voidcmdcCsY|jd�}t|d�t|d�g}||}ddj|�}|j|�S(uUSend a PORT command with the current host and the given
        port number.
        u.iuPORT u,(usplitureprujoinuvoidcmd(uselfuhostuportuhbytesupbytesubytesucmd((u+/opt/alt/python33/lib64/python3.3/ftplib.pyusendports
 
uFTP.sendportcCs�d}|jtjkr!d}n|jtjkr<d}n|dkrWtd��ndt|�|t|�dg}ddj|�}|j|�S(uDSend a EPRT command with the current host and the given port number.iiiuunsupported address familyuuEPRT u|(uafusocketuAF_INETuAF_INET6uerror_protoureprujoinuvoidcmd(uselfuhostuportuafufieldsucmd((u+/opt/alt/python33/lib64/python3.3/ftplib.pyusendeprts		!uFTP.sendeprtc
Cs�d}d}x�tjdd|jtjdtj�D]�}|\}}}}}y&tj|||�}|j|�WnJtjk
r�}	z'|	}|r�|j�nd}w4WYdd}	~	XnXPq4W|dkr	|dk	r�|�ntjd��tjt	��n|j
d�|j�d}
|jj�d}|jtj
kr`|j||
�}n|j||
�}|jtk	r�|j|j�n|S(u3Create a new socket and send a PORT command for it.iNu!getaddrinfo returns an empty listi(uNoneusocketugetaddrinfouafuSOCK_STREAMu
AI_PASSIVEubinduerrorucloseumsgulistenugetsocknameusockuAF_INETusendportusendeprtutimeoutu_GLOBAL_DEFAULT_TIMEOUTu
settimeout(
uselfuerrusockuresuafusocktypeuprotou	canonnameusau_uportuhosturesp((u+/opt/alt/python33/lib64/python3.3/ftplib.pyumakeport(s8.
	
uFTP.makeportcCsa|jtjkr0t|jd��\}}n't|jd�|jj��\}}||fS(NuPASVuEPSV(uafusocketuAF_INETuparse227usendcmduparse229usockugetpeername(uselfuhostuport((u+/opt/alt/python33/lib64/python3.3/ftplib.pyumakepasvIs'uFTP.makepasvc

Cs�d}|jr�|j�\}}tj||f|jd|j�}yq|dk	rh|jd|�n|j|�}|ddkr�|j�}n|ddkr�t	|��nWq�|j
��Yq�Xn�|j���}|dk	r|jd|�n|j|�}|ddkr.|j�}n|ddkrMt	|��n|j�\}}	|jt
k	r�|j|j�nWdQX|dd�dkr�t|�}n||fS(	u�Initiate a transfer over the data connection.

        If the transfer is active, send a port command and the
        transfer command, and accept the connection.  If the server is
        passive, send a pasv command, connect to it, and start the
        transfer command.  Either way, return the socket for the
        connection and the expected size of the transfer.  The
        expected size may be None if it could not be determined.

        Optional `rest' argument can be a string that is sent as the
        argument to a REST command.  This is essentially a server
        marker used to tell the server to skip over any data up to the
        given marker.
        usource_addressuREST %siu2u1Niu150(uNoneu
passiveserverumakepasvusocketucreate_connectionutimeoutusource_addressusendcmdugetrespuerror_replyucloseumakeportuacceptu_GLOBAL_DEFAULT_TIMEOUTu
settimeoutuparse150(
uselfucmdurestusizeuhostuportuconnurespusockusockaddr((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuntransfercmdPs<	
uFTP.ntransfercmdcCs|j||�dS(u0Like ntransfercmd() but returns only the socket.i(untransfercmd(uselfucmdurest((u+/opt/alt/python33/lib64/python3.3/ftplib.pyutransfercmd�suFTP.transfercmdcCs�|sd}n|sd}n|s-d}n|dkrR|dkrR|d}n|jd|�}|ddkr�|jd|�}n|ddkr�|jd	|�}n|dd
kr�t|��n|S(uLogin, default anonymous.u	anonymousuu-u
anonymous@uUSER iu3uPASS uACCT u2>uu-(usendcmduerror_reply(uselfuuserupasswduaccturesp((u+/opt/alt/python33/lib64/python3.3/ftplib.pyulogin�s 			
u	FTP.logini c	Cs[|jd�|j||��0}x&|j|�}|s>Pn||�q%WdQX|j�S(u�Retrieve data in binary mode.  A new port is created for you.

        Args:
          cmd: A RETR command.
          callback: A single parameter callable to be called on each
                    block of data read.
          blocksize: The maximum number of bytes to read from the
                     socket at one time.  [default: 8192]
          rest: Passed to transfercmd().  [default: None]

        Returns:
          The response code.
        uTYPE IN(uvoidcmdutransfercmdurecvuvoidresp(uselfucmducallbacku	blocksizeurestuconnudata((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu
retrbinary�s
uFTP.retrbinarycCs9|dkrt}n|jd�}|j|���}|jdd|j���}x�|j|jd�}t|�|jkr�t	d|j��n|j
dkr�tdt|��n|s�Pn|d
d�t
kr�|dd�}n)|dd�d	kr|dd
�}n||�qTWdQXWdQX|j�S(uhRetrieve data in line mode.  A new port is created for you.

        Args:
          cmd: A RETR, LIST, or NLST command.
          callback: An optional single parameter callable that is called
                    for each line with the trailing CRLF stripped.
                    [default: print_line()]

        Returns:
          The response code.
        uTYPE Auruencodingiugot more than %d bytesiu*retr*Nu
i����i����i����i����(uNoneu
print_lineusendcmdutransfercmdumakefileuencodingureadlineumaxlineulenuErroru	debugginguprinturepruCRLFuvoidresp(uselfucmducallbackurespuconnufpuline((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu	retrlines�s&	u
FTP.retrlinesc	Csq|jd�|j||��F}x<|j|�}|s>Pn|j|�|r%||�q%q%WdQX|j�S(u9Store a file in binary mode.  A new port is created for you.

        Args:
          cmd: A STOR command.
          fp: A file-like object with a read(num_bytes) method.
          blocksize: The maximum data size to read from fp and send over
                     the connection at once.  [default: 8192]
          callback: An optional single parameter callable that is called on
                    each block of data after it is sent.  [default: None]
          rest: Passed to transfercmd().  [default: None]

        Returns:
          The response code.
        uTYPE IN(uvoidcmdutransfercmdureadusendalluvoidresp(uselfucmdufpu	blocksizeucallbackurestuconnubuf((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu
storbinary�s

uFTP.storbinaryc
Cs�|jd�|j|���}x�|j|jd�}t|�|jkrctd|j��n|smPn|dd�tkr�|dtkr�|dd�}n|t}n|j|�|r"||�q"q"WdQX|j�S(	uhStore a file in line mode.  A new port is created for you.

        Args:
          cmd: A STOR command.
          fp: A file-like object with a readline() method.
          callback: An optional single parameter callable that is called on
                    each line after it is sent.  [default: None]

        Returns:
          The response code.
        uTYPE Aiugot more than %d bytesiNi����i����i����(	uvoidcmdutransfercmdureadlineumaxlineulenuErroruB_CRLFusendalluvoidresp(uselfucmdufpucallbackuconnubuf((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu	storlines�s 


u
FTP.storlinescCsd|}|j|�S(uSend new account name.uACCT (uvoidcmd(uselfupassworducmd((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuaccts
uFTP.acctcGsBd}x|D]}|d|}q
Wg}|j||j�|S(uBReturn a list of files in a given directory (default the current).uNLSTu (u	retrlinesuappend(uselfuargsucmduargufiles((u+/opt/alt/python33/lib64/python3.3/ftplib.pyunlsts
uFTP.nlstcGs�d}d}|dd�rVt|d�td�krV|dd�|d	}}nx%|D]}|r]|d|}q]q]W|j||�dS(
uList a directory in long form.
        By default list current directory to stdout.
        Optional last argument is callback function; all
        non-empty arguments before it are concatenated to the
        LIST command.  (This *should* only be used for a pathname.)uLISTiNuu i����i����i����i����(uNoneutypeu	retrlines(uselfuargsucmdufuncuarg((u+/opt/alt/python33/lib64/python3.3/ftplib.pyudirs,
uFTP.dirc
cs�|r'|jddj|�d�n|r:d|}nd}g}|j||j�x�|D]�}|jt�jd�\}}}i}	xI|dd	�jd�D].}
|
jd�\}}}||	|j�<q�W||	fVq`WdS(
u<List a directory in a standardized format by using MLSD
        command (RFC-3659). If path is omitted the current directory
        is assumed. "facts" is a list of strings representing the type
        of information desired (e.g. ["type", "size", "perm"]).

        Return a generator object yielding a tuple of two elements
        for every file found in path.
        First element is the file name, the second one is a dictionary
        including a variable number of "facts" depending on the server
        and whether "facts" argument has been provided.
        u
OPTS MLST u;uMLSD %suMLSDu Niu=i����(	usendcmdujoinu	retrlinesuappendurstripuCRLFu	partitionusplitulower(
uselfupathufactsucmdulinesulineufacts_foundu_unameuentryufactukeyuvalue((u+/opt/alt/python33/lib64/python3.3/ftplib.pyumlsd$s!

! uFTP.mlsdcCsC|jd|�}|ddkr2t|��n|jd|�S(uRename a file.uRNFR iu3uRNTO (usendcmduerror_replyuvoidcmd(uselfufromnameutonameuresp((u+/opt/alt/python33/lib64/python3.3/ftplib.pyurename@su
FTP.renamecCs=|jd|�}|dd�dkr-|St|��dS(uDelete a file.uDELE Niu250u200>u250u200(usendcmduerror_reply(uselfufilenameuresp((u+/opt/alt/python33/lib64/python3.3/ftplib.pyudeleteGsu
FTP.deletecCs�|dkrky|jd�SWq�tk
rg}z(|jddd�dkrU�nWYdd}~Xq�Xn|dkr�d}nd	|}|j|�S(
uChange to a directory.u..uCDUPiNiu500uu.uCWD (uvoidcmdu
error_permuargs(uselfudirnameumsgucmd((u+/opt/alt/python33/lib64/python3.3/ftplib.pyucwdOs	
uFTP.cwdcCsM|jd|�}|dd�dkrI|dd�j�}t|�SdS(uRetrieve the size of a file.uSIZE Niu213(usendcmdustripuint(uselfufilenameurespus((u+/opt/alt/python33/lib64/python3.3/ftplib.pyusize\suFTP.sizecCs0|jd|�}|jd�s&dSt|�S(u+Make a directory, return its full pathname.uMKD u257u(uvoidcmdu
startswithuparse257(uselfudirnameuresp((u+/opt/alt/python33/lib64/python3.3/ftplib.pyumkddsuFTP.mkdcCs|jd|�S(uRemove a directory.uRMD (uvoidcmd(uselfudirname((u+/opt/alt/python33/lib64/python3.3/ftplib.pyurmdmsuFTP.rmdcCs,|jd�}|jd�s"dSt|�S(u!Return current working directory.uPWDu257u(uvoidcmdu
startswithuparse257(uselfuresp((u+/opt/alt/python33/lib64/python3.3/ftplib.pyupwdqsuFTP.pwdcCs|jd�}|j�|S(uQuit, and close the connection.uQUIT(uvoidcmduclose(uselfuresp((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuquitzs
uFTP.quitcCsR|jdk	r|jj�n|jdk	r>|jj�nd|_|_dS(u8Close the connection without assuming anything about it.N(ufileuNoneucloseusock(uself((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuclose�s
u	FTP.closeNi���(;u__name__u
__module__u__qualname__u__doc__u	debugginguhostuFTP_PORTuportuMAXLINEumaxlineuNoneusockufileuwelcomeu
passiveserveruencodingu_GLOBAL_DEFAULT_TIMEOUTu__init__u	__enter__u__exit__uconnectu
getwelcomeuset_debugleveludebuguset_pasvusanitizeuputlineuputcmdugetlineugetmultilineugetrespuvoidrespuabortusendcmduvoidcmdusendportusendeprtumakeportumakepasvuntransfercmdutransfercmduloginu
retrbinaryu	retrlinesu
storbinaryu	storlinesuacctunlstudirumlsdurenameudeleteucwdusizeumkdurmdupwduquituclose(u
__locals__((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuFTPJsj




!7	
		cBs�|EeZdZdZejZdddddddeddd�	Z	dddddd�Zdd�Zd	d
�Z
dd�Zd
d�Zddd�Zdddd�Zddd�Zddddd�Zddd�Zdd�ZdS(uFTP_TLSu�A FTP subclass which adds TLS support to FTP as described
        in RFC-4217.

        Connect as usual to port 21 implicitly securing the FTP control
        connection before authenticating.

        Securing the data connection requires user to explicitly ask
        for it by calling prot_p() method.

        Usage example:
        >>> from ftplib import FTP_TLS
        >>> ftps = FTP_TLS('ftp.python.org')
        >>> ftps.login()  # login anonymously previously securing control channel
        '230 Guest login ok, access restrictions apply.'
        >>> ftps.prot_p()  # switch to secure data connection
        '200 Protection level set to P'
        >>> ftps.retrlines('LIST')  # list directory content securely
        total 9
        drwxr-xr-x   8 root     wheel        1024 Jan  3  1994 .
        drwxr-xr-x   8 root     wheel        1024 Jan  3  1994 ..
        drwxr-xr-x   2 root     wheel        1024 Jan  3  1994 bin
        drwxr-xr-x   2 root     wheel        1024 Jan  3  1994 etc
        d-wxrwxr-x   2 ftp      wheel        1024 Sep  5 13:43 incoming
        drwxr-xr-x   2 root     wheel        1024 Nov 17  1993 lib
        drwxr-xr-x   6 1094     wheel        1024 Sep 13 19:07 pub
        drwxr-xr-x   3 root     wheel        1024 Jan  3  1994 usr
        -rw-r--r--   1 root     root          312 Aug  1  1994 welcome.msg
        '226 Transfer complete.'
        >>> ftps.quit()
        '221 Goodbye.'
        >>>
        uc


Cs�|dk	r'|dk	r'td��n|dk	rN|dk	rNtd��n||_||_||_d|_tj|||||||	�dS(Nu4context and keyfile arguments are mutually exclusiveu5context and certfile arguments are mutually exclusiveF(	uNoneu
ValueErrorukeyfileucertfileucontextuFalseu_prot_puFTPu__init__(
uselfuhostuuserupasswduacctukeyfileucertfileucontextutimeoutusource_address((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu__init__�s				uFTP_TLS.__init__cCs?|r)t|jtj�r)|j�ntj||||�S(N(u
isinstanceusockusslu	SSLSocketuauthuFTPulogin(uselfuuserupasswduacctusecure((u+/opt/alt/python33/lib64/python3.3/ftplib.pyulogin�s
u
FTP_TLS.logincCs�t|jtj�r$td��n|jtjkrH|jd�}n|jd�}|jdk	r�|jj
|j�|_n*tj
|j|j|jd|j�|_|jj
ddd|j�|_|S(	u2Set up secure control connection by using TLS/SSL.uAlready using TLSuAUTH TLSuAUTH SSLussl_versionumodeuruencodingN(u
isinstanceusockusslu	SSLSocketu
ValueErrorussl_versionuPROTOCOL_TLSv1uvoidcmducontextuNoneuwrap_socketukeyfileucertfileumakefileuencodingufile(uselfuresp((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuauth�s	!uFTP_TLS.authcCsIt|jtj�s$td��n|jd�}|jj�|_|S(u/Switch back to a clear-text control connection.u
not using TLSuCCC(u
isinstanceusockusslu	SSLSocketu
ValueErroruvoidcmduunwrap(uselfuresp((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuccc�s
uFTP_TLS.ccccCs)|jd�|jd�}d|_|S(uSet up secure data connection.uPBSZ 0uPROT PT(uvoidcmduTrueu_prot_p(uselfuresp((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuprot_p�s
	uFTP_TLS.prot_pcCs|jd�}d|_|S(u"Set up clear text data connection.uPROT CF(uvoidcmduFalseu_prot_p(uselfuresp((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuprot_c�s	uFTP_TLS.prot_ccCsytj|||�\}}|jro|jdk	rH|jj|�}qotj||j|jd|j	�}n||fS(Nussl_version(
uFTPuntransfercmdu_prot_pucontextuNoneuwrap_socketusslukeyfileucertfileussl_version(uselfucmdurestuconnusize((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuntransfercmd�s	uFTP_TLS.ntransfercmdi c
Csz|jd�|j||��O}x&|j|�}|s>Pn||�q%t|tj�rj|j�nWdQX|j�S(NuTYPE I(uvoidcmdutransfercmdurecvu
isinstanceusslu	SSLSocketuunwrapuvoidresp(uselfucmducallbacku	blocksizeurestuconnudata((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu
retrbinary�s

uFTP_TLS.retrbinarycCs`|dkrt}n|jd�}|j|�}|jdd|j�}|�|��x�|j|jd�}t|�|jkr�t	d|j��n|j
dkr�tdt|��n|s�Pn|d	d�t
kr�|dd
�}n)|dd�dkr|dd�}n||�q\t|tj�rJ|j�nWdQXWdQX|j�S(
NuTYPE Auruencodingiugot more than %d bytesiu*retr*u
i����i����i����i����(uNoneu
print_lineusendcmdutransfercmdumakefileuencodingureadlineumaxlineulenuErroru	debugginguprinturepruCRLFu
isinstanceusslu	SSLSocketuunwrapuvoidresp(uselfucmducallbackurespuconnufpuline((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu	retrliness,	
uFTP_TLS.retrlinesc
Cs�|jd�|j||��e}x<|j|�}|s>Pn|j|�|r%||�q%q%t|tj�r�|j�nWdQX|j�S(NuTYPE I(	uvoidcmdutransfercmdureadusendallu
isinstanceusslu	SSLSocketuunwrapuvoidresp(uselfucmdufpu	blocksizeucallbackurestuconnubuf((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu
storbinary#s

uFTP_TLS.storbinaryc
Cs|jd�|j|���}x�|j|jd�}t|�|jkrctd|j��n|smPn|dd�tkr�|dtkr�|dd�}n|t}n|j|�|r"||�q"q"t|t	j
�r�|j�nWdQX|j�S(NuTYPE Aiugot more than %d bytesii����i����i����(
uvoidcmdutransfercmdureadlineumaxlineulenuErroruB_CRLFusendallu
isinstanceusslu	SSLSocketuunwrapuvoidresp(uselfucmdufpucallbackuconnubuf((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu	storlines0s$


uFTP_TLS.storlinescCsOdt}|jj|�|j�}|dd�dkrKt|��n|S(NsABORiu426u225u226>u225u226u426(uB_CRLFusockusendallugetmultilineuerror_proto(uselfulineuresp((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuabortBs
u
FTP_TLS.abortNT(u__name__u
__module__u__qualname__u__doc__ussluPROTOCOL_TLSv1ussl_versionuNoneu_GLOBAL_DEFAULT_TIMEOUTu__init__uTrueuloginuauthucccuprot_puprot_cuntransfercmdu
retrbinaryu	retrlinesu
storbinaryu	storlinesuabort(u
__locals__((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuFTP_TLS�s  	



uFTP_TLScCs�|dd�dkr%t|��ntdkr\ddl}|jd|j|jB�antj|�}|sudSt|j	d��S(u�Parse the '150' response for a RETR request.
    Returns the expected transfer size or None; size is not guaranteed to
    be present in the 150 message.
    Niu150iu150 .* \((\d+) bytes\)i(
uerror_replyu_150_reuNoneureucompileu
IGNORECASEuASCIIumatchuintugroup(urespureum((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuparse150Qsuparse150cCs�|dd�dkr%t|��ntdkrUddl}|jd|j�antj|�}|syt|��n|j�}dj	|dd��}t
|d�d>t
|d	�}||fS(
u�Parse the '227' response for a PASV request.
    Raises error_proto if it does not contain '(h1,h2,h3,h4,p1,p2)'
    Return ('host.addr.as.numbers', port#) tuple.Niu227iu#(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)u.iii(uerror_replyu_227_reuNoneureucompileuASCIIusearchuerror_protougroupsujoinuint(urespureumunumbersuhostuport((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuparse227es"uparse227cCs|dd�dkr%t|��n|jd�}|dkrOt|��n|jd|d�}|dkr�t|��n||d||dkr�t|��n||d|�j||d�}t|�dkr�t|��n|d}t|d�}||fS(	u�Parse the '229' response for a EPSV request.
    Raises error_proto if it does not contain '(|||port|)'
    Return ('host.addr.as.numbers', port#) tuple.Niu229u(iu)ii(uerror_replyufinduerror_protousplitulenuint(urespupeerulefturightupartsuhostuport((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuparse229ys %
uparse229cCs�|dd�dkr%t|��n|dd�dkr?dSd}d}t|�}xg||kr�||}|d}|dkr�||ks�||dkr�Pn|d}n||}qZW|S(	u�Parse the '257' response for a MKD or PWD request.
    This is a response to a MKD or PWD request: a directory name.
    Returns the directoryname in the 257 reply.Niu257iu "uiu"(uerror_replyulen(urespudirnameuiunuc((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuparse257�s 


uparse257cCst|�dS(u+Default retrlines callback to print a line.N(uprint(uline((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu
print_line�su
print_lineuuIc	Cs�|s|}nd|}|j|�|j|�t|jd��\}}|j||�|jd|�}|dd�d	kr�t�n|jd|�}|dd�d
kr�t�n|j�|j�dS(u+Copy file from one FTP-instance to another.uTYPE uPASVuSTOR Niu125u150uRETR >u150u125>u150u125(uvoidcmduparse227usendcmdusendportuerror_protouvoidresp(	usourceu
sourcenameutargetu
targetnameutypeu
sourcehostu
sourceportutreplyusreply((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuftpcp�s	


		
uftpcpcBsk|EeZdZdZdZdZdZddd�Zdd�Z	dd�Z
dd	�Zd
d�ZdS(
uNetrcu�Class to parse & provide access to 'netrc' format files.

    See the netrc(4) man page for information on the file format.

    WARNING: This class is obsolete -- use module netrc instead.

    c
Cs�|dkrIdtjkr:tjjtjdd�}qItd��ni|_i|_t|d�}d}xe|j	�}|s�Pn|r�|j
�r�|j|�qsn"|r�t|�|j|<d}n|j
�}d}}	}
}d}d}
x.|
t|�kr*||
}|
dt|�kr@||
d}nd}|dkr[d}n�|dkr�|r�|j�}|
d}
n�|d	kr�|r�|}	|
d}
nr|d
kr�|r�|}
|
d}
nM|dkr�|r�|}|
d}
n(|dkr|r|}g}d}Pn|
d}
q�W|rj|	p=|j|_|
pO|j|_|pa|j|_n|rs||jkr�|j|\}}}|	p�|}	|
p�|}
|p�|}n|	|
|f|j|<qsqs|j�dS(
NuHOMEu.netrcu!specify file to load or set $HOMEuriiudefaultumachineuloginupassworduaccountumacdef(uNoneuosuenvironupathujoinuIOErroru
_Netrc__hostsu_Netrc__macrosuopenureadlineustripuappendutupleusplitulenuloweru_Netrc__defuseru_Netrc__defpasswdu_Netrc__defacctuclose(uselfufilenameufpuin_macroulineumacro_linesu
macro_nameuwordsuhostuuserupasswduacctudefaultuiuw1uw2uouseruopasswduoacct((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu__init__�sx		
	
	



uNetrc.__init__cCs
|jj�S(u4Return a list of hosts mentioned in the .netrc file.(u
_Netrc__hostsukeys(uself((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu	get_hosts
suNetrc.get_hostscCs||j�}d}}}||jkrB|j|\}}}n|pN|j}|p]|j}|pl|j}|||fS(u�Returns login information for the named host.

        The return value is a triple containing userid,
        password, and the accounting field.

        N(uloweruNoneu
_Netrc__hostsu_Netrc__defuseru_Netrc__defpasswdu_Netrc__defacct(uselfuhostuuserupasswduacct((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuget_accountsuNetrc.get_accountcCs
|jj�S(u)Return a list of all defined macro names.(u_Netrc__macrosukeys(uself((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu
get_macrossuNetrc.get_macroscCs|j|S(u6Return a sequence of lines which define a named macro.(u_Netrc__macros(uselfumacro((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu	get_macro"suNetrc.get_macroN(
u__name__u
__module__u__qualname__u__doc__uNoneu_Netrc__defuseru_Netrc__defpasswdu_Netrc__defacctu__init__u	get_hostsuget_accountu
get_macrosu	get_macro(u
__locals__((u+/opt/alt/python33/lib64/python3.3/ftplib.pyuNetrc�s@cCskttj�dkr2ttj�tjd�nd}d}x+tjddkrk|d}tjd=qAWtjddd�dkr�tjddd�}tjd=ntjd}t|�}|j	|�d}}}yt
|�}Wn1tk
r$|dk	r tjj
d�nYnBXy|j|�\}}}Wn"tk
retjj
d	�YnX|j|||�x�tjdd�D]�}|dd�d
kr�|j|dd��q�|dd�dkrd}	|dd�r
|	d|dd�}	n|j|	�}
q�|d
kr<|j|j�q�|jd|tjj
d�q�W|j�dS(u�Test program.
    Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...

    -d dir
    -l list
    -p password
    iiiu-dNu-ruu5Could not open account file -- using anonymous login.u$No account -- using anonymous login.u-luCWDu u-puRETR i(ulenusysuargvuprintutestu__doc__uexituNoneuFTPuset_debugleveluNetrcuIOErrorustderruwriteuget_accountuKeyErroruloginudirusendcmduset_pasvu
passiveserveru
retrbinaryustdoutuquit(u	debuggingurcfileuhostuftpuuseridupasswduacctunetrcufileucmduresp((u+/opt/alt/python33/lib64/python3.3/ftplib.pyutest(sN	






	
utestu__main__(&u__doc__uosusysusocketu_GLOBAL_DEFAULT_TIMEOUTu__all__uMSG_OOBuFTP_PORTuMAXLINEu	ExceptionuErroruerror_replyu
error_tempu
error_permuerror_protouIOErroruEOFErroru
all_errorsuCRLFuB_CRLFuFTPussluImportErroruFTP_TLSuappenduSSLErroruNoneu_150_reuparse150u_227_reuparse227uparse229uparse257u
print_lineuftpcpuNetrcutestu__name__(((u+/opt/alt/python33/lib64/python3.3/ftplib.pyu<module>sL
��@
�
j7