ó x”þfc@s÷dZddlZddlZddlZddlZddlZddlZddlmZd„Zda da da da da ddd gZd „Zd „Zd „Zd dd„ƒYZd„Zd„Zd„ZedkróeƒndS(s—Mirror a remote ftp subtree into a local directory tree. usage: ftpmirror [-v] [-q] [-i] [-m] [-n] [-r] [-s pat] [-l username [-p passwd [-a account]]] hostname[:port] [remotedir [localdir]] -v: verbose -q: quiet -i: interactive mode -m: macintosh server (NCSA telnet 2.4) (implies -n -s '*.o') -n: don't log in -r: remove local files/directories no longer pertinent -l username [-p passwd [-a account]]: login info (default .netrc or anonymous) -s pat: skip files matching pattern hostname: remote host w/ optional port separated by ':' remotedir: remote directory (default initial) localdir: local directory (default current) iÿÿÿÿN(tfnmatchcGs8tjt_x|D] }|GHqWtGHtjdƒdS(Ni(tsyststderrtstdoutt__doc__texit(targstmsg((s//usr/lib64/python2.7/Tools/scripts/ftpmirror.pytusages   iit.s..s .mirrorinfocCsy#tjtjddƒ\}}Wn tjk rE}t|ƒnXd}d}d}|sktdƒn|d}d}d|kr®|jddƒ\}}t|ƒ}ny7tjƒj|ƒ}|dk rä|\}}}nWntj t fk rnXx|D]ü\} } | dkr*| }n| dkr?| }n| d krT| }n| d krmt da n| d kr‚da n| d kr—da n| d kr¿dadatjdƒn| dkrÔdan| dkrédan| dkr tj| ƒq q Wd} d} |drZ|d} |drZ|d} |drWtdƒqWqZntjƒ} t rŽd||r‚d|p…dfGHn| j||ƒtsÒt r¼d|p¶dGHn| j|||ƒnt ràdGHn| jƒ}t dkr dGt|ƒGHn| r|t dkr.dt| ƒGHn| j| ƒt dkrOdGHn| jƒ}t dkr|dGt|ƒGHq|nt| | ƒdS(Nisa:bil:mnp:qrs:vtshostname missingit:s-ls-ps-as-vs-qs-is-ms*.os-ns-rs-siistoo many argumentssConnecting to '%s%s'...s:%dsLogging in as %r...t anonymoussOK.sPWD =scwd(%s)(tgetoptRtargvterrorRtsplittinttnetrctauthenticatorstNonetNetrcParseErrortIOErrortverboset interactivetmactnologintskippatstappendtrmoktftplibtFTPtconnecttlogintpwdtreprtcwdt mirrorsubdir(toptsRRR!tpasswdtaccountthosttporttauthtotat remotedirtlocaldirtfR"((s//usr/lib64/python2.7/Tools/scripts/ftpmirror.pytmain,s–#                           c# Cs” |jƒ}|rwtjj|ƒ rwtr=dGt|ƒGHnyt|ƒWqwtjk rs}dGt|ƒGHdSXntjj|dƒ}yt |dƒj ƒ}Wnt k rÀ}d}nXyt |ƒ}Wn,t tfk rÿdGt|ƒGHi}nXg}g}tr!d|fGHn|jd|jƒg} x|D]} td kred Gt| ƒGHntr©| jƒ} d } | d d kr | d } d} nd} n¶| jddƒ}t|ƒdkrçtd krAdGHqAqAn|d jƒ} | jdƒ}|dkrHtd kr-d| fGHn| |d}| | } n|dd !} |d} d}xStD]K}t| |ƒrltd kr­dGt|ƒGdGt| ƒGHnd }PqlqlW|rÇqAn| ddkrtd krõdGt| ƒGHn|j| ƒqAn| j| ƒ|j| ƒrX|| | krXtd krAdGt| ƒGHqAqAntjj|| ƒ}tjj|d| ƒ}trÉtd| |ƒ}|sÉ|j| ƒsAd|| NsCreating local directorys#Failed to establish local directorys .mirrorinfotrs{}sBad mirror info insListing remote directory %r...tLISTis-->t-iÿÿÿÿt/tdR iisSkipping short lines -> isFound symbolic link %riiûÿÿÿs Skip patterntmatchessRemembering subdirectorysAlready have this version oft@tfiles Not retrievedtlsCreating symlink %r -> %rsCan't create %r: %stwbsRetrieving %r from %r as %r...isRETR sCan't rename %r to %r: %sg@s Kbytes intsecondss(~%d Kbytes/sec)s Removing obsolete info entry fortinR s Local filesis no longer pertinentsRemoving local file/dirt subdirectorysProcessing subdirectorysRemote directory now:s Remote cwdsCan't chdir toR s Mirroring ass Remote cwd ..s..s,Ended up in wrong directory after cd + cd ..sGiving up now.sOK.i (4R"tostpathtisdirRR#tmakedirRtjointopentreadRtevalt SyntaxErrort NameErrort retrlinesRRtstripRRtlentlstriptfindRRthas_keyRtaskabouttunlinktsymlinkt LoggingFileRRttimet retrbinarytwriteRt error_permttelltclosetrenamet writedictRtroundtkeystlistdirtcurdirRtremoveR$R%(#R0R/R"Rt infofilenamettexttinfotsubdirstlistingt filesfoundtlinetfilenametmodet infostufftwordstitlinktotskiptpattfullnamettempnametdoittfptfp1tt0tt1tbytestdttkbytest deletionstnamestnametsubdirt localsubdirtnewpwd((s//usr/lib64/python2.7/Tools/scripts/ftpmirror.pyR%isŽ                                      "  +      !      cCstjj|ƒr×tjj|ƒ r×ytj|ƒ}Wntjk rTg}nXd}x2|D]*}ttjj||ƒƒsbd}qbqbW|sšdSytj|ƒWqtjk rÓ}d||fGHdSXn:ytj |ƒWn&tjk r}d||fGHdSXdS(Niis#Can't remove local directory %r: %ssCan't remove local file %r: %s( R?R@RAtislinkR]RR_RCtrmdirRP(RoRztokR{R((s//usr/lib64/python2.7/Tools/scripts/ftpmirror.pyR_7s,%   RRcBs#eZd„Zd„Zd„ZRS(cCs1||_d|_d|_||_||_dS(Ni(RrRvthashest blocksizetoutfp(tselfRrRƒR„((s//usr/lib64/python2.7/Tools/scripts/ftpmirror.pyt__init__Rs     cCsƒ|jt|ƒ|_t|jƒ|j}x@||jkrn|jjdƒ|jjƒ|jd|_q/W|jj|ƒdS(Nt#i( RvRKRRƒR‚R„RUtflushRr(R…tdataR‚((s//usr/lib64/python2.7/Tools/scripts/ftpmirror.pyRUXs cCs|jjdƒdS(Ns (R„RU(R…((s//usr/lib64/python2.7/Tools/scripts/ftpmirror.pyRX`s(t__name__t __module__R†RURX(((s//usr/lib64/python2.7/Tools/scripts/ftpmirror.pyRRQs  cCsZd|||f}x@t|ƒjƒjƒ}|d kr>dS|dkrNd Sd GHqdS(NsRetrieve %s %s from %s ? [ny] tytyetyesiR tntnotnoptnopeisPlease answer yes or no.(RŒRsyes(R RRR‘R’(t raw_inputRJtlower(tfiletypeRgR"tprompttreply((s//usr/lib64/python2.7/Tools/scripts/ftpmirror.pyROds  cCsOtjj|ƒrdStjj|ƒ}|r;t|ƒntj|dƒdS(Niÿ(R?R@RAtdirnameRBtmkdir(tpathnameR˜((s//usr/lib64/python2.7/Tools/scripts/ftpmirror.pyRBps  c Cstjj|ƒ\}}tjj|d|ƒ}tjj||dƒ}ytj|ƒWntjk rqnXt|dƒ}|jdƒx1|jƒD]#\}}|jd||fƒq›W|jdƒ|j ƒytj ||ƒWntjk rnXtj ||ƒdS(NR8t~tws{ s%r: %r, s} ( R?R@RRCRPRRDRUtitemsRXRY( tdictRgtdirtfnameRptbackupRrtkeytvalue((s//usr/lib64/python2.7/Tools/scripts/ftpmirror.pyRZzs$   t__main__((RR?RRSR RRRRRRRRRRR1R%R_RRRORBRZRŠ(((s//usr/lib64/python2.7/Tools/scripts/ftpmirror.pyts.        = Î