/snap/core22/2437/usr/lib/python3.10/__pycache__
NameSizeModeActions
abc.cpython-310.pyc67510644editdlrm
aifc.cpython-310.pyc246850644editdlrm
antigravity.cpython-310.pyc8220644editdlrm
argparse.cpython-310.pyc635390644editdlrm
ast.cpython-310.pyc557390644editdlrm
asynchat.cpython-310.pyc70250644editdlrm
asyncore.cpython-310.pyc160020644editdlrm
base64.cpython-310.pyc171620644editdlrm
bdb.cpython-310.pyc258320644editdlrm
binhex.cpython-310.pyc128700644editdlrm
bisect.cpython-310.pyc25880644editdlrm
bz2.cpython-310.pyc108700644editdlrm
calendar.cpython-310.pyc263030644editdlrm
cgi.cpython-310.pyc267230644editdlrm
cgitb.cpython-310.pyc99980644editdlrm
chunk.cpython-310.pyc48600644editdlrm
cmd.cpython-310.pyc127070644editdlrm
code.cpython-310.pyc99570644editdlrm
codecs.cpython-310.pyc332190644editdlrm
codeop.cpython-310.pyc55950644editdlrm
colorsys.cpython-310.pyc32650644editdlrm
compileall.cpython-310.pyc127330644editdlrm
configparser.cpython-310.pyc454580644editdlrm
contextlib.cpython-310.pyc208950644editdlrm
contextvars.cpython-310.pyc2460644editdlrm
copy.cpython-310.pyc69960644editdlrm
copyreg.cpython-310.pyc46830644editdlrm
cProfile.cpython-310.pyc51130644editdlrm
crypt.cpython-310.pyc35500644editdlrm
csv.cpython-310.pyc117980644editdlrm
dataclasses.cpython-310.pyc265780644editdlrm
datetime.cpython-310.pyc565330644editdlrm
decimal.cpython-310.pyc3620644editdlrm
difflib.cpython-310.pyc589050644editdlrm
dis.cpython-310.pyc156560644editdlrm
doctest.cpython-310.pyc761750644editdlrm
enum.cpython-310.pyc260630644editdlrm
filecmp.cpython-310.pyc87490644editdlrm
fileinput.cpython-310.pyc140720644editdlrm
fnmatch.cpython-310.pyc42440644editdlrm
fractions.cpython-310.pyc186000644editdlrm
ftplib.cpython-310.pyc289770644editdlrm
functools.cpython-310.pyc283350644editdlrm
genericpath.cpython-310.pyc39070644editdlrm
getopt.cpython-310.pyc63390644editdlrm
getpass.cpython-310.pyc42100644editdlrm
gettext.cpython-310.pyc182210644editdlrm
glob.cpython-310.pyc58520644editdlrm
graphlib.cpython-310.pyc76160644editdlrm
gzip.cpython-310.pyc185460644editdlrm
hashlib.cpython-310.pyc68450644editdlrm
heapq.cpython-310.pyc138650644editdlrm
hmac.cpython-310.pyc69730644editdlrm
imaplib.cpython-310.pyc423120644editdlrm
imghdr.cpython-310.pyc39050644editdlrm
imp.cpython-310.pyc97860644editdlrm
inspect.cpython-310.pyc851530644editdlrm
io.cpython-310.pyc36630644editdlrm
ipaddress.cpython-310.pyc626700644editdlrm
keyword.cpython-310.pyc9270644editdlrm
linecache.cpython-310.pyc41420644editdlrm
locale.cpython-310.pyc461540644editdlrm
lzma.cpython-310.pyc121000644editdlrm
mailbox.cpython-310.pyc600910644editdlrm
mailcap.cpython-310.pyc73200644editdlrm
mimetypes.cpython-310.pyc176190644editdlrm
modulefinder.cpython-310.pyc161660644editdlrm
netrc.cpython-310.pyc39330644editdlrm
nntplib.cpython-310.pyc316230644editdlrm
ntpath.cpython-310.pyc147040644editdlrm
nturl2path.cpython-310.pyc17470644editdlrm
numbers.cpython-310.pyc118660644editdlrm
opcode.cpython-310.pyc54470644editdlrm
operator.cpython-310.pyc135080644editdlrm
optparse.cpython-310.pyc477540644editdlrm
os.cpython-310.pyc315990644editdlrm
pathlib.cpython-310.pyc420520644editdlrm
pdb.cpython-310.pyc474400644editdlrm
pickle.cpython-310.pyc468820644editdlrm
pickletools.cpython-310.pyc677600644editdlrm
pipes.cpython-310.pyc77690644editdlrm
pkgutil.cpython-310.pyc183610644editdlrm
platform.cpython-310.pyc274290644editdlrm
plistlib.cpython-310.pyc237650644editdlrm
poplib.cpython-310.pyc135730644editdlrm
posixpath.cpython-310.pyc105600644editdlrm
pprint.cpython-310.pyc178750644editdlrm
profile.cpython-310.pyc143910644editdlrm
pstats.cpython-310.pyc236210644editdlrm
pty.cpython-310.pyc41430644editdlrm
pyclbr.cpython-310.pyc97750644editdlrm
pydoc.cpython-310.pyc856450644editdlrm
py_compile.cpython-310.pyc73390644editdlrm
queue.cpython-310.pyc107920644editdlrm
quopri.cpython-310.pyc57940644editdlrm
random.cpython-310.pyc227480644editdlrm
re.cpython-310.pyc142270644editdlrm
reprlib.cpython-310.pyc52500644editdlrm
rlcompleter.cpython-310.pyc59540644editdlrm
runpy.cpython-310.pyc94110644editdlrm
sched.cpython-310.pyc61150644editdlrm
secrets.cpython-310.pyc21750644editdlrm
selectors.cpython-310.pyc171050644editdlrm
shelve.cpython-310.pyc94920644editdlrm
shlex.cpython-310.pyc77820644editdlrm
shutil.cpython-310.pyc385360644editdlrm
signal.cpython-310.pyc29350644editdlrm
site.cpython-310.pyc179220644editdlrm
sitecustomize.cpython-310.pyc2250644editdlrm
smtpd.cpython-310.pyc261470644editdlrm
smtplib.cpython-310.pyc357660644editdlrm
sndhdr.cpython-310.pyc69620644editdlrm
socket.cpython-310.pyc289630644editdlrm
socketserver.cpython-310.pyc253470644editdlrm
sre_compile.cpython-310.pyc151940644editdlrm
sre_constants.cpython-310.pyc63570644editdlrm
sre_parse.cpython-310.pyc217550644editdlrm
ssl.cpython-310.pyc452710644editdlrm
stat.cpython-310.pyc42730644editdlrm
statistics.cpython-310.pyc370510644editdlrm
string.cpython-310.pyc71020644editdlrm
stringprep.cpython-310.pyc170750644editdlrm
struct.cpython-310.pyc3070644editdlrm
subprocess.cpython-310.pyc447410644editdlrm
sunau.cpython-310.pyc164820644editdlrm
symtable.cpython-310.pyc128350644editdlrm
sysconfig.cpython-310.pyc181510644editdlrm
tabnanny.cpython-310.pyc69500644editdlrm
tarfile.cpython-310.pyc706740644editdlrm
telnetlib.cpython-310.pyc185060644editdlrm
tempfile.cpython-310.pyc273390644editdlrm
textwrap.cpython-310.pyc138120644editdlrm
this.cpython-310.pyc12640644editdlrm
threading.cpython-310.pyc449690644editdlrm
timeit.cpython-310.pyc117690644editdlrm
token.cpython-310.pyc27380644editdlrm
tokenize.cpython-310.pyc171940644editdlrm
trace.cpython-310.pyc198700644editdlrm
traceback.cpython-310.pyc217120644editdlrm
tracemalloc.cpython-310.pyc175250644editdlrm
tty.cpython-310.pyc10790644editdlrm
turtle.cpython-310.pyc1288570644editdlrm
types.cpython-310.pyc95250644editdlrm
typing.cpython-310.pyc852770644editdlrm
uu.cpython-310.pyc38670644editdlrm
uuid.cpython-310.pyc224980644editdlrm
warnings.cpython-310.pyc136460644editdlrm
wave.cpython-310.pyc175940644editdlrm
weakref.cpython-310.pyc203430644editdlrm
webbrowser.cpython-310.pyc170000644editdlrm
xdrlib.cpython-310.pyc78800644editdlrm
zipapp.cpython-310.pyc60130644editdlrm
zipfile.cpython-310.pyc618450644editdlrm
zipimport.cpython-310.pyc170330644editdlrm
_aix_support.cpython-310.pyc28790644editdlrm
_bootsubprocess.cpython-310.pyc22940644editdlrm
_collections_abc.cpython-310.pyc329250644editdlrm
_compat_pickle.cpython-310.pyc58720644editdlrm
_compression.cpython-310.pyc45120644editdlrm
_distutils_system_mod.cpython-310.pyc54220644editdlrm
_markupbase.cpython-310.pyc75720644editdlrm
_osx_support.cpython-310.pyc115350644editdlrm
_pydecimal.cpython-310.pyc1577360644editdlrm
_pyio.cpython-310.pyc736540644editdlrm
_py_abc.cpython-310.pyc46830644editdlrm
_sitebuiltins.cpython-310.pyc35470644editdlrm
_strptime.cpython-310.pyc159450644editdlrm
_sysconfigdata__linux_x86_64-linux-gnu.cpython-310.pyc353850644editdlrm
_sysconfigdata__x86_64-linux-gnu.cpython-310.pyc353790644editdlrm
_threading_local.cpython-310.pyc65390644editdlrm
_weakrefset.cpython-310.pyc76080644editdlrm
__future__.cpython-310.pyc41310644editdlrm
__phello__.foo.cpython-310.pyc1300644editdlrm
Edit: /snap/core22/2437/usr/lib/python3.10/__pycache__/ftplib.cpython-310.pyc (28977B)
o p̦i@sNdZddlZddlZddlmZgdZdZdZdZGdd d eZ Gd d d e Z Gd d d e Z Gddde Z Gddde Z e eefZdZdZGdddZzddlZWn eycdZYnwejZGdddeZede eeejfZdaddZdaddZddZddZ d d!Z!d)d$d%Z"d&d'Z#e$d(kre#dSdS)*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_TIMEOUT)FTP error_reply error_temp error_perm error_proto all_errors c@ eZdZdS)ErrorN__name__ __module__ __qualname__rr/usr/lib/python3.10/ftplib.pyr 9 r c@r )rNrrrrrr:rrc@r )rNrrrrrr;rrc@r )rNrrrrrr<rrc@r )rNrrrrrr=rr s c@seZdZdZdZdZeZeZ dZ dZ dZ dZ dZddddedfddd d Zd d Zd dZd]ddZddZddZeZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Z d*d+Z!d,d-Z"d.d/Z#d0d1Z$d2d3Z%d^d4d5Z&d^d6d7Z'd_d8d9Z(d`d;d<Z)d^d=d>Z*dad?d@Z+d^dAdBZ,dCdDZ-dEdFZ.dGdHZ/dgfdIdJZ0dKdLZ1dMdNZ2dOdPZ3dQdRZ4dSdTZ5dUdVZ6dWdXZ7dYdZZ8d[d\Z9dS)bruAn FTP client class. To create a connection, call the class using these arguments: host, user, passwd, acct, timeout, source_address, encoding The first four arguments are all strings, and have default value ''. The parameter ´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. The last parameter is the encoding of filenames, which defaults to utf-8. 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. rNTFutf-8encodingcCs>||_||_||_|r|||r||||dSdSdS)zInitialization method (called by class instantiation). Initialize host to localhost, port to standard ftp port. Optional arguments are host (for connect()), and user, passwd, acct (for login()). N)rsource_addresstimeoutconnectlogin)selfhostuserpasswdacctrrrrrr__init__ms z FTP.__init__cCs|SNrrrrr __enter__}sz FTP.__enter__c Gsf|jdur1z z|Wn ttfyYnwW|jdur$|dSdS|jdur0|wwdSr$)sockquitOSErrorEOFErrorclose)rargsrrr__exit__s     z FTP.__exit__cCs|dkr||_|dkr||_|dkr||_|jdur!|js!td|dur(||_td||j|jtj|j|jf|j|jd|_ |j j |_ |j j d|j d |_||_|jS) 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. rrr.Nz0Non-blocking socket (timeout=0) is not supportedzftplib.connectrrr)rportr ValueErrorrsysauditsocketcreate_connectionr'familyafmakefilerfilegetrespwelcome)rrr1rrrrrrs$  z FTP.connectcCs|jr td||j|jS)z`Get the welcome message from the server. (this is read and squirreled away by connect())z *welcome*) debuggingprintsanitizer<r%rrr getwelcomeszFTP.getwelcomecC ||_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_debuglevels zFTP.set_debuglevelcCrA)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_pasvs z FTP.set_pasvcCsJ|dddvr!t|d}|ddd|d||d}t|S)N>pass PASS r*)lenrstriprepr)rsirrrr?s$z FTP.sanitizecCs`d|vsd|vr tdtd|||t}|jdkr$td|||j| |j dS)N  z4an illegal newline character should not be containedzftplib.sendcmdr z*put*) r2r3r4CRLFr=r>r?r'sendallencoderrlinerrrputlines z FTP.putlinecCs$|jr td||||dS)Nz*cmd*)r=r>r?rWrUrrrputcmdsz FTP.putcmdcCs|j|jd}t||jkrtd|j|jdkr$td|||s(t|ddt kr8|dd}|S|ddt vrF|dd}|S)Nr got more than %d bytesz*get*) r:readlinemaxlinerKr r=r>r?r*rRrUrrrgetlines   z FTP.getlinecCsf|}|dddkr1|dd} |}|d|}|dd|kr0|dddkr0 |Sq|S)N-r rQ)r^)rrVcodenextlinerrr getmultilines  zFTP.getmultilinecCsl|}|jrtd|||dd|_|dd}|dvr"|S|dkr*t||dkr2t|t|)Nz*resp*r_r >12345)rdr=r>r?lastresprrr)rrespcrrrr;s z FTP.getrespcCs$|}|dddkrt||S)z%Expect a response beginning with '2'.Nr rf)r;rrrkrrrvoidrespsz FTP.voidrespcCsTdt}|jdkrtd|||j|t|}|dddvr(t||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.ABORr z *put urgent*Nr_225226426) B_CRLFr=r>r?r'rSMSG_OOBrdrrrVrkrrraborts z FTP.abortcC|||S)z'Send a command and return the response.)rXr;rcmdrrrsendcmd z FTP.sendcmdcCrx)z8Send a command and expect a response beginning with '2'.)rXrnryrrrvoidcmdr|z FTP.voidcmdcCsB|d}t|dt|dg}||}dd|}||S)zUSend a PORT command with the current host and the given port number. .zPORT ,)splitrMjoinr})rrr1hbytespbytesbytesrzrrrsendport s  z FTP.sendportcCsbd}|jtjkr d}|jtjkrd}|dkrtddt||t|dg}dd|}||S)zESend an EPRT command with the current host and the given port number.rr zunsupported address familyrzEPRT |)r8r5AF_INETAF_INET6rrMrr})rrr1r8fieldsrzrrrsendeprt*s   z FTP.sendeprtcCsltjd|jdd}|d}|jd}|jtjkr#|||}n|||}|jt ur4| |j|S)z3Create a new socket and send a PORT command for it.)rrr )r7backlogr) r5 create_serverr8 getsocknamer'rrrrr settimeout)rr'r1rrkrrrmakeport7s     z FTP.makeportcCsh|jtjkr#t|d\}}|jr|}||fS|jd}||fSt|d|j\}}||fS)z (address, port)PASVrEPSV) r8r5rparse227r{trust_server_pasv_ipv4_addressr' getpeernameparse229)runtrusted_hostr1rrrrmakepasvDs z FTP.makepasvc Cs>d}|jrF|\}}tj||f|j|jd}z&|dur#|d|||}|ddkr2|}|ddkrrraz anonymous@zUSER rrgrIACCT rfr{r)rr r!r"rkrrrrs    z FTP.loginr cCs|d|||:} ||}|sn||q tdur1t|tr;|Wd|SWd|SWd|S1sHwY|S)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. TYPE Ir N)r}rrecv _SSLSocket isinstanceunwraprn)rrzcallback blocksizerrdatarrr retrbinarys(          zFTP.retrbinaryc Cs<|durt}|d}||}|jd|jd]} ||jd}t||jkr1td|j|j dkr=t dt ||s@n"|d dt krO|dd }n|d dd kr]|dd }||qt durot|t ro|Wdn1sywYWd|SWd|S1swY|S) 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. NTYPE Ar0rr rYrz*retr*rZr[rQ) print_liner{rr9rr\r]rKr r=r>rMrRrrrrn)rrzrrkrfprVrrr retrliness<     ( z FTP.retrlinescCs|d|||A} ||}|sn |||r ||q tdur8t|trB|Wd|SWd|SWd|S1sOwY|S)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. rr N)r}rreadrSrrrrn)rrzrrrrrbufrrr storbinarys,           zFTP.storbinarycCs|d||j} ||jd}t||jkr"td|j|s%n$|ddtkr=|dtvr9|dd}|t}|||rH||q tdur`t |trj| Wd| SWd| SWd| S1swwY| 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. rr rYrZNr[) r}rr\r]rKr rtrSrrrrn)rrzrrrrrrr storliness6      z FTP.storlinescCsd|}||S)zSend new account name.rr})rpasswordrzrrrr"s zFTP.acctcGs0d}|D]}|d|}qg}|||j|S)zBReturn a list of files in a given directory (default the current).NLST )rappend)rr,rzargfilesrrrnlst#s zFTP.nlstcGshd}d}|ddrt|dtdkr|dd|d}}|D] }|r+|d|}q!|||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.)LISTNr[rr)typer)rr,rzfuncrrrrdir,s  zFTP.dirc cs|r|dd|d|rd|}nd}g}|||j|D].}|td\}}}i} |dddD]} | d\} }} | | | <q;|| fVq#dS) 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 %sMLSDrNr[=) r{rrrrLrR partitionrlower) rpathfactsrzlinesrV facts_found_nameentryfactkeyvaluerrrmlsd;s    zFTP.mlsdcCs0|d|}|ddkrt||d|S)zRename a file.zRNFR rrgzRNTO )r{rr})rfromnametonamerkrrrrenameWs z FTP.renamecCs*|d|}|dddvr|St|)zDelete a file.zDELE Nr_>200250r)rfilenamerkrrrdelete^sz FTP.deletec Csp|dkr)z|dWSty(}z|jddddkrWYd}~n d}~ww|dkr/d}d |}||S) zChange to a directory.z..CDUPrNr_500rr~zCWD )r}rr,)rdirnamemsgrzrrrcwdfs   zFTP.cwdcCs:|d|}|dddkr|dd}t|SdS)zRetrieve the size of a file.zSIZE Nr_213)r{stripint)rrrkrNrrrrss zFTP.sizecCs$|d|}|dsdSt|S)z+Make a directory, return its full pathname.zMKD 257rr} startswithparse257)rrrkrrrmkd{s zFTP.mkdcCs|d|S)zRemove a directory.zRMD r)rrrrrrmdszFTP.rmdcCs |d}|ds dSt|S)z!Return current working directory.PWDrrrrmrrrpwds  zFTP.pwdcCs|d}||S)zQuit, and close the connection.QUIT)r}r+rmrrrr(s zFTP.quitcCsdz!|j}d|_|dur|W|j}d|_|dur |dSdS|j}d|_|dur1|ww)z8Close the connection without assuming anything about it.N)r:r+r')rr:r'rrrr+s   z FTP.close)rrr.Nr$)rrr)r N)r NN):rrr__doc__r=rFTP_PORTr1MAXLINEr]r'r:r<rDrrr#r&r-rr@rCdebugrFr?rWrXr^rdr;rnrwr{r}rrrrrrrrrrrr"rrrrrrrrrrr(r+rrrrrJsr      7    #     rc seZdZdZejZdddddddedf ddfdd Zdfd d Z d d Z d dZ ddZ ddZ dfdd ZddZZS)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.' >>> rNrrc  s|dur |dur td|dur|durtd|dus |dur+ddl} | dtd||_||_|dur>tj|j||d}||_ d|_ t j |||||| | ddS) Nz4context and keyfile arguments are mutually exclusivez5context and certfile arguments are mutually exclusiverzAkeyfile and certfile are deprecated, use a custom context insteadr)certfilekeyfileFr) r2warningswarnDeprecationWarningrrssl_create_stdlib_context ssl_versioncontext_prot_psuperr#) rrr r!r"rrrrrrr __class__rrr#s* zFTP_TLS.__init__Tcs*|r t|jtjs |t|||Sr$)rr'r SSLSocketauthrr)rr r!r"securerrrrsz FTP_TLS.logincCsft|jtjr td|jtjkr|d}n|d}|jj |j|j d|_|jj d|j d|_ |S)z2Set up secure control connection by using TLS/SSL.zAlready using TLSzAUTH TLSzAUTH SSLserver_hostnamer0)moder)rr'rrr2r PROTOCOL_TLSr}r wrap_socketrr9rr:rmrrrrs   z FTP_TLS.authcCs0t|jtjs td|d}|j|_|S)z/Switch back to a clear-text control connection.z not using TLSCCC)rr'rrr2r}rrmrrrcccs   z FTP_TLS.ccccCs|d|d}d|_|S)zSet up secure data connection.zPBSZ 0zPROT PTr}rrmrrrprot_ps zFTP_TLS.prot_pcCs|d}d|_|S)z"Set up clear text data connection.zPROT CFrrmrrrprot_cs zFTP_TLS.prot_ccs2t||\}}|jr|jj||jd}||fS)Nr)rrrrrr)rrzrrrrrrrs zFTP_TLS.ntransfercmdcCs8dt}|j||}|dddvrt||S)Nror_rp)rtr'rSrdrrvrrrrws  z FTP_TLS.abort)rrrTr$)rrrrrPROTOCOL_TLS_CLIENTrrr#rrrrr rrw __classcell__rrrrrs   rcCs\|dddkr t|tdurddl}|d|j|jBat|}|s'dSt|dS)zParse 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. Nr_rrz150 .* \((\d+) bytes\)r ) r_150_rerecompile IGNORECASEASCIImatchrgroup)rkr mrrrr.s  rcCs|dddkr t|tdurddl}|d|jat|}|s&t||}d|dd}t |dd>t |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.Nr_227rz#(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)r~r`rG) r_227_rer rrsearchrgroupsrr)rkr rnumbersrr1rrrrBs rcCs|dddkr t||d}|dkrt||d|d}|dkr)t|||d||dkr9t|||d|||d}t|dkrRt||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.Nr_229(r)r rG)rfindrrrKr)rkpeerleftrightpartsrr1rrrrUs   rcCs|dddkr t||dddkrdSd}d}t|}||krG||}|d}|dkr?||ks8||dkr; |S|d}||}||ks"|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.Nr_rrGz "rr ")rrK)rkrrOnrlrrrrjs$rcCs t|dS)z+Default retrlines callback to print a line.N)r>)rVrrrrs rrIc Cs|s|}d|}||||t|d\}}||||d|}|dddvr2t|d|}|dddvrCt||dS)z+Copy file from one FTP-instance to another.zTYPE rzSTOR Nr_>125rRETR )r}rr{rrrn) source sourcenametarget targetnamer sourcehost sourceporttreplysreplyrrrftpcps    r/c Csttjdkrttjtdddl}d}d}tjddkr/|d}tjd=tjddks tjddddkrGtjddd}tjd=tjd}t|}| |d}}}z||}Wnt yu|durstj dYnwz | |\}}}Wntytj d Ynw||||tjddD]K} | ddd kr|| ddq| dddkrd } | ddr| d | dd} || } q| d kr||j q|d| tjj dq|dS)zTest program. Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ... -d dir -l list -p password rrNr z-dz-rrz5Could not open account file -- using anonymous login.z$No account -- using anonymous login.z-lCWDrz-pr&i)rKr3argvr>testrexitnetrcrrCr)stderrwriteauthenticatorsKeyErrorrrr{rFrDrstdoutr() r4r=rcfilerftpuseridr!r"netrcobjr:rzrkrrrr2sZ            r2__main__)rr$)%rr3r5r__all__rurr Exceptionr rrrrr)r*rrRrtrr ImportErrorrrrrSSLErrorr rrrrrrr/r2rrrrrsT&  ^   } 9