Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/protocols/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyc


OvNc
@sdZddlZddlZddlZddlZddlZddlZddlZddlZyddl	Z	ddl
Z
Wnek
reZ	Z
nXddl
mZmZddlmZddlmZmZmZmZmZddlmZmZddlmZmZmZddlm Z dd	l!mZ"m#Z#m$Z$m%Z%d
Z&dZ'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]i8dBe&6dCe'6dDe(6dEe)6dFe*6dGe+6dHe,6dIe-6dJe.6dKe/6dLe06dMe16dNe26dOe46dPe36dQe56dRe66dSe76dTe86dUe96dVe:6dWe;6dXe<6dYe=6dZe>6d[e?6d\e@6d]eA6d^eB6d_eC6d`eD6daeE6dbeF6dceG6ddeH6deeI6dfeJ6dgeK6dheL6dieM6djeN6dkeO6dleP6dmeQ6dneR6doeS6dpeT6dqeU6dreV6dseW6dteY6dueZ6dveX6dwe[6dxe\6dye]6Z^dze_fd{YZ`d|Zad}Zbd~e_fdYZcdecfdYZddecfdYZedecfdYZfdecfdYZgdecfdYZhdecfdYZidecfdYZjdecfdYZkdecfdYZldecfdYZmde_fdYZnde_fdYZodecfdYZpdecfdYZqdZreddddddddddddg
ZsdetejufdYZvdejwfdYZxdetfdYZydetfdYZzdej{fdYZ|detej{ej}fdYZ~dejfdYZdefdYZdefdYZdefdYZdZddZdetfdYZdetfdYZdefdYZdetfdYZdfdYZdefdYZdefdYZdenfdYZdenfdYZdenfdYZdenfdYZdenfdYZdfdYZdejufdYZdejfdYZdejufdYZdZdZdZdejfdYZdej{fdYZdejwfdYZdefdYZdej{fdYZdZdS(s 
An FTP protocol implementation
iN(t	Interfacet
implements(t	copyright(treactort
interfacestprotocolterrortdefer(tbasictpolicies(tlogtfailuretfilepath(treduce(Rtportaltcredentialstcheckerst100t120t125t150s200.1s200.2s200.3t202t211t212t213t214t215s220.1s220.2s221.1s221.2t225s226.1s226.2t227t229s230.1s230.2t250s257.1s257.2s331.1s331.2t332t350s421.1s421.2t425t426t450t451t452t500t501t502t503t504s530.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.s200 PORT OKs5202 Command not implemented, superfluous at this sites211 System status replys212 %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&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 allowedtInvalidPathcBseZdZRS(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.pyterrnoToFailurestFTPCmdErrorcBs 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.pyRQscCst|j|jS(sA
        Generate a FTP response message for this error.
        (tRESPONSEt	errorCodeRR(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytresponses(R0R1R2RQRW(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyROs	RCcBseZdZeZRS(sH
    Raised when trying to access a non existent file or directory.
    (R0R1R2tFILE_NOT_FOUNDRV(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRCstAnonUserDeniedErrorcBseZdZeZRS(s[
    Raised when an anonymous user issues a command that will alter the
    filesystem
    (R0R1R2tANON_USER_DENIEDRV(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRYsRFcBseZdZeZRS(s[
    Raised when access is attempted to a resource to which access is
    not allowed.
    (R0R1R2tPERMISSION_DENIEDRV(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRFsRHcBseZdZeZRS(sE
    Raised when RMD is called on a path that isn't a directory.
    (R0R1R2tIS_NOT_A_DIRRV(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRHsRJcBseZdZeZRS(sA
    Raised when attempted to override an existing resource.
    (R0R1R2tFILE_EXISTSRV(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRJsRLcBseZdZeZRS(sC
    Raised when DELE is called on a path that is a directory.
    (R0R1R2tIS_A_DIRRV(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRLstCmdSyntaxErrorcBseZdZeZRS(s0
    Raised when a command syntax is wrong.
    (R0R1R2t
SYNTAX_ERRRV(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR_$stCmdArgSyntaxErrorcBseZdZeZRS(s^
    Raised when a command is called with wrong value or a wrong number of
    arguments.
    (R0R1R2tSYNTAX_ERR_IN_ARGSRV(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRa,stCmdNotImplementedErrorcBseZdZeZRS(sF
    Raised when an unimplemented command is given to the server.
    (R0R1R2tCMD_NOT_IMPLMNTDRV(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRc5stCmdNotImplementedForArgErrorcBseZdZeZRS(se
    Raised when the handling of a parameter for a command is not implemented by
    the server.
    (R0R1R2tCMD_NOT_IMPLMNTD_FOR_PARAMRV(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRe=stFTPErrorcBseZRS((R0R1(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRgFstPortConnectionErrorcBseZRS((R0R1(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRhKstBadCmdSequenceErrorcBseZdZeZRS(sS
    Raised when a client sends a series of commands in an illogical sequence.
    (R0R1R2tBAD_CMD_SEQRV(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRiPstAuthorizationErrorcBseZdZeZRS(s2
    Raised when client authentication fails.
    (R0R1R2tAUTH_FAILURERV(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRkXscGs!tjdt|dtdS(NsdebugDeferred(): %stdebug(R
RTtstrtTrue(RSt_((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt
debugDeferred`stJantFebtMartAprtMaytJuntJultAugtSeptOcttNovtDectDTPcBseZeejeZdZdZ	dZ
dZdZdZ
dZdZdZdZdZdZd	Zd
ZdZdZd
ZdZRS(cCs)t|_|jjjdg|_dS(N(RotisConnectedtfactorytdeferredtcallbacktNonet_buffer(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytconnectionMadevs	cCs/t|_|jdk	r+|jjdndS(N(tFalseRt_onConnLostRR(RStreason((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytconnectionLost{s	cCs|jj|ddS(Ns
(t	transporttwrite(RStline((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytsendLinesc	Csd}	d}
d}|i|r*dp-dd6|	|d6|d6|d	 d
6|d	 d6|d6|
tj|d
6|d6S(NcSsBdjgtdD](}|d|?@r5d|dp8d^qS(NR5i	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	directorytpermissionst	hardlinksitownertgrouptsizetdatetname(RR(RSRRRRRtmodifiedRRRRtformat((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_formatOneListResponses		
cCs|j|j||dS(N(RR(RSRRW((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytsendListResponsescCs|jj||S(N(RtregisterProducer(RStproducert	streaming((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs|jj|jjdS(N(RtunregisterProducertloseConnection(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs
cCs)|jr|jj|StddS(NsCrap damn crap damn crap damn(RRRRP(RStdata((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs	cCs/y|jj|Wn|jjnXdS(N(t_consRRterrback(RStbytes((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt
_conswritescCs3|jdk	r|j|n|jj|dS(N(RRRRR:(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytdataReceivedscCs |jjd|_|`|S(N(RRRR(RStignored((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(RRtAssertionErrorRRoRRRRtDeferredRtaddBothRRtsucceed(RStconstchunkR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytregisterConsumers			
	cCs|jjdS(N(RtresumeProducing(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs|jjdS(N(RtpauseProducing(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs|jjdS(N(Rt
stopProducing(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRsN(R0R1RRt	IConsumerRRRRRRRRRRRRRRRRRRRRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR~ms(
				 										t
DTPFactorycBszeZdZeZeZeZeZeZ	dddZdZ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(sConstructor
        @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(
tpitpeerHostRRRRtdelayedCallttwisted.internetRt_reactor(RSRRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRQs			cCsmtjddt|j|jk	r)dS|j|_|jt}||_	|j
|_
||j
_|S(NsDTPFactory.buildProtocolRm(R
RTRot_statet_IN_PROGRESSRt	_FINISHEDt
cancelTimeoutR~RRtdtpInstance(RStaddrtp((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt
buildProtocol	s
		cCs!tjddt|jdS(NsdtpFactory.stopFactoryRm(R
RTRoR(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytstopFactoryscCsatjd|j|jk	r#dS|j|_|j}d|_|jtt	j
ddS(Ns$timed out waiting for DTP connectionsDTPFactory timeout(R
RTRRt_FAILEDRRRRhRtTimeoutError(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyttimeoutFactorys
		cCsE|jdk	rA|jjrAtjddt|jjndS(Nscancelling DTP timeoutRm(RRtactiveR
RTRotcancel(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR)scCs0tjd||jj||j|_dS(Ns'DTPFactory.setTimeout set to %s seconds(R
RTRt	callLaterRR(RStseconds((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt
setTimeout/scCsK|j|jk	rdS|j|_|j}d|_|jt|dS(N(RRRRRRRh(RSt	connectorRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytclientConnectionFailed4s		N(R0R1R2tobjectRRRRRt	peerCheckRRQRRRRRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs								tASCIIConsumerWrappercBseZdZdZRS(cCss||_|j|_|j|_tjdksQttjdksQtdtjdkro|j|_ndS(Ns
is6Unsupported platform (yea right like this even exists)(RRRtostlineseptlenRR(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRQ@s	0cCs|jj|jtjdS(Ns
(RRtreplaceRR(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRJs(R0R1RQR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR?s	
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(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRQYscCs||_|stdS(N(RR(RSRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR]s	cCsd|_|jjdS(N(RRRtclose(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRbs	cCs|jj|dS(N(RR(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRgs(
R0R1R2RRRRQRRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyROs
			tFTPOverflowProtocolcBseZdZdZRS(s:FTP mini-protocol for when there are too many connections.cCs"|jtt|jjdS(N(RRUtTOO_MANY_CONNECTIONSRR(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRns(R0R1R2R(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRlstFTPcBseZdZeZed\ZZZZ	dZ
d)Zd)Z
d)Zd)Zd)ZeZeddZejZdZdZdZdZd	Zd
ZdZdZd
Z dZ!dZ"ddZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1d Z2d!Z3d"Z4d#Z5d$Z6d%Z7d&Z8d'Z9d(Z:RS(*s
    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
iicGst||}|j|dS(N(RUR(RStkeytargsRT((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytreplyscCs6|j|_|j|j|jt|jjdS(N(tUNAUTHtstateRttimeOutRtWELCOME_MSGRtwelcomeMessage(RS((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(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs	

$	cCs|jjdS(N(RR(RS((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
jdt
j|jt
ddS(Nis
takes exactlyis%s requires an argument.sUnexpected FTP errorsinternal server error(tcheckRORtvalueRWt	TypeErrorRtfindRR`R
RTterrtREQ_ACTN_NOT_TAKEN(R(RStcmd(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt
processFaileds

cs?t|trj|n|dk	r;j|ndS(N(t
isinstancettupleRR(tresult(RS(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytprocessSucceededscsjsjndS(N(tdisconnectedR(R(RS(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytallDones	t ii(Ri((tresetTimeoutRRRt
maybeDeferredtprocessCommandtaddCallbackst
addErrbackR
RRRRR(	RSRRR
Rt
spaceIndexRRR((RSRs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytlineReceiveds 


cGs|j}|j|jkrT|dkr7|j|S|dkrMtdfStSn|j|jkr|dkr|j|StdfSn|j|jkrt	|d|d}|dk	r||Stjt
|S|j|jkr|dkr|j|StdfSndS(NtUSERtPASSsUSER required before PASSsPASS required after USERtftp_tRNTOsRNTO required after RNFR(tupperRRtftp_USERRjt
NOT_LOGGED_INtINAUTHtftp_PASStAUTHEDtgetattrRRRBRctRENAMINGtftp_RNTO(RSRtparamstmethod((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs(





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.
        R5sNo port available in range %sN(tpassivePortRanget
listenFactoryRtCannotListenError(RSRtportntdtpPort((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt
getDTPPorts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(RRBR_t_userRRRtallowAnonymoust
userAnonymoustGUEST_NAME_OK_NEED_EMAILtUSR_NAME_OK_NEED_PASS(RStusername((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	IFTPShellRRRtworkingDirectoryRR(t.0t	interfacetavatarR(RSR(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_cbLogin-s			cs,|jtjtjj_tdS(N(ttrapt
cred_errortUnauthorizedLogintUnhandledCredentialsRRRk(R(RS(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_ebLogin5sN(RR+R*R,Rt	AnonymoustGUEST_LOGGED_IN_PROCEEDtUsernamePasswordtUSR_LOGGED_IN_PROCEEDRtloginRR0R(RStpasswordtcredsR5R:R((RSRs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs!	cCs|jdk	r|jntd||_|jj|j|j|j|_|jj	j
}|jj	j}|jt
t|||jjjdS(sRequest 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.pyt<lambda>VsN(RRRRRt
dtpTimeoutR)R(RtgetHostthosttportRtENTERING_PASV_MODEtencodeHostPortRtaddCallback(RSRFRG((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_PASV?s
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	connectedfscSs|jttS(N(R6RhtCANT_OPEN_DATA_CNX(R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt
connFailedhs
(tmaptintR8RRRRRRtgetPeerRFRRDRt
connectTCPR(RR(RStaddressRtipRGRNRP((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_PORTYs
$		R5c
sjdksjjr/tjtdS|dkrDd}n|dkrYd}n|dkrnd}n|dkrd}nfd}ytj|}Wn!tk
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-aR5s-aLs-Ls-lacsNjtx'|D]\}}jj||qWjjjtfS(N(RtDATA_CNX_ALREADY_OPEN_START_XFRRRRRtTXFR_COMPLETE_OK(tresultsRtattrs(RS(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt
gotListings

RRRRRRRN(ssizes	directoryspermissionss	hardlinkssmodifiedsownersgroup(
RRRRRBRiR?R1R/RCRtlistRJ(RSR<R\tsegmentsR((RSs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_LISTns*
				
		
cs5jd
ksjjr/tjtdSytj|Wn!tk
rhtjt	|SXfd}fd}fd}rddksddksddkrd	dkrj
jd }|j|n,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 RETRcsKjtx$|D]\}}jj|qWjjjtfS(s
            Send, line by line, each 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.

            @rtype: C{tuple}
            @return: A C{tuple} containing the status code for a successful
                transfer.
            (RRXRRRRRY(RZRR(RS(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytcbLists


csdjtx=|D]5\}}tj|drjj|qqWjjjtfS(Ni(RRXtfnmatchRRRRRY(RZRR(RSR^(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytcbGlobs
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.

            @rtype: C{tuple}
            @returns: A C{tuple} containing the status code for a successful
                transfer.
            (RRRRY(RZ(RS(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytlistErrst*it?t[t]N(RRRRRBRiR?R1R/RCRR]RJR(RSR<R`RbRcR((RSR^s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_NLSTs&

  

cseytj|Wn!tk
r9tjt|SXfd}jjj|S(Ncs_tfS(N(R1tREQ_FILE_ACTN_COMPLETED_OK(R	(RSR^(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt
accessGranteds	(	R?R1R/RRBRCRtaccessRJ(RSR<Rj((RSR^s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_CWDs
cCs
|jdS(Ns..(Rl(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_CDUPscCstddj|jfS(NR3(t	PWD_REPLYRR1(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_PWDscsjdkrtdnytj|Wn!tk
rWtjt|SXj	dfd}j
stjn	jddfd}fd}jj
}|j|||j||S(Ns!PORT or PASV required before RETRcsjjj|S(N(RRR(R	(RS(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt
enableTimeoutscSstfS(N(RY(R	((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytcbSentscSs!tjdtj|tfS(Ns7Unexpected error attempting to transmit file to client:(R
RTRtCNX_CLOSED_TXFR_ABORTED(R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytebSent!s

csLjjrjtn
jt|j}|j|S(N(RRRRXtFILE_STATUS_OK_OPEN_DATA_CNXtsendR(tfileR(RRSRqRs(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytcbOpened&s
csm|jttts2tjdtj|n|jtrZ|jj	dj
fStdj
fS(Ns:Unexpected error attempting to open file for transmission:R3(RRFRCRHR
RTRRORRVRRX(R(tnewsegs(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytebOpened1s
(RRRiR?R1R/RRBRCRtbinaryRRtopenForReadingRR(RSR<RpRwRyR((RRxRSRsRqs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_RETRs&

				
csjdkrtdnytj|Wn!tk
rWtjt|SXj	dfd}ddfdfd}fd}j
j}|j|||j
||S(Ns!PORT or PASV required before STORcsjjj|S(N(RRR(R	(RS(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRpPscSstfS(N(RY(R	((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRqTscSs4tjdtj||jtr-|StfS(Ns,Unexpected error receiving file from client:(R
RTRRRORr(R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRsWs


csWjst|}njj|}jjrFjtn
jt|S(N(RzRRRRRRXRt(RR(RS(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt
cbConsumer^s	
csCj}|j|jfd|j|S(Ncs
jS(N(R(R(Rv(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRCos(treceiveRJR(RvR(RqRsR}(Rvs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRwls

csp|jttts2tjdtj|nt|jt	r]|jj
djfStdjfS(Ns4Unexpected error attempting to open file for upload:R3(
RRFRCRHR
RTRRRRORVRRX(R(Rx(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRyss
(RRRiR?R1R/RRBRCRRtopenForWritingRR(RSR<RpRwRyR((RxRSRsR}Rqs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_STORAs"

		
cCs_yt|j|}Wn!tk
r9tjt|SXd}|jj|dj|S(NcSs|\}tt|fS(N(tFILE_STATUSRn(R2R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytcbStatsR(ssize(	R?R1R/RRBRCRtstatRJ(RSR<RxR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_SIZEs
	cCs_yt|j|}Wn!tk
r9tjt|SXd}|jj|dj|S(NcSs(|\}ttjdtj|fS(Ns%Y%m%d%H%M%S(RRtstrftimeR(R2R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRsR(smodified(	R?R1R/RRBRCRRRJ(RSR<RxR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_MDTMs
	cCsZ|j}|rSt|d|dd}|dk	rF||dS|j|StfS(Nttype_ii(RRRttype_UNKNOWNR`(RSttypeRtf((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_TYPEs
cCsF|dks|dkr/t|_td|fStjt|SdS(NR5tNtA(RRztTYPE_SET_OKRRBRa(RStcode((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyttype_As	cCs6|dkrt|_tdfStjt|SdS(NR5tI(RoRzRRRBRa(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyttype_Is	
cCstjt|S(N(RRBRe(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCstS(N(t
NAME_SYS_TYPE(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_SYSTscCs2|j}|dkrtfStjt|S(NtF(RtCMD_OKRRBRe(RSt	structureR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_STRUscCs2|j}|dkrtfStjt|S(NtS(RRRRBRe(RSRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_MODEscs\yt|j}Wn!tk
r9tjtSX|jj|jfdS(Ncs
tfS(N(t	MKD_REPLY(RB(R<(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRCs(	R?R1R/RRBRCRt
makeDirectoryRJ(RSR<Rx((R<s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_MKDs

cCsVyt|j|}Wn!tk
r9tjt|SX|jj|jdS(NcSstfS(N(Ri(RB((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRCs(	R?R1R/RRBRCRtremoveDirectoryRJ(RSR<Rx((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_RMDs

cCsVyt|j|}Wn!tk
r9tjt|SX|jj|jdS(NcSstfS(N(Ri(RB((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRCs(	R?R1R/RRBRCRt
removeFileRJ(RSR<Rx((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_DELEs

cCstfS(N(R(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_NOOPscCs||_|j|_tfS(N(t	_fromNameR Rt"REQ_FILE_ACTN_PENDING_FURTHER_INFO(RStfromName((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
||jdS(NcSstfS(N(Ri(RB((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRCs(RRRR?R1R/RRBRCRtrenameRJ(RSttoNameRtfromsegsttosegs((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR!s	
cCs'|jt|jjt|_dS(N(RtGOODBYE_MSGRRRoR(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytftp_QUITs

cCstjddttj|j|jd}|_tjj|rU|jn8tj	j|rt|j
ntstd|f|j
jd|_
|jdk	rd|_ndS(s'call when DTP connection exits
        RRms@dtpPort should be an IListeningPort or IConnector, instead is %rN(R
RTRoR(RRtIListeningPortt
providedByt
stopListeningt
IConnectort
disconnectRRRRR(RSR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs


	N(;R0R1R2RRRRRRR RDRRRRR(RRoRztxrangeR$Rt	listenTCPR%RRRRRRR)RRRKRWR_RhRlRmRoR|RRRRRRRRRRRRRRRR!RR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRss^						+				!		.	S				<	B																
	t
FTPFactorycBsleZdZeZeZeZdZ	dZ
dej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(RR,t	instances(RSRR,((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRQ's		cCsUtjj||}|dk	rQ|j|j_|j|j_|j|j_n|S(N(R	tLimitTotalConnectionsFactoryRRRtwrappedProtocolRR$(RSRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR,scCsFg|jD]$}|jdk	r
|jd^q
tjj|dS(N(RRRRR	RR(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR4s2N(R0R1R2RRRtoverflowProtocolRoR+R,RRtversionRRR$RRQRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs		R0cBseeZdZdZdZdZdZdZd
dZddZ	dZ
d	ZRS(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.pyREscCsdS(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.pyRQscCsdS(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.pyR]scCsdS(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.pyRiscCsdS(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.pyRkxscCsdS(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.pyRscCsdS(sP
        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}

        @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
        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.pyR]scCsdS(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.pyR{scCsdS(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.pyRs(((R0R1R2RRRRRkRR]R{R(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR0=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.pyRus(R0R1R2Ru(((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.pyR~scCsdS(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(R0R1R2R~R(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs	cCseg}tj|}|j|jx9tjD]+}|j|jkr2|j|jq2q2W|S(sZReturn the primary and supplementary groups for the given UID.

    @type uid: C{int}
    (	tpwdtgetpwuidR:tpw_gidtgrptgetgralltpw_nametgr_memtgr_gid(tuidR	tpwenttgrent((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
ValueErrorRR<texistsRotst_modetst_uidRRkR
RTtgetuid(
RtgidtspathRtusrRtothtamodeRkR>((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_testPermissionss8									
	tFTPAnonymousShellcBseZdZeedZdZdZdZdZ	dZ
dZdZd	Z
d
ZddZdd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(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRQBscCsttjj||jS(N(R
RtFilePathtchildR(RSR<((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_pathFscCstjtS(N(RRBRY(RSR<((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRJscCstjtS(N(RRBRY(RSR<((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRNscCstjtS(N(RRBRY(RSR<((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRRscCstjtS(N(RRBRY(RSRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRVscCs|j|}tjtS(N(RRRBRY(RSR<((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR~ZscCs|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(RtisdirRRBRLtopentIOErrortOSErrorRNR@Rt_FileReader(RSR<RRRM((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR{_scCstjtdS(sa
        Reject write attempts by anonymous users with
        L{PermissionDeniedError}.
        sSTOR not allowed(RRBRF(RSR<((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRyscCs|j|}|js.tjt|Sy|jWn3ttfk
rd}t|j	|StjSXtj
dSdS(N(RRRRBRCtlistdirRRRNR@RR(RSR<RRM((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRkscCs|j|}|jrwy|j||}Wn3ttfk
rY}t|j|StjSXtj	|Sn|j
||jdSdS(NcSs|ddS(Nii((tres((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRCs(RRt	_statNodeRRRNR@RRBRR]RJ(RSR<RRt
statResultRM((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs@|j|}|jrL|j}g|D]}|j|^q.}nL|jrtjj|j|j	g}|g}nt
jt|Sg}xt
||D]\}}g}	|j||	f|ry|	j|j||Wq/ttfk
r}
t|
j|St
jSXqqWt
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segmentsFromRRRBRCtzipR:textendRRRRNR@R(RSR<RtfilePathtentriesRtfileEntriesRZtfileNametentRM((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR]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_(trestatRtstatinfo(RSRRtk((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs

tst_sizeRtst_nlinktst_mtimecCsHtdk	r;ytj|jdSWq;tk
r7q;Xnt|jS(Ni(RRRRtKeyErrorRn(RStst((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_stat_owners
cCsHtdk	r;ytj|jdSWq;tk
r7q;Xnt|jS(Ni(RRtgetgrgidtst_gidRRn(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_stat_groups
cCst|jtj@S(N(tboolRRtS_IFDIR(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_stat_directorys(((R0R1R2RR0RQRRRRRR~R{RRkRR]Rtoperatort
attrgettert
_stat_sizet_stat_permissionst_stat_hardlinkst_stat_modifiedRRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR8s,
										$	
				RcBs-eZeedZdZdZRS(cCs||_t|_dS(N(RRt_send(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRQs	cCst|_|jj|S(N(RoRRR(RStpassthrough((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(	RRRoRt
FileSendertbeginFileTransferRRR(RSRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRus
	(R0R1RRRQRRu(((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(
RtmakedirsRRRNR@RRBRR(RSR<RRM((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR	scCs|j|}|jr.tjt|Sytj|jWn3tt	fk
rj}t
|j|StjSXtjdSdS(N(RRRRBRHRtrmdirR<RRRNR@RR(RSR<RRM((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs|j|}|jr.tjt|Sy|jWn3ttfk
rd}t|j	|StjSXtj
dSdS(N(RRRRBRLtremoveRRRNR@RR(RSR<RRM((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR&scCs|j|}|j|}ytj|j|jWn3ttfk
r`}t|j|Stj	SXtj
dSdS(N(RRRR<RRRNR@RRBRR(RSRRtfpttpRM((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR7scCs|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(RRRRBRLRRRRNR@Rt_FileWriter(RSR<RRRM((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRDs(R0R1R2RRRRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs				
RcBs-eZeedZdZdZRS(cCs||_t|_dS(N(RRt_receive(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRQas	cCs5|jstdt|_tjt|jS(Ns4Can only call IWriteFile.receive *once* per instance(RRRoRRRR(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR~es	cCs
tjdS(N(RRR(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRks(R0R1RRRQR~R(((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(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRQwscCstd|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__(RStavatarId((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytgetHomeDirectory{s
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.pyRCss3Only IFTPShell interface is supported by this realm(	R0Rt	ANONYMOUSRRRR!RR(RSR tmindRtifaceR4((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt
requestAvatars
(	R0R1R2RRtIRealmRQR!R%(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRps

		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(RRQRRtuserHome(RSRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRQscCs|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(RSR ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR!s(R0R1R2RQR!(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR's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
expanduserR7R7R8RR(RSR R<((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR!s(R0R1R2R!(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR)stConnectionLostcBseZRS((R0R1(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR,st
CommandFailedcBseZRS((R0R1(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR-stBadResponsecBseZRS((R0R1(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR.stUnexpectedResponsecBseZRS((R0R1(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR/stUnexpectedDatacBseZRS((R0R1(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR0st
FTPCommandcBs eZdddZdZRS(icCs7||_tj|_d|_||_d|_dS(Ni(ttextRRRtreadytpublicRttransferDeferred(RSR2R4((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRQs
			cCs |jr|jj|ndS(N(R4RR(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRBs	N(R0R1RRQRB(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR1stProtocolWrappercBs,eZdZdZdZdZRS(cCs||_||_dS(N(toriginalR(RSR7R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRQs	cCs|jj|dS(N(R7tmakeConnection(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR8scCs|jj|dS(N(R7R(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs$|jj||jjddS(N(R7RRRR(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs(R0R1RQR8RR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR6s			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(R0R1R2R:(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR9stSenderProtocolcBsZeZeedZdZdZdZdZdZ	dZ
dZRS(cCs"tj|_tj|_dS(N(RRtconnectedDeferredR(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRQscCstddS(Ns<Received data from the server on a send-only data-connection(R0(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs'tjj|||jj|dS(N(RtProtocolR8R<R(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR8scCs9|jtjr%|jjdn|jj|dS(Nsconnection done(RRtConnectionDoneRRR(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR scCs|jj|dS(N(RR(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR'scCs|jj||dS(sA
        Register the given producer with our transport.
        N(RR(RSRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR*scCs|jjdS(s@
        Unregister the previously registered producer.
        N(RR(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR0scCs|jjdS(N(RR(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR:6s(R0R1RR9RQRR8RRRRR:(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR;s
							c
Cstjdd|}g|jdD]}t|j^q%}x;|D]3}|dksh|dkrJtd||qJqJW|\}}}}}	}
d||||f}t|	d>t|
}||fS(	s`Decode an FTP response specifying a host and port.

    @return: a 2-tuple of (host, port).
    s[^0-9, ]R5RLiisOut of ranges%s.%s.%s.%si(tretsubR8RRtstripR(
RtabcdefRtparsedtxtatbtcRRMRRFRG((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytdecodeHostPort:s.
cCs:|jdt|d?t|dg}dj|S(NR4iiRL(R8RnR(RFRGtnumbers((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRIIs-cCs|jtj|jjS(N(R6Rt
FirstErrorRt
subFailure(R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt_unwrapFirstErrorMstFTPDataPortFactorycBseZdZdZdZRS(sZFactory for data connections that use the PORT command

    (i.e. "active" transfers)
    icCs ||j_|jj|jS(N(RRRGR(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRWs
(R0R1R2tnoisyR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRMQstFTPClientBasiccBseZdZeZdZdZdZdZdZ	dZ
dZdd	Zd
Z
dZdZd
ZRS(s'
    Foundations of an FTP client.
    cCsVg|_d|_tjj|j|_|jj|j	g|_
d|_dS(Ni(tactionQueueRtgreetingRRRJt_cb_greetingtnextDeferredRRBRWt_failed(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRQgs			cCs|j|dS(s8
        Give an error to any queued deferreds.
        N(t_fail(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRBoscCs|jr
|Sd|_|jr_y&|jjtjtd|Wq_tjk
r[q_Xnx0|jD]%}|j	tjtd|qiW|S(s/
        Errback all queued deferreds.
        isFTP connection lost(
RTRSRRtFailureR,RtAlreadyCalledErrorRPRB(RSRt
ftpCommand((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRUus			&#cCs
||_dS(N(RQ(RSRQ((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRRscCs'|dkrdStjj||dS(s>
        (Private) Sends a line, unless line is None.
        N(RRtLineReceiverR(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRscCs|j}|dkr%d|_dS|jsa|jjd|tjd|jd|_dS|j	dkr|j
|n|jrtj
d|j	n|j|_|j|j	dS(sD
        (Private) Processes the next command in the queue.
        Nig?tPORTs<-- %s(tpopCommandQueueRRSR3RPtinsertRRtsendNextCommandR2tgeneratePortCommandRmR
RTRR(RSRX((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR]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(RPR:RRRRSR](RSRX((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytqueueCommands
$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.
        (R1R_R(RStcommandR4RX((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytqueueStringCommands
cCs!|jr|jjdSdSdS(sR
        Return the front element of the command queue, or None if empty.
        iN(RPR9R(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR[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 R4isPASS cs*|djdr&jjn|S(Nit230(R7RPR(RW(RStpasswordCmd(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytcancelPasswordIfNotNeededscSsdS(N(R(RD((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRCsN(	RaR:RR1R_RRJRRB(RSR/R@t	deferredstuserDeferredRdR((RcRSs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt
queueLogins	


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(RiRj(RkRl(RmR
RTRWR:R?tmatchRSRRBR/RRRRVR-R.R](RSRtcodeIsValidRRW((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs*	
		"cCs|j|dS(N(RU(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR 	s(R0R1R2RRmRQRBRURRRR]R_RaR[RgRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyROas										#	-t_PassiveConnectionFactorycBs)eZeZdZdZdZRS(cCs
||_dS(N(t
protoInstance(RSRp((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRQ(	scCs||j_|jS(N(RpR(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR+	scCs&td|}|jjj|dS(NsConnection Failed(RgRpRR(RSRRRM((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR/	s(R0R1RRNRQRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRo%	s		t	FTPClientcBseZdZejZddddZdZdZdZ	dZ
d	Zd
ZdZ
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<http://www.ietf.org/rfc/rfc959.txt>} 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(RORQRgtpassive(RSR/R@Rr((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRQK	s
cCs|jj|j|dS(sM
        Disconnect, and also give an error to any queued deferreds.
        N(RRRU(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRB^	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	IProtocolR6RRt_openDataConnection(RStcommandsRtwrapper((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytreceiveFromConnectione	s
cCsLtj||||jddd}|j|j|jddS(sg
        Login: send the username, send the password, and
        set retrieval mode to binary
        sTYPE IR4icSsdS(N(R(RD((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRC	sN(RORgRaRRB(RSR/R@R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRgv	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.
        (R;RtR<(RSRuR>R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytsendToConnection	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.
        R4itfireOnOneErrbackt
consumeErrorscsCt|dd\}}t}j|||d<dS(s5Connect to the port specified in the response to PASViiiN(RHRotconnectFactory(RWRFRGR(RRSt_mutable(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt	doPassive	stPASVcSs|do|dj|S(Ni(R(RDtm((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR	sRZcSs|S(N((R	((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRC	scSs|S(N((R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRC	scSs|j|p|S(N(RB(RMtpc((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRC	sN(R1RtDeferredListRRoRRLRrRR_RJRBRR5RRR(
RSRuRR`tcmdsRtcmdsDeferredR}tpasvCmdRZRRtportCmd((R|RRSs9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRt	s:%"
		

		


cCst}|j|_tjd|}||_|d}||_|jjj}|jj}dt	|||_
dS(sG
        (Private) Generates the text of a given PORT command.
        icSs|jr|jn|S(N(RNR(Rtlistener((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytlistenerFail	s	
sPORT N(RMRRRRGRBRRERFRIR2(RSRRRRRFRG((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR^	s			cCs|jddS(sK
        Returns a FTP escaped path (replace newlines with nulls).
        s
R6(R(RSR<((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt
escapePath	sicCsId|j|g}|r9|jddt|n|j||S(s
        Retrieve a file from the given path

        This method issues the 'RETR' FTP command.

        The file is fed into the given Protocol instance.  The data connection
        will be passive if self.passive is set.

        @param path: path to file that you wish to receive.
        @param protocol: a L{Protocol} instance.
        @param offset: offset to start downloading from

        @return: L{Deferred}
        sRETR isREST (RR\RnRw(RSR<RtoffsetR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytretrieveFile	scCsFd|j|g}|r9|jddt|n|j|S(s
        Store a file at the given path.

        This method issues the 'STOR' FTP command.

        @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.
        sSTOR isREST (RR\RnRx(RSR<RR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt	storeFile
scsjdj|}jdj|}gtjjfdfd}|jj||jS(s_
        Rename a file.

        This method issues the I{RNFR}/I{RNTO} command sequence to rename
        C{pathFrom} to C{pathTo}.

        @param: pathFrom: the absolute path to the file to be renamed
        @type pathFrom: C{str}

        @param: pathTo: the absolute path to rename the file to.
        @type pathTo: C{str}

        @return: A L{Deferred} which fires when the rename operation has
            succeeded or failed.  If it succeeds, the L{Deferred} is called
            back with a two-tuple of lists.  The first list contains the
            responses to the I{RNFR} command.  The second list contains the
            responses to the I{RNTO} command.  If either I{RNFR} or I{RNTO}
            fails, the L{Deferred} is errbacked with L{CommandFailed} or
            L{BadResponse}.
        @rtype: L{Deferred}

        @since: 8.2
        sRNFR sRNTO cs
|fS(N((t
toResponse(tfromResponse(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRCH
scsjj|dS(N(R[R(R(RSR	(s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytebFromJ
s
(RaRRRRJRRt
chainDeferred(RStpathFromtpathTot
renameFromtrenameToR((RSRR	s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR'
s
cCs5|dkrd}n|jd|j|g|S(s|
        Retrieve a file listing into the given protocol instance.

        This method issues the 'LIST' FTP command.

        @param path: path to get a file listing for.
        @param protocol: a L{Protocol} instance, probably a
            L{FTPFileListProtocol} instance.  It can cope with most common file
            listing formats.

        @return: L{Deferred}
        R5sLIST N(RRwR(RSR<R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR]X
s
	cCs5|dkrd}n|jd|j|g|S(s1
        Retrieve a short file listing into the given protocol instance.

        This method issues the 'NLST' FTP command.

        NLST (should) return a list of filenames, one per line.

        @param path: path to get short file listing for.
        @param protocol: a L{Protocol} instance.
        R5sNLST N(RRwR(RSR<R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytnlstj
s	cCs|jd|j|S(s
        Issues the CWD (Change Working Directory) command. It's also
        available as changeDirectory, which parses the result.

        @return: a L{Deferred} that will be called when done.
        sCWD (RaR(RSR<((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR;z
scCs8tjddtddd}|j|j|S(sY
        Change the directory on the server and parse the result to determine
        if it was successful or not.

        @type path: C{str}
        @param path: The path to which to change.

        @return: a L{Deferred} which will be called back when the directory
            change has succeeded or errbacked if an error occurrs.
        s]FTPClient.changeDirectory is deprecated in Twisted 8.2 and newer.  Use FTPClient.cwd instead.tcategoryt
stacklevelicSs+|dd dkr'tjt|StS(NiiR(RRVR-Ro(R	((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytcbResult
s(twarningstwarntDeprecationWarningR;RJ(RSR<R((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytchangeDirectory
s	cCs|jd|j|S(s@
        Make a directory

        This method issues the MKD command.

        @param path: The path to the directory to create.
        @type path: C{str}

        @return: A L{Deferred} which fires when the server responds.  If the
            directory is created, the L{Deferred} is called back with the
            server response.  If the server response indicates the directory
            was not created, the L{Deferred} is errbacked with a L{Failure}
            wrapping L{CommandFailed} or L{BadResponse}.
        @rtype: L{Deferred}

        @since: 8.2
        sMKD (RaR(RSR<((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR
scCs|jd|j|S(s^
        Delete a file on the server.

        L{removeFile} issues a I{DELE} command to the server to remove the
        indicated file.  Note that this command cannot remove a directory.

        @param path: The path to the file to delete. May be relative to the
            current dir.
        @type path: C{str}

        @return: A L{Deferred} which fires when the server responds.  On error,
            it is errbacked with either L{CommandFailed} or L{BadResponse}.  On
            success, it is called back with a list of response lines.
        @rtype: L{Deferred}

        @since: 8.2
        sDELE (RaR(RSR<((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR
scCs|jd|j|S(s`
        Delete a directory on the server.

        L{removeDirectory} issues a I{RMD} command to the server to remove the
        indicated directory. Described in RFC959.

        @param path: The path to the directory to delete. May be relative to
            the current working directory.
        @type path: C{str}

        @return: A L{Deferred} which fires when the server responds. On error,
            it is errbacked with either L{CommandFailed} or L{BadResponse}. On
            success, it is called back with a list of response lines.
        @rtype: L{Deferred}

        @since: 11.1
        sRMD (RaR(RSR<((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR
scCs
|jdS(s
        Issues the CDUP (Change Directory UP) command.

        @return: a L{Deferred} that will be called when done.
        tCDUP(Ra(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytcdup
scCs
|jdS(sh
        Issues the PWD (Print Working Directory) command.

        The L{getDirectory} does the same job but automatically parses the
        result.

        @return: a L{Deferred} that will be called when done.  It is up to the
            caller to interpret the response, but the L{parsePWDResponse} method
            in this module should work.
        tPWD(Ra(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR
scCsd}|jj|S(s
        Returns the current remote directory.

        @return: a L{Deferred} that will be called back with a C{str} giving
            the remote directory or which will errback with L{CommandFailed}
            if an error response is returned.
        cSsy3t|djddddkr2tnWn'ttfk
r\tjt|SXt|d}|dkrtjt|S|S(NiR
ii(	RRR8Rt
IndexErrorRRVR-tparsePWDResponseR(R	R<((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytcbParse
s&
(RRJ(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytgetDirectory
s	cCs
|jdS(s
        Issues the I{QUIT} command.

        @return: A L{Deferred} that fires when the server acknowledges the
            I{QUIT} command.  The transport should not be disconnected until
            this L{Deferred} fires.
        tQUIT(Ra(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pytquits(R0R1R2RRTR{RQRBRwRgRxRtR^RRtretrRtstorRR]RR;RRRRRRRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRq5	s8						D	"		1			
								tFTPFileListProtocolcBsPeZdZejdZdZdZdZdZ	dZ
dZRS(sParser for standard FTP file listings

    This is the evil required to match::

        -rw-r--r--   1 root     other        531 Jan 29 03:26 README

    If you need different evil for a wacky FTP server, you can
    override either C{fileLinePattern} or C{parseDirectoryLine()}.

    It populates the instance attribute self.files, which is a list containing
    dicts with the following keys (examples from the above line):
        - filetype:   e.g. 'd' for directories, or '-' for an ordinary file
        - perms:      e.g. 'rw-r--r--'
        - nlinks:     e.g. 1
        - owner:      e.g. 'root'
        - group:      e.g. 'other'
        - size:       e.g. 531
        - date:       e.g. 'Jan 29 03:26'
        - filename:   e.g. 'README'
        - linktarget: e.g. 'some/file'

    Note that the 'date' value will be formatted differently depending on the
    date.  Check U{http://cr.yp.to/ftp.html} if you really want to try to parse
    it.

    @ivar files: list of dicts describing the files in this listing
    s^(?P<filetype>.)(?P<perms>.{9})\s+(?P<nlinks>\d*)\s*(?P<owner>\S+)\s+(?P<group>\S+)\s+(?P<size>\d+)\s+(?P<date>...\s+\d+\s+[\d:]+)\s+(?P<filename>([^ ]|\\ )*?)( -> (?P<linktarget>[^\r]*))?\r?$s
cCs
g|_dS(N(tfiles(RS((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRQ8scCs<|j|}|dkr+|j|n
|j|dS(N(tparseDirectoryLineRtunknownLinetaddFile(RSRR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyR;scCs|jj|}|dkr"dS|j}|djdd|d<t|d|d<t|d|d<|dr|djdd|d<n|SdS(sReturn a dictionary of fields, or None if line cannot be parsed.

        @param line: line of text expected to contain a directory entry
        @type line: str

        @return: dict
        tfilenames\ R
tnlinksRt
linktargetN(tfileLinePatternRmRt	groupdictRRR(RSRRmR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRBs
cCs|jj|dS(sxAppend file information dictionary to the list of known files.

        Subclasses can override or extend this method to handle file
        information differently without affecting the parsing of data
        from the server.

        @param info: dictionary containing the parsed representation
                     of the file information
        @type info: dict
        N(RR:(RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRVscCsdS(sDeal with received lines which could not be parsed as file
        information.

        Subclasses can override this to perform any special processing
        needed.

        @param line: unparsable line as received
        @type line: str
        N((RSR((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRcs
(R0R1R2R?tcompileRt	delimiterRQRRRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRs					
cCs.tjd|}|r&|jdSdSdS(sReturns the path from a response to a PWD command.

    Responses typically look like::

        257 "/home/andrew" is current directory.

    For this example, I will return C{'/home/andrew'}.

    If I can't find the path, I return C{None}.
    s"(.*)"iN(R?tsearchtgroupsR(RWRm((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyRos(R2RRR?R	RR@RaRRRtImportErrorRtzope.interfaceRRttwistedRRRRRRRttwisted.protocolsRR	ttwisted.pythonR
RRttwisted.python.compatR
ttwisted.credR7RRRtRESTART_MARKER_REPLYtSERVICE_READY_IN_N_MINUTESRXRtRRRMtCMD_NOT_IMPLMNTD_SUPERFLUOUStSYS_STATUS_OR_HELP_REPLYt
DIR_STATUSRtHELP_MSGRtSVC_READY_FOR_NEW_USERRtSVC_CLOSING_CTRL_CNXRt DATA_CNX_OPEN_NO_XFR_IN_PROGRESStCLOSING_DATA_CNXRYRHtENTERING_EPSV_MODER>R<RiRnRR.R-tNEED_ACCT_FOR_LOGINRtSVC_NOT_AVAIL_CLOSING_CTRL_CNXRRORrtREQ_ACTN_ABRTD_FILE_UNAVAILtREQ_ACTN_ABRTD_LOCAL_ERRtREQ_ACTN_ABRTD_INSUFF_STORAGER`RbRdRjRfRRltNEED_ACCT_FOR_STORRXR[RZR\RR]R^t
PAGE_TYPE_UNKtEXCEEDED_STORAGE_ALLOCtFILENAME_NOT_ALLOWEDRURPR/R?RNRORCRYRFRHRJRLR_RaRcReRgRhRiRkRqRRR=R~t
ClientFactoryRRRRYRtTimeoutMixinRRRR0RRRRRRRRRR'R)R,R-R.R/R0R1R6RR9R;RHRIRLt
ServerFactoryRMRORoRqRR(((s9/usr/lib/python2.7/dist-packages/twisted/protocols/ftp.pyt<module>s
("
		
				u]"*	7Z'$
/			[