SlQc @s dZddlZddlZddlZddlZddlZddlZddlZddlZyddl Z ddl Z Wne k re Z Z nXddl mZmZddlmZddlmZmZmZmZmZddlmZmZddlmZmZmZddlm Z dd l!mZ"m#Z#m$Z$m%Z%d Z&d Z'd Z(d Z)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4dZ5dZ6dZ7dZ8dZ9dZ:dZ;d Z<d!Z=d"Z>d#Z?d$Z@d%ZAd&ZBd'ZCd(ZDd)ZEd*ZFd+ZGd,ZHd-ZId.ZJd/ZKd0ZLd1ZMd2ZNd3ZOd4ZPd5ZQd6ZRd7ZSd8ZTd9ZUd:ZVd;ZWd<ZXd=ZYd>ZZd?Z[d@Z\dAZ]dBZ^dCZ_i:dDe&6dEe'6dFe(6dGe)6dHe*6dIe+6dJe,6dKe-6dLe.6dMdNge/6dOe06dPe16dQe26dRe36dSe56dTe46dUe66dVe76dWe86dXe96dYe:6dZe;6d[e<6d\e=6d]e>6d^e?6d_e@6d`eA6daeB6dbeC6dceD6ddeE6deeF6dfeG6dgeH6dheI6dieJ6djeK6dkeL6dleM6dmeN6dneO6doeP6dpeQ6dqeR6dreS6dseT6dteU6dueV6dveW6dweX6dxeY6dye[6dze\6d{eZ6d|e]6d}e^6d~e_6Z`deafdYZbdZcdZde dZedeafdYZfdeffdYZgdeffdYZhdeffdYZideffdYZjdeffdYZkdeffdYZldeffdYZmdeffdYZndeffdYZodeffdYZpdeafdYZqdeafdYZrdeffdYZsdeffdYZtdZue ddddddddddddg ZvdewejxfdYZydejzfdYZ{dewfdYZ|dewfdYZ}dej~fdYZdewej~ejfdYZdejfdYZdefdYZdefdYZdefdYZdZddZdewfdYZdewfdYZdefdYZdewfdYZdfdYZdefdYZdefdYZdeqfdYZdeqfdYZdeqfdYZdeqfdYZdeqfdYZdfdYZdejxfdYZdejfdYZdejxfdYZdZdZdZdejfdYZdej~fdYZdejzfdYZdefdYZdej~fdYZdZdS(s An FTP protocol implementation iN(t Interfacet implements(t copyright(treactort interfacestprotocolterrortdefer(tbasictpolicies(tlogtfailuretfilepath(treduce(Rtportalt credentialstcheckerst100t120t125t150s200.1s200.2s200.3t202s211.1s211.2t212t213t214t215s220.1s220.2s221.1s221.2t225s226.1s226.2t227t229s230.1s230.2t250s257.1s257.2s331.1s331.2t332t350s421.1s421.2t425t426t450t451t452t500t501s502.1s502.2t503t504s530.1s530.2t532s550.1s550.2s550.3s550.4s550.5s550.6s550.7t551t552t553s110 MARK yyyy-mmmms120 service ready in %s minutess3125 Data connection already open, starting transfers4150 File status okay; about to open data connection.s200 Command OKs200 Type set to %s.s 200 PORT OKs5202 Command not implemented, superfluous at this sites211 System status replys 211-Features:s211 Ends212 %ss213 %ss 214 help: %ss215 UNIX Type: L8s220 %ss220 Service readys&221 Service closing control connections 221 Goodbye.s1225 data connection open, no transfer in progresss226 Abort successfuls226 Transfer Complete.s227 Entering Passive Mode (%s).s,229 Entering Extended Passive Mode (|||%s|).s230 User logged in, proceeds2230 Anonymous login ok, access restrictions apply.s&250 Requested File Action Completed OKs257 "%s"s257 "%s" createds331 Password required for %s.s8331 Guest login ok, type your email address as password.s332 Need account for login.s6350 Requested file action pending further information.s6421 Service not available, closing control connection.s9421 Too many users right now, try again in a few minutes.s425 Can't open data connection.s.426 Transfer aborted. Data connection closed.s/450 Requested action aborted. File unavailable.s8451 Requested action aborted. Local error in processing.s3452 Requested action aborted. Insufficient storage.s500 Syntax error: %ss#501 syntax error in argument(s) %s.s 502 Command '%s' not implementeds 502 Option '%s' not implemented.s&503 Incorrect sequence of commands: %ss'504 Not implemented for parameter '%s'.s$530 Please login with USER and PASS.s!530 Sorry, Authentication failed.s%532 Need an account for storing filess"550 %s: No such file or directory.s550 %s: Permission denied.s:550 Anonymous users are forbidden to change the filesystems%550 Cannot rmd, %s is not a directorys550 %s: File existss550 %s: is a directorys"550 Requested action not taken: %ss551 Page type unknownsC552 Requested file action aborted, exceeded file storage allocations5553 Requested action not taken, file name not allowedt InvalidPathcBseZdZRS(sL Internal exception used to signify an error during parsing a path. (t__name__t __module__t__doc__(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR-scCs|jdrg}n|}x|jdD]}|dks/|dkrSq/q/|dkr|rr|jqt||q/d|ksd|krt||q/|j|q/W|S(sn Normalize a path, as represented by a list of strings each representing one segment of the path. t/t.ts..t(t startswithtsplittpopR-tappend(tcwdtpathtsegsts((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt toSegmentss   cCs|tjkr"tjt|S|tjks@|tjkrStjt|S|tjkrutjt |S|tj krtjt |S|tj krtjt |StjSdS(s? Map C{OSError} and C{IOError} to standard FTP errors. N(terrnotENOENTRtfailtFileNotFoundErrortEACCEStEPERMtPermissionDeniedErrortENOTDIRtIsNotADirectoryErrortEEXISTtFileExistsErrortEISDIRtIsADirectoryError(teR:((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyterrnoToFailurescCsN|s tS|d}tjd}tj|}|||krFtStSdS(s Helper for checking if a FTPShell `segments` contains a wildcard Unix expression. Only filename globbing is supported. This means that wildcards can only be presents in the last element of `segments`. @type segments: C{list} @param segments: List of path elements as used by the FTP server protocol. @rtype: Boolean @return: True if `segments` contains a globbing expression. iR3N(tFalsetfnmatcht translatetTrue(tsegmentst globCandidatetemtpyTranslationstglobTranslations((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_isGlobbingExpressions t FTPCmdErrorcBs eZdZdZdZRS(s- Generic exception for FTP commands. cGstj||||_dS(N(t Exceptiont__init__t errorMessage(tselftmsg((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRXscCst|j|jS(sA Generate a FTP response message for this error. (tRESPONSEt errorCodeRY(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytresponse s(R.R/R0RXR^(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRVs RAcBseZdZeZRS(sH Raised when trying to access a non existent file or directory. (R.R/R0tFILE_NOT_FOUNDR](((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRAstAnonUserDeniedErrorcBseZdZeZRS(s[ Raised when an anonymous user issues a command that will alter the filesystem (R.R/R0tANON_USER_DENIEDR](((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR`sRDcBseZdZeZRS(s[ Raised when access is attempted to a resource to which access is not allowed. (R.R/R0tPERMISSION_DENIEDR](((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRD&sRFcBseZdZeZRS(sE Raised when RMD is called on a path that isn't a directory. (R.R/R0t IS_NOT_A_DIRR](((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRF/sRHcBseZdZeZRS(sA Raised when attempted to override an existing resource. (R.R/R0t FILE_EXISTSR](((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRH7sRJcBseZdZeZRS(sC Raised when DELE is called on a path that is a directory. (R.R/R0tIS_A_DIRR](((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRJ?stCmdSyntaxErrorcBseZdZeZRS(s0 Raised when a command syntax is wrong. (R.R/R0t SYNTAX_ERRR](((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRfGstCmdArgSyntaxErrorcBseZdZeZRS(s^ Raised when a command is called with wrong value or a wrong number of arguments. (R.R/R0tSYNTAX_ERR_IN_ARGSR](((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRhOstCmdNotImplementedErrorcBseZdZeZRS(sF Raised when an unimplemented command is given to the server. (R.R/R0tCMD_NOT_IMPLMNTDR](((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRjXstCmdNotImplementedForArgErrorcBseZdZeZRS(se Raised when the handling of a parameter for a command is not implemented by the server. (R.R/R0tCMD_NOT_IMPLMNTD_FOR_PARAMR](((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRl`stFTPErrorcBseZRS((R.R/(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRnistPortConnectionErrorcBseZRS((R.R/(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRonstBadCmdSequenceErrorcBseZdZeZRS(sS Raised when a client sends a series of commands in an illogical sequence. (R.R/R0t BAD_CMD_SEQR](((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRpsstAuthorizationErrorcBseZdZeZRS(s2 Raised when client authentication fails. (R.R/R0t AUTH_FAILURER](((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRr{scGs!tjdt|dtdS(NsdebugDeferred(): %stdebug(R R[tstrRP(RZt_((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt debugDeferredstJantFebtMartAprtMaytJuntJultAugtSeptOcttNovtDectDTPcBseZeejeZdZdZ dZ dZ dZ dZ dZdZdZdZdZdZd Zd Zd Zd Zd ZdZRS(cCs)t|_|jjjdg|_dS(N(RPt isConnectedtfactorytdeferredtcallbacktNonet_buffer(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytconnectionMades cCs/t|_|jdk r+|jjdndS(N(RMRt _onConnLostRR(RZtreason((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytconnectionLosts cCs|jj|ddS(sv Send a line to data channel. @param line: The line to be sent. @type line: L{bytes} s N(t transporttwrite(RZtline((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytsendLinesc Csd} d} d} | i|r*dp-dd6| |d6|d6|d d 6|d d 6|d 6| tj|d 6|d6S(NcSsBdjgtdD](}|d|?@r5d|dp8d^qS(NR3i itrwxit-(tjointrange(tmodetn((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt formatModescSsntj}it|jd6|jd6|jd6|jd6|jd6}|j|jkrbd|Sd|SdS(Ntmonthtdaytyearthourtminutes%(month)s %(day)02d %(year)5ds+%(month)s %(day)02d %(hour)02d:%(minute)02d(ttimetgmtimet_monthsttm_monttm_mdayttm_yearttm_hourttm_min(tmtimetnowtinfo((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt formatDates     sa%(directory)s%(permissions)s%(hardlinks)4d %(owner)-9s %(group)-9s %(size)15d %(date)12s %(name)stdRt directoryt permissionst hardlinksitownertgrouptsizetdatetname(RR( RZRRRRRtmodifiedRRRRtformat((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_formatOneListResponses     cCs|j|j||dS(N(RR(RZRR^((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytsendListResponsescCs|jj||S(N(RtregisterProducer(RZtproducert streaming((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs|jj|jjdS(N(RtunregisterProducertloseConnection(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs cCs)|jr|jj|StddS(NsCrap damn crap damn crap damn(RRRRW(RZtdata((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs cCs/y|jj|Wn|jjnXdS(N(t_consRRterrback(RZtbytes((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt _conswritescCs3|jdk r|j|n|jj|dS(N(RRRRR8(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt dataReceivedscCs |jjd|_|`|S(N(RRRR(RZtignored((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_unregConsumers  cCs|jdkst||_|jj|tx|jD]}|j|q;Wd|_|jrtj |_ }|j |j |S|jj d|_tjdSdS(N(RRtAssertionErrorRRPRRRRtDeferredRtaddBothRRtsucceed(RZtconstchunkR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytregisterConsumers     cCs|jjdS(N(RtresumeProducing(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs|jjdS(N(RtpauseProducing(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs|jjdS(N(Rt stopProducing(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRsN(R.R/RRt IConsumerRMRRRRRRRRRRRRRRRRRRRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs(             t DTPFactorycBszeZdZeZeZeZeZeZ dddZ dZ dZ dZdZdZdZRS( s Client factory for I{data transfer process} protocols. @ivar peerCheck: perform checks to make sure the ftp-pi's peer is the same as the dtp's @ivar pi: a reference to this factory's protocol interpreter @ivar _state: Indicates the current state of the DTPFactory. Initially, this is L{_IN_PROGRESS}. If the connection fails or times out, it is L{_FAILED}. If the connection succeeds before the timeout, it is L{_FINISHED}. cCsV||_||_tj|_d|_|dkrIddlm}n||_ dS(s Constructor @param pi: this factory's protocol interpreter @param peerHost: if peerCheck is True, this is the tuple that the generated instance will use to perform security checks i(RN( tpitpeerHostRRRRt delayedCallttwisted.internetRt_reactor(RZRRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRX#s    cCsmtjddt|j|jk r)dS|j|_|jt}||_ |j |_ ||j _ |S(NsDTPFactory.buildProtocolRt( R R[RPt_statet _IN_PROGRESSRt _FINISHEDt cancelTimeoutRRRt dtpInstance(RZtaddrtp((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt buildProtocol4s      cCs!tjddt|jdS(NsdtpFactory.stopFactoryRt(R R[RPR(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt stopFactoryCscCsatjd|j|jk r#dS|j|_|j}d|_|jtt j ddS(Ns$timed out waiting for DTP connectionsDTPFactory timeout( R R[RRt_FAILEDRRRRoRt TimeoutError(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyttimeoutFactoryHs    cCsE|jdk rA|jjrAtjddt|jjndS(Nscancelling DTP timeoutRt(RRtactiveR R[RPtcancel(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRTscCs0tjd||jj||j|_dS(Ns'DTPFactory.setTimeout set to %s seconds(R R[Rt callLaterRR(RZtseconds((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt setTimeoutZscCsK|j|jk rdS|j|_|j}d|_|jt|dS(N(RRRRRRRo(RZt connectorRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytclientConnectionFailed_s    N(R.R/R0tobjectRRRRRMt peerCheckRRXRRRRRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR s        tASCIIConsumerWrappercBseZdZdZRS(cCss||_|j|_|j|_tjdksQttjdksQtdtjdkro|j|_ndS(Ns is6Unsupported platform (yea right like this even exists)(RRRtostlineseptlenRR(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRXks    0cCs|jj|jtjdS(Ns (RRtreplaceRR(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRus(R.R/RXR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRjs t FileConsumercBs?eZdZeejdZdZdZdZ RS(s A consumer for FTP input that writes data to a file. @ivar fObj: a file object opened for writing, used to write data received. @type fObj: C{file} cCs ||_dS(N(tfObj(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRXscCs||_|stdS(N(RR(RZRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs cCsd|_|jjdS(N(RRRtclose(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs cCs|jj|dS(N(RR(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs( R.R/R0RRRRXRRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRzs     tFTPOverflowProtocolcBseZdZdZRS(s:FTP mini-protocol for when there are too many connections.cCs"|jtt|jjdS(N(RR\tTOO_MANY_CONNECTIONSRR(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs(R.R/R0R(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRstFTPcBseZdZeZed\ZZZZ dZ d2Z d2Z d2Zd2Zd2ZeZddgZdddddgZed d ZejZd Zd Zd ZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%ddZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-d Z.d!Z/d"Z0d#Z1d$Z2d%Z3d&Z4d'Z5d(Z6d)Z7d*Z8d+Z9d,Z:d-Z;d.Z<d/Z=d0Z>d1Z?RS(3s Protocol Interpreter for the File Transfer Protocol @ivar state: The current server state. One of L{UNAUTH}, L{INAUTH}, L{AUTHED}, L{RENAMING}. @ivar shell: The connected avatar @ivar binary: The transfer mode. If false, ASCII. @ivar dtpFactory: Generates a single DTP for this session @ivar dtpPort: Port returned from listenTCP @ivar listenFactory: A callable with the signature of L{twisted.internet.interfaces.IReactorTCP.listenTCP} which will be used to create Ports for passive connections (mainly for testing). @ivar passivePortRange: iterator used as source of passive port numbers. @type passivePortRange: C{iterator} ii tFEATtQUITtMDTMtPASVtSIZEsTYPE A;IiicGst||}|j|dS(N(R\R(RZtkeytargsR[((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytreplyscCs6|j|_|j|j|jt|jjdS(N(tUNAUTHtstateRttimeOutRt WELCOME_MSGRtwelcomeMessage(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs cCsm|jr|jn|jdt|jdrW|jjdk rW|jjnd|_d|_dS(Ntlogout(t dtpFactoryt cleanupDTPRRthasattrtshellRR(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs   $ cCs|jjdS(N(RR(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyttimeoutConnectionsc sjjfd}fd}fd}|jd}|dkr}|| ||df}n |d }tjj|}|j|||jtj ddl m }|j d|j |dS( Ncs|jtr(j|jjnr|jtrp|jjdjddkrpjt dfn*t j dt j |jt ddS(Nis takes exactlyis%s requires an argument.sUnexpected FTP errorsinternal server error(tcheckRVRtvalueR^t TypeErrorRtfindRRgR R[terrtREQ_ACTN_NOT_TAKEN(R (tcmdRZ(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt processFaileds  cs?t|trj|n|dk r;j|ndS(N(t isinstancettupleRR(tresult(RZ(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytprocessSucceededs csjsjndS(N(t disconnectedR(R(RZ(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytallDones t ii(Ri((t resetTimeoutRR Rt maybeDeferredtprocessCommandt addCallbackst addErrbackR R RRRR( RZRRRRt spaceIndexRRR((RRZs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt lineReceiveds      csfd}|j}|jkr7||Sjjkr|dkrbjS|dkrxtdfStSnjjkr|dkrjStdfSnTjj kr||Sjj kr |dkrj StdfSndS(Ncs?td|d}|dk r,|Stjt|S(Ntftp_(tgetattrRRR@Rj(tcommandtmethod(tparamsRZ(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytcall_ftp_command s  tUSERtPASSsUSER required before PASSsPASS required after USERtRNTOsRNTO required after RNFR( tuppertPUBLIC_COMMANDSRRtftp_USERRqt NOT_LOGGED_INtINAUTHtftp_PASStAUTHEDtRENAMINGtftp_RNTO(RZRR#R$((R#RZs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR s(            cCskxE|jD]:}y|j||}Wntjk r?q q X|Sq Wtjd|d|jfdS(se Return a port for passive access, using C{self.passivePortRange} attribute. R3sNo port available in range %sN(tpassivePortRanget listenFactoryRtCannotListenError(RZRtportntdtpPort((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt getDTPPort/s cCsa|stjtdS||_|j|_|jjrS|j|jjkrSt St |fSdS(sc First part of login. Get the username the peer wants to authenticate as. sUSER requires an argumentN( RR@Rft_userR,RRtallowAnonymoust userAnonymoustGUEST_NAME_OK_NEED_EMAILtUSR_NAME_OK_NEED_PASS(RZtusername((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR*@s  !csjjr6jjjkr6tj}tntjj|}t`fd}fd}j j |dt }|j |||S(sf Second part of login. Get the password the peer wants to authenticate with. csR|\}}}|tks'td|_|_g_j_S(NsThe realm is busted, jerk.(t IFTPShellRRRtworkingDirectoryR.R(t.0t interfacetavatarR(RRZ(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_cbLoginas     cs,|jtjtjj_tdS(N(ttrapt cred_errortUnauthorizedLogintUnhandledCredentialsRRRr(R (RZ(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_ebLoginis N(RR8R7R9Rt AnonymoustGUEST_LOGGED_IN_PROCEEDtUsernamePasswordtUSR_LOGGED_IN_PROCEEDRtloginRR=R(RZtpasswordtcredsRBRGR((RRZs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR-Rs!  cCs|jdk r|jntd||_|jj|j|j|j|_|jj j }|jj j }|j t t|||jjjdS(s Request for a passive connection from the rfc:: This command requests the server-DTP to "listen" on a data port (which is not its default data port) and to wait for a connection rather than initiate one upon receipt of a transfer command. The response to this command includes the host and port address this server is listening on. RcSsdS(N(R(tign((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytsN(RRRRRt dtpTimeoutR6R5RtgetHostthosttportRtENTERING_PASV_MODEtencodeHostPortRt addCallback(RZRSRT((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_PASVss  cCstt|jd}dt|d }|dd>|dB}|jdk r^|jntd|d|jj j |_|jj |j t j|||j|_d}d }|jjj||S( Nt,s %d.%d.%d.%diiiRRcSstS(N(tENTERING_PORT_MODE(R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt connectedscSs|jttS(N(RCRotCANT_OPEN_DATA_CNX(R ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt connFaileds (tmaptintR6RRRRRRtgetPeerRSRRQRt connectTCPR5RR(RZtaddressRtipRTR[R]((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_PORTs $  cCs t|tr|jdS|S(s Encode C{name} to be sent over the wire. This encodes L{unicode} objects as UTF-8 and leaves L{bytes} as-is. As described by U{RFC 3659 section 2.2}:: Various FTP commands take pathnames as arguments, or return pathnames in responses. When the MLST command is supported, as indicated in the response to the FEAT command, pathnames are to be transferred in one of the following two formats. pathname = utf-8-name / raw utf-8-name = raw = Which format is used is at the option of the user-PI or server-PI sending the pathname. @param name: Name to be encoded. @type name: L{bytes} or L{unicode} @return: Wire format of C{name}. @rtype: L{bytes} sutf-8(Rtunicodetencode(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt _encodeNames R3c sjdksjj r/tjtdS|jdkrJd}nfd}ytj|}Wn!t k rtjt |SXj j |d}|j ||S(s This command causes a list to be sent from the server to the passive DTP. If the pathname specifies a directory or other group of files, the server should transfer a list of files in the specified directory. If the pathname specifies a file then the server should send current information on the file. A null argument implies the user's current working or default directory. s"must send PORT or PASV before RETRs-as-ls-las-alR3cs]jtx6|D].\}}j|}jj||qWjjjtfS(N(RtDATA_CNX_ALREADY_OPEN_START_XFRRgRRRRtTXFR_COMPLETE_OK(tresultsRtattrs(RZ(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt gotListings  RRRRRRRN(s-as-ls-las-al(ssizes directorys permissionss hardlinkssmodifiedsownersgroup(RRRRR@RptlowerR=R>R-RARtlistRW(RZR:RlRQR((RZs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_LISTs      csjdksjj r/tjtdSytj|}Wn!tk rhtjt |SXfd}fd}t |r|j }nd}j j |}|j|||j||S(s\ This command causes a directory listing to be sent from the server to the client. The pathname should specify a directory or other system-specific file group descriptor. An empty path implies the current working directory. If the path is non-existent, send nothing. If the path is to a file, send only the file name. @type path: C{str} @param path: The path for which a directory listing should be returned. @rtype: L{Deferred} @return: a L{Deferred} which will be fired when the listing request is finished. s"must send PORT or PASV before RETRcs|jtxU|D]M\}}| s?|rtj||rj|}jj|qqWjjjtfS(s Send, line by line, each matching file in the directory listing, and then close the connection. @type results: A C{list} of C{tuple}. The first element of each C{tuple} is a C{str} and the second element is a C{list}. @param results: The names of the files in the directory. @param glob: A shell-style glob through which to filter results (see U{http://docs.python.org/2/library/fnmatch.html}), or C{None} for no filtering. @type glob: L{str} or L{NoneType} @return: A C{tuple} containing the status code for a successful transfer. @rtype: C{tuple} ( RRhRNRgRRRRRi(RjtglobRR(RZ(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytcbLists csjjjtfS(s RFC 959 specifies that an NLST request may only return directory listings. Thus, send nothing and just close the connection. @type results: L{Failure} @param results: The L{Failure} wrapping a L{FileNotFoundError} that occurred while trying to list the contents of a nonexistent directory. @returns: A C{tuple} containing the status code for a successful transfer. @rtype: C{tuple} (RRRRi(Rj(RZ(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytlistErrsN(RRRRR@RpR=R>R-RARUR7RRnRWR(RZR:RQRqRrRpR((RZs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_NLSTs     cseytj|Wn!tk r9tjt|SXfd}jjj|S(Ncs_tfS(N(R>tREQ_FILE_ACTN_COMPLETED_OK(R(RQRZ(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt accessGrantedBs ( R=R>R-RR@RARtaccessRW(RZR:Ru((RQRZs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_CWD;s  cCs |jdS(Ns..(Rw(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_CDUPIscCstddj|jfS(NR1(t PWD_REPLYRR>(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_PWDMscsjdkrtdnytj|Wn!tk rWtjt|SXj dfd}j st jn jddfd}fd}j j }|j|||j||S(s This command causes the content of a file to be sent over the data transfer channel. If the path is to a folder, an error will be raised. @type path: C{str} @param path: The path to the file which should be transferred over the data transfer channel. @rtype: L{Deferred} @return: a L{Deferred} which will be fired when the transfer is done. s!PORT or PASV required before RETRcsjjj|S(N(RRR(R(RZ(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt enableTimeoutkscSstfS(N(Ri(R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytcbSentuscSs4tjdtj||jtr-|StfS(Ns7Unexpected error attempting to transmit file to client:(R R[R R RVtCNX_CLOSED_TXFR_ABORTED(R ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytebSentxs   csLjjrjtn jt|j}|j|S(N(RRRRhtFILE_STATUS_OK_OPEN_DATA_CNXtsendR(tfileR(R|RR~RZ(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytcbOpeneds   csm|jttts2tjdtj|n|jtrZ|jj dj fSt dj fS(Ns:Unexpected error attempting to open file for transmission:R1( R RDRARJR R[R RVR R]RR_(R (tnewsegs(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytebOpeneds  N(RRRpR=R>R-RR@RARtbinaryRRtopenForReadingRR(RZR:R{RRR((R|RR~RRZs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_RETRQs&         csjdkrtdnytj|Wn!tk rWtjt|SXj dfd}fd}fd}fdddj j }|j |||j ||S( s STORE (STOR) This command causes the server-DTP to accept the data transferred via the data connection and to store the data as a file at the server site. If the file specified in the pathname exists at the server site, then its contents shall be replaced by the data being transferred. A new file is created at the server site if the file specified in the pathname does not already exist. s!PORT or PASV required before STORcsjjj|S(N(RRR(R(RZ(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR{scsCj}|j|jfd|j|S(sx File was open for reading. Launch the data transfer channel via the file consumer. cs jS(N(R(R(R(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRPs(treceiveRWR(RR(t cbConsumerR|R~(Rs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs   csNt|jtr+|jjdjfStj|dtdjfS(s Called when failed to open the file for reading. For known errors, return the FTP error code. For all other, return a file not found error. R1s-Unexpected error received while opening file:(RR RVR]RR R R_(R (R(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscsWjst|}njj|}jjrFjtn jt|S(s Called after the file was opended for reading. Prepare the data transfer channel and send the response to the command channel. (RRRRRRRhR(RR(RZ(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs   cSstfS(sJ Called from data transport when tranfer is done. (Ri(R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR|scSs*tj|d|jtr#|StfS(sk Called from data transport when there are errors during the transfer. s*Unexpected error received during transfer:(R R R RVR}(R ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR~sN(RRRpR=R>R-RR@RARRtopenForWritingRR(RZR:R{RRR((RR|R~RRZs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_STORs"        cCs_yt|j|}Wn!tk r9tjt|SXd}|jj|dj|S(sb File SIZE The FTP command, SIZE OF FILE (SIZE), is used to obtain the transfer size of a file from the server-FTP process. This is the exact number of octets (8 bit bytes) that would be transmitted over the data connection should that file be transmitted. This value will change depending on the current STRUcture, MODE, and TYPE of the data connection or of a data connection that would be created were one created now. Thus, the result of the SIZE command is dependent on the currently established STRU, MODE, and TYPE parameters. The SIZE command returns how many octets would be transferred if the file were to be transferred using the current transfer structure, mode, and type. This command is normally used in conjunction with the RESTART (REST) command when STORing a file to a remote server in STREAM mode, to determine the restart point. The server-PI might need to read the partially transferred file, do any appropriate conversion, and count the number of octets that would be generated when sending the file in order to correctly respond to this command. Estimates of the file transfer size MUST NOT be returned; only precise information is acceptable. http://tools.ietf.org/html/rfc3659 cSs|\}tt|fS(N(t FILE_STATUSRu(R?R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytcbStatsR(ssize( R=R>R-RR@RARtstatRW(RZR:RR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_SIZEs   cCs_yt|j|}Wn!tk r9tjt|SXd}|jj|dj|S(s! File Modification Time (MDTM) The FTP command, MODIFICATION TIME (MDTM), can be used to determine when a file in the server NVFS was last modified. This command has existed in many FTP servers for many years, as an adjunct to the REST command for STREAM mode, thus is widely available. However, where supported, the "modify" fact that can be provided in the result from the new MLST command is recommended as a superior alternative. http://tools.ietf.org/html/rfc3659 cSs(|\}ttjdtj|fS(Ns %Y%m%d%H%M%S(RRtstrftimeR(R?R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR2sR(smodified( R=R>R-RR@RARRRW(RZR:RR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_MDTM s   cCsZ|j}|rSt|d|dd}|dk rF||dS|j|StfS(s REPRESENTATION TYPE (TYPE) The argument specifies the representation type as described in the Section on Data Representation and Storage. Several types take a second parameter. The first parameter is denoted by a single Telnet character, as is the second Format parameter for ASCII and EBCDIC; the second parameter for local byte is a decimal integer to indicate Bytesize. The parameters are separated by a (Space, ASCII code 32). ttype_iiN(R(R Rt type_UNKNOWNRg(RZttypeRtf((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_TYPE8s   cCsF|dks|dkr/t|_td|fStjt|SdS(NR3tNtA(RMRt TYPE_SET_OKRR@Rh(RZtcode((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyttype_AMs cCs6|dkrt|_tdfStjt|SdS(NR3tI(RPRRRR@Rh(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyttype_ITs   cCstjt|S(N(RR@Rl(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR[scCstS(N(t NAME_SYS_TYPE(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_SYST`scCs2|j}|dkrtfStjt|S(NtF(R(tCMD_OKRR@Rl(RZt structureR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_STRUds  cCs2|j}|dkrtfStjt|S(NtS(R(RRR@Rl(RZRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_MODEks  cs\yt|j}Wn!tk r9tjtSX|jj|jfdS(Ncs tfS(N(t MKD_REPLY(RO(R:(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRPws( R=R>R-RR@RARt makeDirectoryRW(RZR:R((R:s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_MKDrs  cCsVyt|j|}Wn!tk r9tjt|SX|jj|jdS(NcSstfS(N(Rt(RO((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRPs( R=R>R-RR@RARtremoveDirectoryRW(RZR:R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_RMDzs  cCsVyt|j|}Wn!tk r9tjt|SX|jj|jdS(NcSstfS(N(Rt(RO((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRPs( R=R>R-RR@RARt removeFileRW(RZR:R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_DELEs  cCstfS(N(R(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_NOOPscCs||_|j|_tfS(N(t _fromNameR/Rt"REQ_FILE_ACTN_PENDING_FURTHER_INFO(RZtfromName((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_RNFRs  cCs|j}|`|j|_y(t|j|}t|j|}Wn!tk rftjt|SX|j j ||j dS(NcSstfS(N(Rt(RO((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRPs( RR.RR=R>R-RR@RARtrenameRW(RZttoNameRtfromsegsttosegs((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR0s   cCsS|jttdx"|jD]}|jd|qW|jttddS(sm Advertise the features supported by the server. http://tools.ietf.org/html/rfc2389 iRiN(RR\tFEAT_OKtFEATURES(RZtfeature((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_FEATscCs|jt|S(sl Handle OPTS command. http://tools.ietf.org/html/draft-ietf-ftpext-utf-8-option-00 (RtOPTS_NOT_IMPLEMENTED(RZtoption((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_OPTSscCs'|jt|jjt|_dS(N(Rt GOODBYE_MSGRRRPR(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_QUITs  cCstjddttj|j|jd}|_tjj|rU|jn8tj j|rt|j nt st d|f|j jd|_ |jdk rd|_ndS(s0 Call when DTP connection exits RRts@dtpPort should be an IListeningPort or IConnector, instead is %rN(R R[RPR5RRtIListeningPortt providedByt stopListeningt IConnectort disconnectRMRRRR(RZR5((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs    N(@R.R/R0RMRRRR,R.R/RQRRRRR5RRPRR)RtxrangeR1Rt listenTCPR2RRRRRRR6R*R-RXRdRgRoRsRwRxRzRRRRRRRRRRRRRRRRR0RRRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRsh      + %   !   & R    I a %               t FTPFactorycBsleZdZeZeZeZdZ dZ de j fZ eddZd ddZdZdZRS( s A factory for producing ftp protocol instances @ivar timeOut: the protocol interpreter's idle timeout time in seconds, default is 600 seconds. @ivar passivePortRange: value forwarded to C{protocol.passivePortRange}. @type passivePortRange: C{iterator} t anonymousiXsTwisted %s FTP ServeriicCs||_||_g|_dS(N(RR9t instances(RZRR9((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRXs  cCsUtjj||}|dk rQ|j|j_|j|j_|j|j_n|S(N(R tLimitTotalConnectionsFactoryRRRtwrappedProtocolRR1(RZRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs  cCsFg|jD]$}|jdk r |jd^q tjj|dS(N(RRRRR RR(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs2N(R.R/R0RRRtoverflowProtocolRPR8R9RRtversionRRR1RRXRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs  R=cBseeZdZdZdZdZdZdZd dZd dZ dZ d Z RS( s An abstraction of the shell commands used by the FTP protocol for a given user account. All path names must be absolute. cCsdS(s Create a directory. @param path: The path, as a list of segments, to create @type path: C{list} of C{unicode} @return: A Deferred which fires when the directory has been created, or which fails if the directory cannot be created. N((R:((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCsdS(s Remove a directory. @param path: The path, as a list of segments, to remove @type path: C{list} of C{unicode} @return: A Deferred which fires when the directory has been removed, or which fails if the directory cannot be removed. N((R:((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR scCsdS(s  Remove a file. @param path: The path, as a list of segments, to remove @type path: C{list} of C{unicode} @return: A Deferred which fires when the file has been removed, or which fails if the file cannot be removed. N((R:((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCsdS(sx Rename a file or directory. @param fromPath: The current name of the path. @type fromPath: C{list} of C{unicode} @param toPath: The desired new name of the path. @type toPath: C{list} of C{unicode} @return: A Deferred which fires when the path has been renamed, or which fails if the path cannot be renamed. N((tfromPathttoPath((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR%scCsdS(s Determine whether access to the given path is allowed. @param path: The path, as a list of segments @return: A Deferred which fires with None if access is allowed or which fails with a specific exception type if access is denied. N((R:((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRv4scCsdS(s Retrieve information about the given path. This is like list, except it will never return results about child paths. N((R:tkeys((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR@scCsdS(se Retrieve information about the given path. If the path represents a non-directory, the result list should have only one entry with information about that non-directory. Otherwise, the result list should have an element for each child of the directory. @param path: The path, as a list of segments, to list @type path: C{list} of C{unicode} or C{bytes} @param keys: A tuple of keys desired in the resulting dictionaries. @return: A Deferred which fires with a list of (name, list), where the name is the name of the entry as a unicode string or bytes and each list contains values corresponding to the requested keys. The following are possible elements of keys, and the values which should be returned for them: - C{'size'}: size in bytes, as an integer (this is kinda required) - C{'directory'}: boolean indicating the type of this entry - C{'permissions'}: a bitvector (see os.stat(foo).st_mode) - C{'hardlinks'}: Number of hard links to this entry - C{'modified'}: number of seconds since the epoch since entry was modified - C{'owner'}: string indicating the user owner of this entry - C{'group'}: string indicating the group owner of this entry N((R:R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRnIscCsdS(s @param path: The path, as a list of segments, to open @type path: C{list} of C{unicode} @rtype: C{Deferred} which will fire with L{IReadFile} N((R:((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRoscCsdS(s @param path: The path, as a list of segments, to open @type path: C{list} of C{unicode} @rtype: C{Deferred} which will fire with L{IWriteFile} N((R:((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRxs((( R.R/R0RRRRRvRRnRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR=s  & t IReadFilecBseZdZdZRS(s0 A file out of which bytes may be read. cCsdS(s Produce the contents of the given path to the given consumer. This method may only be invoked once on each provider. @type consumer: C{IConsumer} @return: A Deferred which fires when the file has been consumed completely. N((tconsumer((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs(R.R/R0R(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRst IWriteFilecBs eZdZdZdZRS(s1 A file into which bytes may be written. cCsdS(s Create a consumer which will write to this file. This method may only be invoked once on each provider. @rtype: C{Deferred} of C{IConsumer} N((((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCsdS(se Perform any post-write work that needs to be done. This method may only be invoked once on each provider, and will always be invoked after receive(). @rtype: C{Deferred} of anything: the value is ignored. The FTP client will not see their upload request complete until this Deferred has been fired. N((((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs(R.R/R0RR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs cCseg}tj|}|j|jx9tjD]+}|j|jkr2|j|jq2q2W|S(s_ Return the primary and supplementary groups for the given UID. @type uid: C{int} ( tpwdtgetpwuidR8tpw_gidtgrptgetgralltpw_nametgr_memtgr_gid(tuidRtpwenttgrent((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt _getgroupsstrc Cs`|dkr3tj}tj}tj}tj}nF|dkrftj}tj}tj}tj }nt d|ft }tj j |r|dkrt}qtj|} || j@r|| jkrt}q|| j@r|t|krt}q|| j@rt}qn|r\tj||s\t }tjd|tjfq\n|S(s checks to see if uid has proper permissions to access path with mode @type uid: C{int} @param uid: numeric user id @type gid: C{int} @param gid: numeric group id @type spath: C{str} @param spath: the path on the server to test @type mode: C{str} @param mode: 'r' or 'w' (read or write) @rtype: C{bool} @return: True if the given credentials have the specified form of access to the given path Rtws(Invalid mode %r: must specify 'r' or 'w'isUFilesystem grants permission to UID %d but it is inaccessible to me running as UID %d(RtS_IRUSRtS_IRGRPtS_IROTHRtR_OKtS_IWUSRtS_IWGRPtS_IWOTHtW_OKt ValueErrorRMR:texistsRPtst_modetst_uidRRvR R[tgetuid( RtgidtspathRtusrRtothtamodeRvR<((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_testPermissionss8                 tFTPAnonymousShellcBseZdZeedZdZdZdZdZ dZ dZ dZ d Z d Zdd Zdd Zd ZejdZejdZejdZejdZdZdZdZRS(s An anonymous implementation of IFTPShell @type filesystemRoot: L{twisted.python.filepath.FilePath} @ivar filesystemRoot: The path which is considered the root of this shell. cCs ||_dS(N(tfilesystemRoot(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRXscCsttjj||jS(N(R R tFilePathtchildR(RZR:((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_pathscCstjtS(N(RR@R`(RZR:((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCstjtS(N(RR@R`(RZR:((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR scCstjtS(N(RR@R`(RZR:((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCstjtS(N(RR@R`(RZRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs|j|}tjtS(N(RRR@R`(RZR:((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs|j|}|jr.tjt|Sy|jd}Wn3ttfk ri}t|j |StjSXtj t |SdS(s Open C{path} for reading. @param path: The path, as a list of segments, to open. @type path: C{list} of C{unicode} @return: A L{Deferred} is returned that will fire with an object implementing L{IReadFile} if the file is successfully opened. If C{path} is a directory, or if an exception is raised while trying to open the file, the L{Deferred} will fire with an error. RN( RtisdirRR@RJtopentIOErrortOSErrorRLR>Rt _FileReader(RZR:RRRK((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs   cCstjtdS(sa Reject write attempts by anonymous users with L{PermissionDeniedError}. sSTOR not allowed(RR@RD(RZR:((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR6scCs|j|}|js.tjt|Sy|jWn3ttfk rd}t|j |StjSXtj dSdS(N( RRRR@RAtlistdirRRRLR>RR(RZR:RRK((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRv>s  cCs|j|}|jrwy|j||}Wn3ttfk rY}t|j|StjSXtj |Sn|j ||j dSdS(NcSs |ddS(Nii((tres((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRP[s( RRt _statNodeRRRLR>RR@RRnRW(RZR:RRt statResultRK((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyROs  c Cs@|j|}|jrL|j}g|D]}|j|^q.}nL|jrtjj|j|j g}|g}nt j t |Sg}xt ||D]\}}g} |j|| f|ry| j|j||Wq/ttfk r} t| j|St j SXqqWt j|S(s Return the list of files at given C{path}, adding C{keys} stat informations if specified. @param path: the directory or file to check. @type path: C{str} @param keys: the list of desired metadata @type keys: C{list} of C{str} (RRRRtisfileRR:Rt segmentsFromRRR@RAtzipR8textendRRRRLR>R( RZR:RtfilePathtentriesRt fileEntriesRjtfileNametentRK((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRn^s(   % ! cCs7|jg|D]"}t|d||j^qS(s Shortcut method to get stat info on a node. @param filePath: the node to stat. @type filePath: C{filepath.FilePath} @param keys: the stat keys to get. @type keys: C{iterable} t_stat_(trestatR tstatinfo(RZRRtk((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs tst_sizeRtst_nlinktst_mtimecCsHtdk r;ytj|jdSWq;tk r7q;Xnt|jS(Ni(RRRRtKeyErrorRu(RZtst((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt _stat_owners   cCsHtdk r;ytj|jdSWq;tk r7q;Xnt|jS(Ni(RRtgetgrgidtst_gidRRu(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt _stat_groups   cCst|jtj@S(N(tboolRRtS_IFDIR(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_stat_directorys(((R.R/R0RR=RXRRRRRRRRRvRRnRtoperatort attrgettert _stat_sizet_stat_permissionst_stat_hardlinkst_stat_modifiedRRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs,             $  RcBs-eZeedZdZdZRS(cCs||_t|_dS(N(RRMt_send(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRXs cCst|_|jj|S(N(RPR!RR(RZt passthrough((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_closes  cCsN|j stdt|_tjj|j|}|j|j|S(Ns0Can only call IReadFile.send *once* per instance( R!RRPRt FileSendertbeginFileTransferRRR#(RZRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs  (R.R/RRRXR#R(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs   tFTPShellcBs;eZdZdZdZdZdZdZRS(s: An authenticated implementation of L{IFTPShell}. cCsd|j|}y|jWn3ttfk rE}t|j|StjSXtjdSdS(N( RtmakedirsRRRLR>RR@RR(RZR:RRK((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs cCs|j|}|jr.tjt|Sytj|jWn3tt fk rj}t |j |StjSXtj dSdS(N(RRRR@RFRtrmdirR:RRRLR>RR(RZR:RRK((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs  cCs|j|}|jr.tjt|Sy|jWn3ttfk rd}t|j |StjSXtj dSdS(N( RRRR@RJtremoveRRRLR>RR(RZR:RRK((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs  cCs|j|}|j|}ytj|j|jWn3ttfk r`}t|j|Stj SXtj dSdS(N( RRRR:RRRLR>RR@RR(RZRRtfpttpRK((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs cCs|j|}|jr.tjt|Sy|jd}Wn3ttfk ri}t|j |StjSXtj t |S(s Open C{path} for writing. @param path: The path, as a list of segments, to open. @type path: C{list} of C{unicode} @return: A L{Deferred} is returned that will fire with an object implementing L{IWriteFile} if the file is successfully opened. If C{path} is a directory, or if an exception is raised while trying to open the file, the L{Deferred} will fire with an error. R( RRRR@RJRRRRLR>Rt _FileWriter(RZR:RRRK((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs   (R.R/R0RRRRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR&s    R,cBs-eZeedZdZdZRS(cCs||_t|_dS(N(RRMt_receive(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRXs cCs5|j stdt|_tjt|jS(Ns4Can only call IWriteFile.receive *once* per instance(R-RRPRRRR(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR"s cCs tjdS(N(RRR(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR(s(R.R/RRRXRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR,s   t BaseFTPRealmcBs6eZdZeejdZdZdZRS(s{ Base class for simple FTP realms which provides an easy hook for specifying the home directory for each user. cCstj||_dS(N(R Rt anonymousRoot(RZR/((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRX4scCstd|jfdS(s Return a L{FilePath} representing the home directory of the given avatar. Override this in a subclass. @param avatarId: A user identifier returned from a credentials checker. @type avatarId: C{str} @rtype: L{FilePath} s$%r did not override getHomeDirectoryN(tNotImplementedErrort __class__(RZtavatarId((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytgetHomeDirectory8s cGsxl|D]d}|tkr|tjkr:t|j}nt|j|}t|t|ddfSqWtddS(NRcSsdS(N(R(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRPNss3Only IFTPShell interface is supported by this realm( R=Rt ANONYMOUSRR/R&R3R R0(RZR2tmindRtifaceRA((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt requestAvatarFs  ( R.R/R0RRtIRealmRXR3R7(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR.-s    tFTPRealmcBs#eZdZddZdZRS(s" @type anonymousRoot: L{twisted.python.filepath.FilePath} @ivar anonymousRoot: Root of the filesystem to which anonymous users will be granted access. @type userHome: L{filepath.FilePath} @ivar userHome: Root of the filesystem containing user home directories. s/homecCs&tj||tj||_dS(N(R.RXR RtuserHome(RZR/R:((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRX]scCs|jj|S(s Use C{avatarId} as a single path segment to construct a child of C{self.userHome} and return that child. (R:R(RZR2((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR3bs(R.R/R0RXR3(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR9Ts tSystemFTPRealmcBseZdZdZRS(s L{SystemFTPRealm} uses system user account information to decide what the home directory for a particular avatarId is. This works on POSIX but probably is not reliable on Windows. cCsAtjjd|}|jdr4tjntj|S(sx Return the system-defined home directory of the system user account with the name C{avatarId}. t~(RR:t expanduserR5RDRER R(RZR2R:((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR3rs(R.R/R0R3(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR;kstConnectionLostcBseZRS((R.R/(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR>st CommandFailedcBseZRS((R.R/(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR?st BadResponsecBseZRS((R.R/(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR@stUnexpectedResponsecBseZRS((R.R/(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRAstUnexpectedDatacBseZRS((R.R/(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRBst FTPCommandcBs eZdddZdZRS(icCs7||_tj|_d|_||_d|_dS(Ni(ttextRRRtreadytpublicRttransferDeferred(RZRDRF((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRXs    cCs |jr|jj|ndS(N(RFRR(RZR ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR@s N(R.R/RRXR@(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRCstProtocolWrappercBs,eZdZdZdZdZRS(cCs||_||_dS(N(toriginalR(RZRIR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRXs cCs|jj|dS(N(RItmakeConnection(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRJscCs|jj|dS(N(RIR(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs$|jj||jjddS(N(RIRRRR(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs(R.R/RXRJRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRHs   tIFinishableConsumercBseZdZdZRS(sA A Consumer for producers that finish. @since: 11.0 cCsdS(s6 The producer has finished producing. N((((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytfinishs(R.R/R0RL(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRKstSenderProtocolcBsZeZeedZdZdZdZdZdZ dZ dZ RS(cCs"tj|_tj|_dS(N(RRtconnectedDeferredR(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRXscCstddS(Ns<Received data from the server on a send-only data-connection(RB(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs'tjj|||jj|dS(N(RtProtocolRJRNR(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRJscCs9|jtjr%|jjdn|jj|dS(Nsconnection done(R RtConnectionDoneRRR(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs|jj|dS(N(RR(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs|jj||dS(sA Register the given producer with our transport. N(RR(RZRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs|jjdS(s@ Unregister the previously registered producer. N(RR(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs|jjdS(N(RR(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRLs( R.R/RRKRXRRJRRRRRL(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRMs        c Cstjdd|}g|jdD]}t|j^q%}x;|D]3}|dksh|dkrJtd||qJqJW|\}}}}} } d||||f} t| d>t| } | | fS( se Decode an FTP response specifying a host and port. @return: a 2-tuple of (host, port). s[^0-9, ]R3RYiis Out of ranges %s.%s.%s.%si(tretsubR6R_tstripR( RtabcdefRtparsedtxtatbtcRRKRRSRT((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytdecodeHostPorts. cCs:|jdt|d?t|dg}dj|S(NR2iiRY(R6RuR(RSRTtnumbers((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRV s-cCs|jtj|jjS(N(RCRt FirstErrorR t subFailure(R ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_unwrapFirstError stFTPDataPortFactorycBseZdZdZdZRS(s_ Factory for data connections that use the PORT command (i.e. "active" transfers) icCs ||j_|jj|jS(N(RRRTR(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR s  (R.R/R0tnoisyR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR_ stFTPClientBasiccBseZdZeZdZdZdZdZdZ dZ dZ dd Z d Z d Zd Zd ZRS(s' Foundations of an FTP client. cCsVg|_d|_tjj|j|_|jj|j g|_ d|_ dS(Ni( t actionQueueRtgreetingRRRWt _cb_greetingt nextDeferredRR@R^t_failed(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRX& s    cCs|j|dS(s8 Give an error to any queued deferreds. N(t_fail(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR@. scCs|jr |Sd|_|jr_y&|jjtjtd|Wq_tjk r[q_Xnx0|jD]%}|j tjtd|qiW|S(s/ Errback all queued deferreds. isFTP connection lost( RfReRR tFailureR>RtAlreadyCalledErrorRbR@(RZRt ftpCommand((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRg4 s   &#cCs ||_dS(N(Rc(RZRc((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRdE scCs'|dkrdStjj||dS(s> (Private) Sends a line, unless line is None. N(RRt LineReceiverR(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRH s cCs|j}|dkr%d|_dS|jsa|jjd|tjd|jd|_dS|j dkr|j |n|j rt j d|j n|j|_|j|j dS(sD (Private) Processes the next command in the queue. Nig?tPORTs<-- %s(tpopCommandQueueRReRERbtinsertRRtsendNextCommandRDtgeneratePortCommandRtR R[RR(RZRj((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRoP s       cCsT|jj|t|jdkrP|jdk rP|jdkrP|jndS(s Add an FTPCommand object to the queue. If it's the only thing in the queue, and we are connected and we aren't waiting for a response of an earlier command, the command will be sent immediately. @param ftpCommand: an L{FTPCommand} iN(RbR8RRRReRo(RZRj((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt queueCommandh s $icCs#t||}|j||jS(su Queues a string to be issued as an FTP command @param command: string of an FTP command to queue @param public: a flag intended for internal use by FTPClient. Don't change it unless you know what you're doing. @return: a L{Deferred} that will be called when the response to the command has been received. (RCRqR(RZR!RFRj((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytqueueStringCommandw s  cCs!|jr|jjdSdSdS(sR Return the front element of the command queue, or None if empty. iN(RbR7R(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRm s csg}jd|dd}|j||dk rtd|ddj|jjfd}|j|nx.|D]&}|jj|jdqWdS(s  Login: send the username, send the password. If the password is C{None}, the PASS command won't be sent. Also, if the response to the USER command has a response code of 230 (User logged in), then PASS won't be sent either. sUSER RFisPASS cs*|djdr&jjn|S(Nit230(R5RbR)(R^(t passwordCmdRZ(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytcancelPasswordIfNotNeeded scSsdS(N(R(RV((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRP sN( RrR8RRCRqRRWRR@(RZR<RMt deferredst userDeferredRuR((RtRZs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt queueLogin s     cCs;|jrtjd|n|jj|tjd|}|sIdS|dd!}|ddkrjdS|jdkr|j t |jdS|j}g|_|dd kr|jj |ne|dd kr|jj t jt|n3tjd |f|jj t jt||jdS(sM (Private) Parses the response messages from the FTP server. s--> %ss\d{3} Niit1t2t3t4t5s$Server sent invalid response code %s(RzR{(R|R}(RtR R[R^R8RQtmatchReRR@RARRR RhR?R@Ro(RZRt codeIsValidRR^((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR s*    "cCs|j|dS(N(Rg(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR s(R.R/R0RMRtRXR@RgRdRRoRqRrRmRxRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRa s         # -t_PassiveConnectionFactorycBs)eZeZdZdZdZRS(cCs ||_dS(N(t protoInstance(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRX scCs||j_|jS(N(RR(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR s cCs&td|}|jjj|dS(NsConnection Failed(RnRRR(RZRRRK((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR s(R.R/RMR`RXRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR s  t FTPClientcBseZdZejZddddZdZdZdZ dZ d Z d Z d Z d d ZeZd dZeZdZdZdZdZdZdZdZdZdZdZdZdZRS(sI L{FTPClient} is a client implementation of the FTP protocol which exposes FTP commands as methods which return L{Deferred}s. Each command method returns a L{Deferred} which is called back when a successful response code (2xx or 3xx) is received from the server or which is error backed if an error response code (4xx or 5xx) is received from the server or if a protocol violation occurs. If an error response code is received, the L{Deferred} fires with a L{Failure} wrapping a L{CommandFailed} instance. The L{CommandFailed} instance is created with a list of the response lines received from the server. See U{RFC 959} for error code definitions. Both active and passive transfers are supported. @ivar passive: See description in __init__. Rstwisted@twistedmatrix.comicCs*tj||j||||_dS(sy Constructor. I will login as soon as I receive the welcome message from the server. @param username: FTP username @param password: FTP password @param passive: flag that controls if I use active or passive data connections. You can also change this after construction by assigning to C{self.passive}. N(RaRXRxtpassive(RZR<RMR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRX s cCs|jj|j|dS(sM Disconnect, and also give an error to any queued deferreds. N(RRRg(RZR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR@ s cCs4tj|}t|tj}|j||S(s Retrieves a file or listing generated by the given command, feeding it to the given protocol. @param commands: list of strings of FTP commands to execute then receive the results of (e.g. C{LIST}, C{RETR}) @param protocol: A L{Protocol} B{instance} e.g. an L{FTPFileListProtocol}, or something that can be adapted to one. Typically this will be an L{IConsumer} implementation. @return: L{Deferred}. (Rt IProtocolRHRRt_openDataConnection(RZtcommandsRtwrapper((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytreceiveFromConnection$ s cCsLtj||||jddd}|j|j|jddS(sg Login: send the username, send the password, and set retrieval mode to binary sTYPE IRFicSsdS(N(R(RV((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRP? sN(RaRxRrRR@(RZR<RMR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRx5 scCs(t}|j||}|j|fS(sQ XXX @return: A tuple of two L{Deferred}s: - L{Deferred} L{IFinishableConsumer}. You must call the C{finish} method on the IFinishableConsumer when the file is completely transferred. - L{Deferred} list of control-connection responses. (RMRRN(RZRR<R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytsendToConnectionA s c sg|D]}t|dd^q}tjg|D]}|j^q2dtdt}|jtjrd gfd}td}j ||jj |jj ||jjg} tj| dtdt} | jtd} | j | ntd} j| _ | _| jj| j jj | d | _d | _ |j| d || j| j g} tj| dtdt} | jtx|D]}j |qW| S( s5 This method returns a DeferredList. RFitfireOnOneErrbackt consumeErrorscsCt|dd\}}t}j|||d TARGET - filename: e.g. 'LINK' - linktarget: e.g. 'TARGET' -rw-r--r-- 1 root other 531 Jan 29 03:26 N S -> L S - filename: e.g. 'N S' - linktarget: e.g. 'L S' @ivar files: list of dicts describing the files in this listing s^(?P.)(?P.{9})\s+(?P\d*)\s*(?P\S+)\s+(?P\S+)\s+(?P\d+)\s+(?P...\s+\d+\s+[\d:]+)\s+(?P.{1,}?)( -> (?P[^\r]*))?\r?$s cCs g|_dS(N(tfiles(RZ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRX scCs<|j|}|dkr+|j|n |j|dS(N(tparseDirectoryLineRt unknownLinetaddFile(RZRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR s cCs|jj|}|dkr"dS|j}|djdd|d s (R0RRRQRRR>RNRRRt ImportErrorRtzope.interfaceRRttwistedRRRRRRRttwisted.protocolsRR ttwisted.pythonR R R ttwisted.python.compatR t twisted.credRDRRRtRESTART_MARKER_REPLYtSERVICE_READY_IN_N_MINUTESRhRRRRZtCMD_NOT_IMPLMNTD_SUPERFLUOUStSYS_STATUS_OR_HELP_REPLYRt DIR_STATUSRtHELP_MSGRtSVC_READY_FOR_NEW_USERRtSVC_CLOSING_CTRL_CNXRt DATA_CNX_OPEN_NO_XFR_IN_PROGRESStCLOSING_DATA_CNXRiRUtENTERING_EPSV_MODERKRIRtRyRR;R:tNEED_ACCT_FOR_LOGINRtSVC_NOT_AVAIL_CLOSING_CTRL_CNXRR\R}tREQ_ACTN_ABRTD_FILE_UNAVAILtREQ_ACTN_ABRTD_LOCAL_ERRtREQ_ACTN_ABRTD_INSUFF_STORAGERgRiRkRRqRmR+RstNEED_ACCT_FOR_STORR_RbRaRcRRdRet PAGE_TYPE_UNKtEXCEEDED_STORAGE_ALLOCtFILENAME_NOT_ALLOWEDR\RWR-R=RLRURVRAR`RDRFRHRJRfRhRjRlRnRoRpRrRwRRRORt ClientFactoryRRRRkRt TimeoutMixinRRRR=RRRRRRR&R,R.R9R;R>R?R@RARBRCRHRRKRMRZRVR^t ServerFactoryR_RaRRRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyts         ("          {_"4*  7Z'$ /   k