tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
L\¬Qc@s dZddlZddlZy5ddlZeZ[ddlmZee_[Wnek
rrddlZnXddlmZddgZdZ    dZ
d    e fd
„ƒYZ d e fd „ƒYZ d e fd„ƒYZde fd„ƒYZde fd„ƒYZe eefZdZdfd„ƒYZyddlZWnek
rTn9Xdefd„ƒYZejdƒe eeejfZead„Zead„Zd„Zd„Z d„Z!ddd„Z"dfd„ƒYZ#d „Z$e%d!kre$ƒndS("sSAn 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
iÿÿÿÿN(tgetfqdn(t_GLOBAL_DEFAULT_TIMEOUTtFTPtNetrciitErrorcBseZRS((t__name__t
__module__(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyR=st error_replycBseZRS((RR(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyR>st
error_tempcBseZRS((RR(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyR?st
error_permcBseZRS((RR(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyR    @st error_protocBseZRS((RR(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyR
Ass
cBsÐeZdZdZdZeZd,Zd,Z    d,Z
dZ dddde d„Z dddd„Zd„Zd„ZeZd    „Zd
„Zd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d,d„Z!d,d„Z"dddd„Z#dd,d„Z$d,d„Z%dd,d,d„Z&d,d„Z'd „Z(d!„Z)d"„Z*d#„Z+d$„Z,d%„Z-d&„Z.d'„Z/d(„Z0d)„Z1d*„Z2d+„Z3RS(-suAn 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.
iticCs?||_|r;|j|ƒ|r;|j|||ƒq;ndS(N(ttimeouttconnecttlogin(tselfthosttusertpasswdtacctR ((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyt__init__qs
     iüÿÿcCs¦|dkr||_n|dkr0||_n|dkrH||_ntj|j|jf|jƒ|_|jj|_|jjdƒ|_    |j
ƒ|_ |j S(s¶Connect to host.  Arguments are:
         - host: hostname to connect to (string, default previous host)
         - port: port to connect to (integer, default previous port)
        R iiüÿÿtrb( RtportR tsockettcreate_connectiontsocktfamilytaftmakefiletfiletgetresptwelcome(RRRR ((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyR ys      $cCs(|jr!dG|j|jƒGHn|jS(s`Get the welcome message from the server.
        (this is read and squirreled away by connect())s    *welcome*(t    debuggingtsanitizeR(R((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyt
getwelcomeŠs    cCs ||_dS(sð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(R (Rtlevel((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytset_debuglevel‘scCs ||_dS(s›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(t passiveserver(Rtval((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytset_pasvšscCsˆ|d dks |d dkr~t|ƒ}x.|dkr\||ddkr\|d}q/W|d d|d||}nt|ƒS(Nispass sPASS is
t*(tlentrepr(Rtsti((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyR!¡s   #!cCsB|t}|jdkr.dG|j|ƒGHn|jj|ƒdS(Nis*put*(tCRLFR R!Rtsendall(Rtline((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytputlineªs
cCs/|jrdG|j|ƒGHn|j|ƒdS(Ns*cmd*(R R!R0(RR/((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytputcmd°s    cCs€|jjƒ}|jdkr3dG|j|ƒGHn|sBt‚n|dtkr_|d }n|dtkr||d }n|S(Nis*get*iþÿÿÿiÿÿÿÿ(RtreadlineR R!tEOFErrorR-(RR/((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytgetline¶s      cCsw|jƒ}|dd!dkrs|d }xG|jƒ}|d|}|d |kr,|dd!dkr,Pq,q,n|S(Niit-s
(R4(RR/tcodetnextline((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyt getmultilineÃs 
 
cCsŽ|jƒ}|jr*dG|j|ƒGHn|d |_|d }|d    krQ|S|dkrit|‚n|dkrt|‚nt|‚dS(
Ns*resp*iit1t2t3t4t5(R9R:R;(R8R R!tlastrespRR    R
(Rtresptc((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyRÑs      
     cCs,|jƒ}|d dkr(t|‚n|S(s%Expect a response beginning with '2'.iR:(RR(RR?((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytvoidrespÞs  cCsmdt}|jdkr.dG|j|ƒGHn|jj|tƒ|jƒ}|d d    krit|‚ndS(
sü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.tABORis *put urgent*it426t225t226N(RCRDRE(R-R R!RR.tMSG_OOBR8R
(RR/R?((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytabortås
 cCs|j|ƒ|jƒS(s'Send a command and return the response.(R1R(Rtcmd((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytsendcmdñs cCs|j|ƒ|jƒS(s8Send a command and expect a response beginning with '2'.(R1RA(RRH((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytvoidcmdös cCsY|jdƒ}t|dƒt|dƒg}||}ddj|ƒ}|j|ƒS(sUSend a PORT command with the current host and the given
        port number.
        t.isPORT t,(tsplitR*tjoinRJ(RRRthbytestpbytestbytesRH((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytsendportûs
 
cCs•d}|jtjkr!d}n|jtjkr<d}n|dkrTtd‚ndt|ƒ|t|ƒdg}ddj|ƒ}|j|ƒS(sDSend a EPRT command with the current host and the given port number.iiisunsupported address familyR sEPRT t|(RRtAF_INETtAF_INET6R
R*RNRJ(RRRRtfieldsRH((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytsendeprts          !c Csqd}d}x tjdd|jtjdtjƒD]w}|\}}}}}y&tj|||ƒ}|j|ƒWn2tjk
r©}|r|jƒnd}q4nXPq4W|dkrâ|dk    rÐ|‚qâtjdƒ‚n|j    dƒ|j
ƒd}    |j j
ƒd}
|jtj kr9|j |
|    ƒ} n|j|
|    ƒ} |jtk    rm|j|jƒn|S(s3Create a new socket and send a PORT command for it.is!getaddrinfo returns an empty listiN(tNoneRt getaddrinfoRt SOCK_STREAMt
AI_PASSIVEtbindterrortclosetlistent getsocknameRRTRRRWR Rt
settimeout( RterrRtresRtsocktypetprotot    canonnametsaRRR?((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytmakeports4.        cCsa|jtjkr0t|jdƒƒ\}}n't|jdƒ|jjƒƒ\}}||fS(NtPASVtEPSV(RRRTtparse227RItparse229Rt getpeername(RRR((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytmakepasv1s'c
Cs©d}|jrÄ|jƒ\}}tj||f|jƒ}yn|dk    r_|jd|ƒn|j|ƒ}|ddkr|jƒ}n|ddkr©t|‚nWq€|j    ƒ‚q€Xn¼|j
ƒ}z¢|dk    ró|jd|ƒn|j|ƒ}|ddkr!|jƒ}n|ddkr=t|‚n|j ƒ\}}    |jt k    rq|j |jƒnWd|j    ƒX|d dkrŸt|ƒ}n||fS(s¦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.
        sREST %siR:R9Nit150(RXR%RnRRR RIRRR^RhtacceptRRatparse150(
RRHtresttsizeRRtconnR?Rtsockaddr((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyt ntransfercmd8s>     
 
    cCs|j||ƒdS(s0Like ntransfercmd() but returns only the socket.i(Rv(RRHRr((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyt transfercmdqscCsÑ|sd}n|sd}n|s-d}n|dkrR|d krR|d}n|jd|ƒ}|ddkr‹|jd|ƒ}n|ddkr±|jd    |ƒ}n|dd
krÍt|‚n|S( sLogin, default anonymous.t    anonymousR R5s
anonymous@sUSER iR;sPASS sACCT R:(R R5(RIR(RRRRR?((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyRus               i cCs\|jdƒ|j||ƒ}x&|j|ƒ}|s;Pn||ƒq"|jƒ|jƒS(sÆ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.
        sTYPE I(RJRwtrecvR^RA(RRHtcallbackt    blocksizeRrRttdata((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyt
retrbinaryŠs  
cCsá|dkrt}n|jdƒ}|j|ƒ}|jdƒ}x~|jƒ}|jdkrrdGt|ƒGHn|s|Pn|dtkr™|d }n|ddkr¶|d }n||ƒqE|j    ƒ|j    ƒ|j
ƒS(    snRetrieve data in line mode.  A new port is created for you.
 
        Args:
          cmd: A RETR, LIST, NLST, or MLSD 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.
        sTYPE ARis*retr*iþÿÿÿiÿÿÿÿs
N( RXt
print_lineRIRwRR2R R*R-R^RA(RRHRzR?RttfpR/((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyt    retrlines¢s&        
 
cCsr|jdƒ|j||ƒ}x<|j|ƒ}|s;Pn|j|ƒ|r"||ƒq"q"|jƒ|jƒS(s9Store 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.
        sTYPE I(RJRwtreadR.R^RA(RRHRR{RzRrRttbuf((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyt
storbinaryÀs  
cCs¦|jdƒ|j|ƒ}xs|jƒ}|s5Pn|dtkro|dtkrb|d }n|t}n|j|ƒ|r||ƒqq|jƒ|jƒS(shStore 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.
        sTYPE Aiþÿÿÿiÿÿÿÿ(RJRwR2R-R.R^RA(RRHRRzRtR‚((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyt    storlinesÙs     
cCsd|}|j|ƒS(sSend new account name.sACCT (RJ(RtpasswordRH((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyRòs
cGsBd}x|D]}|d|}q Wg}|j||jƒ|S(sBReturn a list of files in a given directory (default the current).tNLSTt (R€tappend(RtargsRHtargtfiles((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytnlst÷s  cGs†d}d}|drJt|dƒtdƒkrJ|d |d}}nx%|D]}|rQ|d|}qQqQW|j||ƒdS(sList 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.)tLISTiÿÿÿÿR R‡N(RXttypeR€(RR‰RHtfuncRŠ((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytdirs& cCs@|jd|ƒ}|ddkr/t|‚n|jd|ƒS(sRename a file.sRNFR iR;sRNTO (RIRRJ(RtfromnamettonameR?((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytrenames cCs4|jd|ƒ}|d dkr'|St|‚dS(sDelete a file.sDELE it250t200N(R”R•(RIR(RtfilenameR?((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytdeletescCs|dkrSy|jdƒSWqhtk
rO}|jdd dkrP‚qPqhXn|dkrhd}nd|}|j|ƒS(    sChange to a directory.s..tCDUPiit500R RKsCWD (RJR    R‰(RtdirnametmsgRH((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytcwds       
cCsi|jd|ƒ}|d dkre|djƒ}yt|ƒSWqettfk
rat|ƒSXndS(sRetrieve the size of a file.sSIZE it213N(RItstriptintt OverflowErrort
ValueErrortlong(RR–R?R+((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyRs+scCs|jd|ƒ}t|ƒS(s+Make a directory, return its full pathname.sMKD (RItparse257(RRšR?((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytmkd6scCs|jd|ƒS(sRemove a directory.sRMD (RJ(RRš((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytrmd;scCs|jdƒ}t|ƒS(s!Return current working directory.tPWD(RIR£(RR?((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytpwd?scCs|jdƒ}|jƒ|S(sQuit, and close the connection.tQUIT(RJR^(RR?((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytquitDs
cCsR|jdk    r|jjƒn|jdk    r>|jjƒnd|_|_dS(s8Close the connection without assuming anything about it.N(RRXR^R(R((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyR^Js
N(4RRt__doc__R RtFTP_PORTRRXRRRR%RRR R"R$tdebugR'R!R0R1R4R8RRARGRIRJRRRWRhRnRvRwRR}R€RƒR„RRŒRR“R—RœRsR¤R¥R§R©R^(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyRMs`                                                              
            9                                                   tFTP_TLScBsªeZdZejZddddd d ed„Zddde    d„Z
d„Z d„Z d„Z d d„Zdd d    „Zd d
„Zdd d d „Zd d „ZRS(s¯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.'
        >>>
        R cCs;||_||_t|_tj||||||ƒdS(N(tkeyfiletcertfiletFalset_prot_pRR(RRRRRR®R¯R ((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyRzs            cCs?|r)t|jtjƒ r)|jƒntj||||ƒS(N(t
isinstanceRtsslt    SSLSockettauthRR(RRRRtsecure((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyRs cCst|jtjƒr$tdƒ‚n|jtjkrH|jdƒ}n|jdƒ}tj|j|j    |j
d|jƒ|_|jj ddƒ|_ |S(s2Set up secure control connection by using TLS/SSL.sAlready using TLSsAUTH TLSsAUTH SSLt ssl_versiontmodeR( R²RR³R´R¡R·tPROTOCOL_TLSv1RJt wrap_socketR®R¯RR(RR?((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyRµ†scCs)|jdƒ|jdƒ}t|_|S(sSet up secure data connection.sPBSZ 0sPROT P(RJtTrueR±(RR?((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytprot_p“s     cCs|jdƒ}t|_|S(s"Set up clear text data connection.sPROT C(RJR°R±(RR?((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytprot_c£s    cCsUtj|||ƒ\}}|jrKtj||j|jd|jƒ}n||fS(NR·(RRvR±R³RºR®R¯R·(RRHRrRtRs((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyRv«s
    i cCsƒ|jdƒ|j||ƒ}zLx&|j|ƒ}|s>Pn||ƒq%t|tjƒrj|jƒnWd|jƒX|jƒS(NsTYPE I(    RJRwRyR²R³R´tunwrapR^RA(RRHRzR{RrRtR|((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyR}²s   cCs|dkrt}n|jdƒ}|j|ƒ}|jdƒ}z¤x~|jƒ}|jdkrudGt|ƒGHn|sPn|dtkrœ|d }n|ddkr¹|d }n||ƒqHt    |t
j ƒrå|j ƒnWd|j ƒ|j ƒX|jƒS(NsTYPE ARis*retr*iþÿÿÿiÿÿÿÿs
(RXR~RIRwRR2R R*R-R²R³R´R¾R^RA(RRHRzR?RtRR/((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyR€Âs,        
 cCs™|jdƒ|j||ƒ}zbx<|j|ƒ}|s>Pn|j|ƒ|r%||ƒq%q%t|tjƒr€|jƒnWd|jƒX|j    ƒS(NsTYPE I(
RJRwRR.R²R³R´R¾R^RA(RRHRR{RzRrRtR‚((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyRƒÚs   cCsÍ|jdƒ|j|ƒ}z™xs|jƒ}|s8Pn|dtkrr|dtkre|d }n|t}n|j|ƒ|r"||ƒq"q"t|tjƒr´|jƒnWd|j    ƒX|j
ƒS(NsTYPE Aiþÿÿÿiÿÿÿÿ( RJRwR2R-R.R²R³R´R¾R^RA(RRHRRzRtR‚((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyR„ês$      N(RRRªR³R¹R·RXRRR»RRµR¼R½RvR}R€RƒR„(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyR­Ws                   cCs§|d dkrt|‚ntdkrLddl}|jd|jƒantj|ƒ}|sedS|jdƒ}yt|ƒSWnt    t
fk
r¢t |ƒSXdS(sž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.
    iRoiÿÿÿÿNs150 .* \((\d+) bytes\)i( Rt_150_reRXtretcompilet
IGNORECASEtmatchtgroupRŸR R¡R¢(R?RÀtmR+((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyRqs   cCs²|d dkrt|‚ntdkrFddl}|jdƒantj|ƒ}|sgt|‚n|jƒ}dj|d ƒ}t    |dƒd>t    |d    ƒ}||fS(
s¢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.it227iÿÿÿÿNs#(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)RKiii(
Rt_227_reRXRÀRÁtsearchR
tgroupsRNRŸ(R?RÀRÅtnumbersRR((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyRks     "cCsý|d dkrt|‚n|jdƒ}|dkrCt|‚n|jd|dƒ}|dkrqt|‚n||d||dkr™t|‚n||d|!j||dƒ}t|ƒdkrÙt|‚n|d}t|dƒ}||fS(s™Parse the '229' response for a EPSV request.
    Raises error_proto if it does not contain '(|||port|)'
    Return ('host.addr.as.numbers', port#) tuple.it229t(it)ii(RtfindR
RMR)RŸ(R?tpeertlefttrighttpartsRR((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyRl.s      " 
cCs¹|d dkrt|‚n|dd!dkr3dSd}d}t|ƒ}xg||kr´||}|d}|dkr§||ks–||dkršPn|d}n||}qNW|S(s¤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.it257is "R it"(RR)(R?RšR,tnR@((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyR£Ds   
 
  cCs    |GHdS(s+Default retrlines callback to print a line.N((R/((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyR~[sR tIc    CsÎ|s|}nd|}|j|ƒ|j|ƒt|jdƒƒ\}}|j||ƒ|jd|ƒ}|d d    krŠt‚n|jd|ƒ}|d d
kr¶t‚n|jƒ|jƒdS( s+Copy file from one FTP-instance to another.sTYPE RisSTOR it125RosRETR N(R×s150(R×s150(RJRkRIRRR
RA(    tsourcet
sourcenamettargett
targetnameRŽt
sourcehostt
sourceportttreplytsreply((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pytftpcp`s    
          
cBsPeZdZdZdZdZdd„Zd„Zd„Z    d„Z
d„Z RS(sÃ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ã|dkrFdtjkr:tjjtjddƒ}qFtd‚ni|_i|_t|dƒ}d}xe|j    ƒ}|s†Pn|r«|j
ƒr«|j |ƒqpn"|rÍt |ƒ|j|<d}n|j ƒ}d}}    }
} d} d} x.| t|ƒkr'|| }| dt|ƒkr=|| d}nd}|dkrXd} nÂ|dkrƒ|rƒ|jƒ}| d} n—|d    kr¨|r¨|}    | d} nr|d
krÍ|rÍ|}
| d} nM|d krò|rò|} | d} n(|d kr|r|}g}d}Pn| d} qúW| rg|    p:|j|_|
pL|j|_| p^|j|_n|rp||jkr¹|j|\}}}|    p›|}    |
p§|}
| p³|} n|    |
| f|j|<qpqp|jƒdS( NtHOMEs.netrcs!specify file to load or set $HOMEtriitdefaulttmachineRR…taccounttmacdef(RXtostenvirontpathRNtIOErrort _Netrc__hostst_Netrc__macrostopenR2RžRˆttupleRMR)tlowert_Netrc__defusert_Netrc__defpasswdt_Netrc__defacctR^(RR–Rtin_macroR/t macro_linest
macro_nametwordsRRRRRãR,tw1tw2tousertopasswdtoacct((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyRsz                     
            cCs |jjƒS(s4Return a list of hosts mentioned in the .netrc file.(Rëtkeys(R((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyt    get_hostsÀscCs||jƒ}d}}}||jkrB|j|\}}}n|pN|j}|p]|j}|pl|j}|||fS(sœReturns login information for the named host.
 
        The return value is a triple containing userid,
        password, and the accounting field.
 
        N(RïRXRëRðRñRò(RRRRR((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyt get_accountÄs cCs |jjƒS(s)Return a list of all defined macro names.(RìRü(R((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyt
get_macrosÔscCs |j|S(s6Return a sequence of lines which define a named macro.(Rì(Rtmacro((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyt    get_macroØsN( RRRªRXRðRñRòRRýRþRÿR(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyRss A            c Cs4ttjƒdkr-tjGHtjdƒnd}d}x+tjddkrf|d}tjd=q<Wtjdd dkrœtjdd}tjd=ntjd}t|ƒ}|j|ƒd}}}yt    |ƒ}Wn0t
k
r|dk    rStj j dƒqSnAXy|j |ƒ\}}}Wn!tk
rRtj j dƒnX|j|||ƒx½tjdD]®}|d d    krž|j|dƒqt|d dkråd
}    |drÓ|    d |d}    n|j|    ƒ}
qt|d kr|j|j ƒqt|jd |tjj dƒqtW|jƒdS(s‚Test program.
    Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...
 
    -d dir
    -l list
    -p password
    iiis-ds-rR s5Could not open account file -- using anonymous login.s$No account -- using anonymous login.s-ltCWDR‡s-psRETR iN(R)tsystargvttestRªtexitRXRR$RRêtstderrtwriteRþtKeyErrorRRRIR'R%R}tstdoutR©( R trcfileRtftptuseridRRtnetrcRRHR?((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyRÞsN    
            
  t__main__(&RªRçRtSOCKSRRt ImportErrorRt__all__RFR«t    ExceptionRRRR    R
RêR3t
all_errorsR-RR³R­RˆtSSLErrorRXR¿RqRÇRkRlR£R~RàRRR(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ftplib.pyt<module>sX
        ÿÿ ¦                     k    7