/snap/core18/2999/usr/lib/python3.6/__pycache__
NameSizeModeActions
abc.cpython-36.pyc75150644editdlrm
aifc.cpython-36.pyc259430644editdlrm
antigravity.cpython-36.pyc7790644editdlrm
argparse.cpython-36.pyc604560644editdlrm
ast.cpython-36.pyc117040644editdlrm
asynchat.cpython-36.pyc68150644editdlrm
asyncore.cpython-36.pyc158380644editdlrm
base64.cpython-36.pyc170590644editdlrm
bdb.cpython-36.pyc170330644editdlrm
binhex.cpython-36.pyc120860644editdlrm
bisect.cpython-36.pyc26760644editdlrm
bz2.cpython-36.pyc112820644editdlrm
calendar.cpython-36.pyc258820644editdlrm
cgi.cpython-36.pyc284160644editdlrm
cgitb.cpython-36.pyc100800644editdlrm
chunk.cpython-36.pyc49000644editdlrm
cmd.cpython-36.pyc125750644editdlrm
code.cpython-36.pyc98360644editdlrm
codecs.cpython-36.pyc339000644editdlrm
codeop.cpython-36.pyc62700644editdlrm
colorsys.cpython-36.pyc33110644editdlrm
compileall.cpython-36.pyc82780644editdlrm
configparser.cpython-36.pyc452440644editdlrm
contextlib.cpython-36.pyc111580644editdlrm
copy.cpython-36.pyc70790644editdlrm
copyreg.cpython-36.pyc42440644editdlrm
cProfile.cpython-36.pyc42940644editdlrm
crypt.cpython-36.pyc22420644editdlrm
csv.cpython-36.pyc118550644editdlrm
datetime.cpython-36.pyc545110644editdlrm
decimal.cpython-36.pyc3510644editdlrm
difflib.cpython-36.pyc596420644editdlrm
dis.cpython-36.pyc141810644editdlrm
doctest.cpython-36.pyc755890644editdlrm
dummy_threading.cpython-36.pyc11020644editdlrm
enum.cpython-36.pyc234530644editdlrm
filecmp.cpython-36.pyc83050644editdlrm
fileinput.cpython-36.pyc131520644editdlrm
fnmatch.cpython-36.pyc28740644editdlrm
formatter.cpython-36.pyc175790644editdlrm
fractions.cpython-36.pyc184260644editdlrm
ftplib.cpython-36.pyc283570644editdlrm
functools.cpython-36.pyc240620644editdlrm
genericpath.cpython-36.pyc37260644editdlrm
getopt.cpython-36.pyc62170644editdlrm
getpass.cpython-36.pyc41770644editdlrm
gettext.cpython-36.pyc143060644editdlrm
glob.cpython-36.pyc42590644editdlrm
gzip.cpython-36.pyc162260644editdlrm
hashlib.cpython-36.pyc66920644editdlrm
heapq.cpython-36.pyc142920644editdlrm
hmac.cpython-36.pyc48360644editdlrm
imaplib.cpython-36.pyc421380644editdlrm
imghdr.cpython-36.pyc41500644editdlrm
imp.cpython-36.pyc96960644editdlrm
inspect.cpython-36.pyc797390644editdlrm
io.cpython-36.pyc33870644editdlrm
ipaddress.cpython-36.pyc623860644editdlrm
keyword.cpython-36.pyc17650644editdlrm
linecache.cpython-36.pyc37780644editdlrm
locale.cpython-36.pyc340300644editdlrm
lzma.cpython-36.pyc119920644editdlrm
macpath.cpython-36.pyc56410644editdlrm
macurl2path.cpython-36.pyc18670644editdlrm
mailbox.cpython-36.pyc637520644editdlrm
mailcap.cpython-36.pyc72090644editdlrm
mimetypes.cpython-36.pyc155530644editdlrm
modulefinder.cpython-36.pyc153660644editdlrm
netrc.cpython-36.pyc38360644editdlrm
nntplib.cpython-36.pyc337800644editdlrm
ntpath.cpython-36.pyc131900644editdlrm
nturl2path.cpython-36.pyc14990644editdlrm
numbers.cpython-36.pyc121420644editdlrm
opcode.cpython-36.pyc54130644editdlrm
operator.cpython-36.pyc139130644editdlrm
optparse.cpython-36.pyc480540644editdlrm
os.cpython-36.pyc296280644editdlrm
pathlib.cpython-36.pyc420070644editdlrm
pdb.cpython-36.pyc460940644editdlrm
pickle.cpython-36.pyc426910644editdlrm
pickletools.cpython-36.pyc660200644editdlrm
pipes.cpython-36.pyc78080644editdlrm
pkgutil.cpython-36.pyc162610644editdlrm
platform.cpython-36.pyc291970644editdlrm
plistlib.cpython-36.pyc280550644editdlrm
poplib.cpython-36.pyc133290644editdlrm
posixpath.cpython-36.pyc104560644editdlrm
pprint.cpython-36.pyc158240644editdlrm
profile.cpython-36.pyc139010644editdlrm
pstats.cpython-36.pyc218570644editdlrm
pty.cpython-36.pyc38610644editdlrm
pyclbr.cpython-36.pyc83650644editdlrm
pydoc.cpython-36.pyc837750644editdlrm
py_compile.cpython-36.pyc65440644editdlrm
queue.cpython-36.pyc87550644editdlrm
quopri.cpython-36.pyc57730644editdlrm
random.cpython-36.pyc193300644editdlrm
re.cpython-36.pyc140580644editdlrm
reprlib.cpython-36.pyc54000644editdlrm
rlcompleter.cpython-36.pyc57800644editdlrm
runpy.cpython-36.pyc79820644editdlrm
sched.cpython-36.pyc65640644editdlrm
secrets.cpython-36.pyc21620644editdlrm
selectors.cpython-36.pyc176970644editdlrm
shelve.cpython-36.pyc94580644editdlrm
shlex.cpython-36.pyc69700644editdlrm
shutil.cpython-36.pyc307040644editdlrm
signal.cpython-36.pyc25150644editdlrm
site.cpython-36.pyc165600644editdlrm
sitecustomize.cpython-36.pyc2120644editdlrm
smtpd.cpython-36.pyc266830644editdlrm
smtplib.cpython-36.pyc353400644editdlrm
sndhdr.cpython-36.pyc69130644editdlrm
socket.cpython-36.pyc220130644editdlrm
socketserver.cpython-36.pyc242500644editdlrm
sre_compile.cpython-36.pyc102780644editdlrm
sre_constants.cpython-36.pyc59720644editdlrm
sre_parse.cpython-36.pyc203580644editdlrm
ssl.cpython-36.pyc369390644editdlrm
stat.cpython-36.pyc38510644editdlrm
statistics.cpython-36.pyc181740644editdlrm
string.cpython-36.pyc79640644editdlrm
stringprep.cpython-36.pyc100300644editdlrm
struct.cpython-36.pyc3120644editdlrm
subprocess.cpython-36.pyc354850644editdlrm
sunau.cpython-36.pyc169380644editdlrm
symbol.cpython-36.pyc25170644editdlrm
symtable.cpython-36.pyc104280644editdlrm
sysconfig.cpython-36.pyc159160644editdlrm
tabnanny.cpython-36.pyc69750644editdlrm
tarfile.cpython-36.pyc630850644editdlrm
telnetlib.cpython-36.pyc180970644editdlrm
tempfile.cpython-36.pyc253090644editdlrm
textwrap.cpython-36.pyc136840644editdlrm
this.cpython-36.pyc12650644editdlrm
threading.cpython-36.pyc372340644editdlrm
timeit.cpython-36.pyc116030644editdlrm
token.cpython-36.pyc33200644editdlrm
tokenize.cpython-36.pyc186470644editdlrm
trace.cpython-36.pyc194950644editdlrm
traceback.cpython-36.pyc196460644editdlrm
tracemalloc.cpython-36.pyc172290644editdlrm
tty.cpython-36.pyc10720644editdlrm
turtle.cpython-36.pyc1317510644editdlrm
types.cpython-36.pyc82010644editdlrm
typing.cpython-36.pyc733060644editdlrm
uu.cpython-36.pyc34980644editdlrm
uuid.cpython-36.pyc209180644editdlrm
warnings.cpython-36.pyc132580644editdlrm
wave.cpython-36.pyc178850644editdlrm
weakref.cpython-36.pyc191430644editdlrm
webbrowser.cpython-36.pyc157970644editdlrm
xdrlib.cpython-36.pyc83020644editdlrm
zipapp.cpython-36.pyc55340644editdlrm
zipfile.cpython-36.pyc497280644editdlrm
_bootlocale.cpython-36.pyc9800644editdlrm
_collections_abc.cpython-36.pyc287970644editdlrm
_compat_pickle.cpython-36.pyc65660644editdlrm
_compression.cpython-36.pyc41040644editdlrm
_dummy_thread.cpython-36.pyc48510644editdlrm
_markupbase.cpython-36.pyc79910644editdlrm
_osx_support.cpython-36.pyc96840644editdlrm
_pydecimal.cpython-36.pyc1634020644editdlrm
_pyio.cpython-36.pyc713860644editdlrm
_sitebuiltins.cpython-36.pyc34350644editdlrm
_strptime.cpython-36.pyc159630644editdlrm
_sysconfigdata_m_linux_x86_64-linux-gnu.cpython-36.pyc187790644editdlrm
_threading_local.cpython-36.pyc64250644editdlrm
_weakrefset.cpython-36.pyc78280644editdlrm
__future__.cpython-36.pyc41670644editdlrm
__phello__.foo.cpython-36.pyc1190644editdlrm
Edit: /snap/core18/2999/usr/lib/python3.6/__pycache__/ftplib.cpython-36.pyc (28357B)
3 Nqi! @sVdZddlZddlZddlmZdddddd gZd Zd Zd ZGd ddeZ Gddde Z Gddde Z Gddde Z Gddde Z e eefZdZdZGdddZy ddlZWnek rdZYn0XejZGdddeZejde eeejfZdaddZdaddZddZddZ d d!Z!d)d$d%Z"d&d'Z#e$d(krRe#dS)*aSAn 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 N)_GLOBAL_DEFAULT_TIMEOUTFTP error_reply error_temp error_perm error_proto all_errorsi c@s eZdZdS)ErrorN)__name__ __module__ __qualname__rr/usr/lib/python3.6/ftplib.pyr 9sr c@s eZdZdS)rN)r r rrrrrr:sc@s eZdZdS)rN)r r rrrrrr;sc@s eZdZdS)rN)r r rrrrrr<sc@s eZdZdS)rN)r r rrrrrr=sz s c@seZdZdZdZdZeZeZ dZ dZ dZ dZ dZdZddddedfdd Zd d Zd d Zd]ddZddZddZeZddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Z d'd(Z!d)d*Z"d+d,Z#d-d.Z$d/d0Z%d1d2Z&d^d3d4Z'd_d5d6Z(d`d7d8Z)dad:d;Z*dbdd?Z,ddd@dAZ-dBdCZ.dDdEZ/dFdGZ0dgfdHdIZ1dJdKZ2dLdMZ3dNdOZ4dPdQZ5dRdSZ6dTdUZ7dVdWZ8dXdYZ9dZd[Z:dS)erayAn 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. rNr zlatin-1FcCs0||_||_|r,|j||r,|j|||dS)N)source_addresstimeoutconnectlogin)selfhostuserpasswdacctrrrrr__init__rs  z FTP.__init__cCs|S)Nr)rrrr __enter__{sz FTP.__enter__cGsN|jdk rJz*y |jWnttfk r0YnXWd|jdk rH|jXdS)N)sockquitOSErrorEOFErrorclose)rargsrrr__exit__s    z FTP.__exit__icCs|dkr||_|dkr||_|dkr*||_|dk r8||_tj|j|jf|j|jd|_|jj|_|jj d|j d|_ |j |_ |j S) awConnect to host. Arguments are: - host: hostname to connect to (string, default previous host) - port: port to connect to (integer, default previous port) - timeout: the timeout to set against the ftp socket(s) - source_address: a 2-tuple (host, port) for the socket to bind to as its source address before connecting. rriN)rr)encodingi)rportrrsocketcreate_connectionrZfamilyafmakefiler%filegetrespwelcome)rrr&rrrrrrs   z FTP.connectcCs|jrtd|j|j|jS)z`Get the welcome message from the server. (this is read and squirreled away by connect())z *welcome*) debuggingprintsanitizer-)rrrr getwelcomeszFTP.getwelcomecCs ||_dS)zSet 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.)rlevelrrrset_debuglevelszFTP.set_debuglevelcCs ||_dS)zUse 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) passiveserver)rvalrrrset_pasvsz FTP.set_pasvcCsJ|dddkrBt|jd}|ddd|d||d}t|S)Npass PASS z *>r8r9)lenrstriprepr)rsirrrr0s$z FTP.sanitizecCsRd|ksd|krtd|t}|jdkr:td|j||jj|j|jdS)N  z4an illegal newline character should not be containedr z*put*) ValueErrorCRLFr.r/r0rsendallencoder%)rlinerrrputlines  z FTP.putlinecCs$|jrtd|j||j|dS)Nz*cmd*)r.r/r0rG)rrFrrrputcmdsz FTP.putcmdcCs|jj|jd}t||jkr.td|j|jdkrHtd|j||sPt|ddt krn|dd}n|ddt kr|dd}|S) Nr zgot more than %d bytesz*get*rJrK) r+readlinemaxliner;r r.r/r0r rC)rrFrrrgetlines  z FTP.getlinecCsd|j}|dddkr`|dd}x:|j}|d|}|dd|kr&|dddkr&Pq&W|S)N-rA)rN)rrFcodeZnextlinerrr getmultilines  zFTP.getmultilinecCsp|j}|jrtd|j||dd|_|dd}|d krD|S|dkrTt||dkrdt|t|dS) Nz*resp*rOr 12345>rVrUrT)rSr.r/r0Zlastresprrr)rrespcrrrr,s z FTP.getrespcCs$|j}|dddkr t||S)z%Expect a response beginning with '2'.Nr rU)r,r)rrYrrrvoidrespsz FTP.voidrespcCsTdt}|jdkr"td|j||jj|t|j}|ddd krPt||S) zAbort 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.sABORr z *put urgent*NrO426225226>r]r\r^) B_CRLFr.r/r0rrDMSG_OOBrSr)rrFrYrrraborts z FTP.abortcCs|j||jS)z'Send a command and return the response.)rHr,)rcmdrrrsendcmds z FTP.sendcmdcCs|j||jS)z8Send a command and expect a response beginning with '2'.)rHr[)rrbrrrvoidcmds z FTP.voidcmdcCsB|jd}t|dt|dg}||}ddj|}|j|S)zUSend a PORT command with the current host and the given port number. .zPORT ,)splitr=joinrd)rrr&ZhbytesZpbytesbytesrbrrrsendports  z FTP.sendportcCsbd}|jtjkrd}|jtjkr$d}|dkr4tddt||t|dg}ddj|}|j|S)zESend an EPRT command with the current host and the given port number.rr rIzunsupported address familyrzEPRT |)r)r'AF_INETZAF_INET6rr=rird)rrr&r)Zfieldsrbrrrsendeprt$s  z FTP.sendeprtc Csd}d}xtjdd|jtjdtjD]j}|\}}}}}ytj|||}|j|Wn8tk r} z| }|rt|jd}w$WYdd} ~ XnXPq$W|dkr|dk r|ntd|jd|j d} |j j d} |jtj kr|j | | } n |j | | } |jtk r|j|j|S)z3Create a new socket and send a PORT command for it.Nrz!getaddrinfo returns an empty listr )r'Z getaddrinfor)Z SOCK_STREAMZ AI_PASSIVEZbindrr!ZlistenZ getsocknamerrmrkrnrr settimeout) rerrrZresr)ZsocktypeprotoZ canonnameZsa_r&rrYrrrmakeport1s6       z FTP.makeportcCs\|jtjkr:t|jd\}}|jr*|}qT|jjd}nt|jd|jj\}}||fS)z (address, port)PASVrZEPSV) r)r'rmparse227rctrust_server_pasv_ipv4_addressrZ getpeernameparse229)rZuntrusted_hostr&rrrrmakepasvQs z FTP.makepasvc Cs6d}|jr|j\}}tj||f|j|jd}yL|dk rF|jd||j|}|ddkrd|j}|ddkrxt|Wn|j YnXn|j r}|dk r|jd||j|}|ddkr|j}|ddkrt||j \}} |jt k r |j |jWdQRX|dddkr.t|}||fS) aInitiate 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. N)rzREST %srrUrTrO150)r4rxr'r(rrrcr,rr!rsZacceptrroparse150) rrbrestsizerr&connrYrZsockaddrrrr ntransfercmd]s<             zFTP.ntransfercmdcCs|j||dS)z0Like ntransfercmd() but returns only the socket.r)r~)rrbr{rrr transfercmdszFTP.transfercmdcCs|sd}|sd}|sd}|dkr0|d kr0|d}|jd|}|ddkrX|jd|}|ddkrr|jd |}|dd krt||S) zLogin, default anonymous.Z anonymousrrQz anonymous@zUSER rrVzPASS zACCT rU>rrQ)rcr)rrrrrYrrrrs    z FTP.login c Csb|jd|j||>}x|j|}|s*P||qWtdk rPt|trP|jWdQRX|jS)aRetrieve 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. zTYPE IN)rdrZrecv _SSLSocket isinstanceunwrapr[)rrbcallback blocksizer{r}datarrr retrbinarys   zFTP.retrbinarycCs|dkr t}|jd}|j|}|jd|jd}x|j|jd}t||jkrbtd|j|j dkrzt dt ||sP|d dt kr|dd }n|d dd kr|dd }||q6Wt dk rt|t r|jWdQRXWdQRX|jS)ahRetrieve 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. NzTYPE Ar$)r%r zgot more than %d bytesrIz*retr*rArJrJrKrK) print_linercrr*r%rLrMr;r r.r/r=rCrrrr[)rrbrrYr}fprFrrr retrliness*      z FTP.retrlinesc Csp|jd|j||L}x*|j|}|s*P|j||r||qWtdk r^t|tr^|jWdQRX|jS)a9Store 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. zTYPE IN)rdrreadrDrrrr[)rrbrrrr{r}bufrrr storbinarys    zFTP.storbinaryc Cs|jd|j|}x||j|jd}t||jkrDtd|j|sJP|ddtkrz|dtkrr|dd}|t}|j||r||qWtdk rt |tr|j WdQRX|j S) ahStore 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. zTYPE Ar zgot more than %d bytesrINrJrKrK) rdrrLrMr;r r_rDrrrr[)rrbrrr}rrrr storlines s$     z FTP.storlinescCsd|}|j|S)zSend new account name.zACCT )rd)rZpasswordrbrrrr+szFTP.acctcGs4d}x|D]}|d|}q Wg}|j||j|S)zBReturn a list of files in a given directory (default the current).ZNLST )rappend)rr"rbargZfilesrrrnlst0s  zFTP.nlstcGsld}d}|ddr>t|dtdkr>|dd|d }}x|D]}|rD|d|}qDW|j||dS) aList 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.)ZLISTNr rrrKrKrKrK)typer)rr"rbfuncrrrrdir9s  zFTP.dirc cs|r|jddj|d|r*d|}nd}g}|j||jxh|D]`}|jtjd\}}}i} x6|dd jdD] } | jd\} }} | | | j<qxW|| fVqFWdS) a<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. z OPTS MLST ;zMLSD %sZMLSDrNr =rK) rcrirrr<rC partitionrhlower) rpathZfactsrblinesrFZ facts_foundrrnameentryZfactkeyvaluerrrmlsdHs   zFTP.mlsdcCs0|jd|}|ddkr"t||jd|S)zRename a file.zRNFR rrVzRNTO )rcrrd)rZfromnameZtonamerYrrrrenameds z FTP.renamecCs.|jd|}|dddkr"|St|dS)zDelete a file.zDELE NrO250200>rr)rcr)rfilenamerYrrrdeleteksz FTP.deletecCsn|dkrPy |jdStk rL}z|jddddkr<WYdd}~Xq\Xn |dkr\d}d |}|j|S) zChange to a directory.z..ZCDUPrNrO500rrezCWD )rdrr")rdirnamemsgrbrrrcwdss zFTP.cwdcCs:|jd|}|dddkr6|ddj}t|SdS)zRetrieve the size of a file.zSIZE NrOZ213)rcstripint)rrrYr>rrrr|szFTP.sizecCs$|jd|}|jdsdSt|S)z+Make a directory, return its full pathname.zMKD 257r)rd startswithparse257)rrrYrrrmkds zFTP.mkdcCs|jd|S)zRemove a directory.zRMD )rd)rrrrrrmdszFTP.rmdcCs |jd}|jdsdSt|S)z!Return current working directory.ZPWDrr)rdrr)rrYrrrpwds  zFTP.pwdcCs|jd}|j|S)zQuit, and close the connection.ZQUIT)rdr!)rrYrrrrs zFTP.quitc CsDz |j}d|_|dk r|jWd|j}d|_|dk r>|jXdS)z8Close the connection without assuming anything about it.N)r+r!r)rr+rrrrr!s z FTP.close)rrrN)N)N)rrr)rN)N)rNN)N);r r r__doc__r.rFTP_PORTr&MAXLINErMrr+r-r4r%rvrrrr#rr1r3debugr6r0rGrHrNrSr,r[rarcrdrkrnrsrxr~rrrrrrrrrrrrrr|rrrrr!rrrrrJsl      7    #      c @sneZdZdZejZdddddddedf ddZdddZ d d Z d d Z d dZ ddZ dddZddZdS)FTP_TLSaA 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.' >>> rNc Cs|dk r|dk rtd|dk r0|dk r0td|dk s@|dk rVddl} | jdtd||_||_|dkr|tj|j||d}||_ d|_ t j ||||||| dS)Nz4context and keyfile arguments are mutually exclusivez5context and certfile arguments are mutually exclusiverzAkeyfile and certfile are deprecated, use a custom context insteadrI)certfilekeyfileF) rBwarningswarnDeprecationWarningrrsslZ_create_stdlib_context ssl_versioncontext_prot_prr) rrrrrrrrrrrrrrrs"zFTP_TLS.__init__TcCs,|rt|jtj r|jtj||||S)N)rrr SSLSocketauthrr)rrrrZsecurerrrrsz FTP_TLS.logincCsft|jtjrtd|jtjkr.|jd}n |jd}|jj |j|j d|_|jj d|j d|_ |S)z2Set up secure control connection by using TLS/SSL.zAlready using TLSzAUTH TLSzAUTH SSL)server_hostnamer$)moder%)rrrrrBrPROTOCOL_SSLv23rdr wrap_socketrr*r%r+)rrYrrrrs     z FTP_TLS.authcCs0t|jtjstd|jd}|jj|_|S)z/Switch back to a clear-text control connection.z not using TLSZCCC)rrrrrBrdr)rrYrrrcccs   z FTP_TLS.ccccCs|jd|jd}d|_|S)zSet up secure data connection.zPBSZ 0zPROT PT)rdr)rrYrrrprot_p s  zFTP_TLS.prot_pcCs|jd}d|_|S)z"Set up clear text data connection.zPROT CF)rdr)rrYrrrprot_cs zFTP_TLS.prot_ccCs2tj|||\}}|jr*|jj||jd}||fS)N)r)rr~rrrr)rrbr{r}r|rrrr~$s  zFTP_TLS.ntransfercmdcCs8dt}|jj||j}|dddkr4t||S)NsABORrOr\r]r^>r]r\r^)r_rrDrSr)rrFrYrrrra+s  z FTP_TLS.abort)rrrT)N)r r rrrrrrrrrrrrr~rarrrrrs     rcCs\|dddkrt|tdkrt |d }||fS) zParse 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.NrOZ227rz#(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)rerPr7) r_227_rerrrsearchrgroupsrir)rYrrZnumbersrr&rrrruNs rucCs|dddkrt||jd}|dkr2t||jd|d}|dkrRt|||d||dkrrt|||d|j||d}t|dkrt||d}t|d}||fS) zParse the '229' response for an EPSV request. Raises error_proto if it does not contain '(|||port|)' Return ('host.addr.as.numbers', port#) tuple.NrOZ229(r)r r7)rfindrrhr;r)rYZpeerleftrightpartsrr&rrrrwbs    rwcCs|dddkrt||dddkr,dSd}d}t|}xJ||kr||}|d}|dkr|||ksr||dkrtP|d}||}q>W|S) zParse 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.NrOrr7z "rr ")rr;)rYrr?nrZrrrrxs   rcCs t|dS)z+Default retrlines callback to print a line.N)r/)rFrrrrsrrIc Cs|s|}d|}|j||j|t|jd\}}|j|||jd|}|ddd krdt|jd|}|ddd krt|j|jdS) z+Copy file from one FTP-instance to another.zTYPE rtzSTOR NrO125ryzRETR >ryr>ryr)rdrurcrkrr[) sourceZ sourcenametargetZ targetnamerZ sourcehostZ sourceportZtreplyZsreplyrrrftpcps   rc Csttjdkr"ttjtjdddl}d}d}x"tjddkrT|d}tjd=q4Wtjddddkrtjddd}tjd=tjd}t|}|j |d}}}y|j|}Wn(t k r|dk rtj j dYn:Xy|j |\}}}Wn"tk rtj j d YnX|j|||xtjddD]} | ddd krf|j| ddnt| dddkrd } | ddr| d | dd} |j| } n0| d kr|j|j n|jd| tjj dqsP    k  |  9