Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/twisted/conch/scripts/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/twisted/conch/scripts/__pycache__/cftp.cpython-310.pyc
o

�b�z�@szdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZm
Z
mZddlmZmZmZddlmZmZmZmZddlmZmZmZmZddlmZddlm Z m!Z!m"Z"dd	l#m$Z$Gd
d�dej%�Z&dd
�Z'dd�Z(dd�Z)dd�Z*dd�Z+Gdd�d�Z,Gdd�dej-�Z.e/e.de.j0�Gdd�dej1�Z1Gdd�dej2�Z3e4dkr�e'�dSdS) z0
Implementation module for the I{cftp} command.
�N)�List�Optional�Union)�connect�default�options)�channel�common�
connection�filetransfer)�defer�reactor�stdio�utils)�basic)�failure�log�usage)�FilePathc@szeZdZUdZdZgd�gd�gd�gd�gZeeeee	e
fed<ej
dd	ie��ejd
d�gd�Zddd�Zd
S)�
ClientOptionsz�Usage:   cftp [options] [user@]host
         cftp [options] [user@]host[:dir[/]]
         cftp [options] [user@]host[:file [localfile]]
zncftp is a client for logging into a remote machine and executing commands to send and receive file information)�
buffersize�Bi�z0Size of the buffer to use for sending/receiving.)�	batchfile�bNz-File to read commands from, or '-' for stdin.)�requests�R�z6Number of requests to make before waiting for a reply.)�	subsystem�s�sftpz'Subsystem/server program to connect to.�
optParametersrz,Size of send/receive buffer (default: 32768)z
local file)�descr)�descriptions�extraActionsNcCsFd|d<d|vr|�dd�\}|d<|d�d�||d<||d<dS)N��
remotePath�:��/�host�	localPath)�split�rstrip)�selfr)r*�r.�</usr/lib/python3/dist-packages/twisted/conch/scripts/cftp.py�	parseArgs6szClientOptions.parseArgs�N)�__name__�
__module__�__qualname__�synopsis�longdescr rrr�str�int�__annotations__r�Completions�CompleteUserAtHost�
CompleteFiles�compDatar0r.r.r.r/rs 
� �
��rc
Cs�tjdd�}d|vr#|�d�}|||d�|}||d|d�=t�}z|�|�WntjyK}ztd|�t�d�WYd}~nd}~ww|dr]tj	}t
�tj�|t_	nt
�
�t|�t��dS)Nr'z-l��z	ERROR: %sr)�sys�argv�indexr�parseOptionsr�
UsageError�print�exit�stdoutr�startLogging�stderr�discardLogs�	doConnectr
�run)�args�ir�u�realoutr.r.r/rL?s(
��rLcCs4dazt��Wn	tyYnwt�t����)Nr>)�
exitStatusr
�stop�
BaseExceptionr�errr�Failurer.r.r.r/�handleErrorUs�rVcCs�d|dvr|d�dd�\|d<|d<|d}|ds"t��|d<|ds+d|d<nt|d�|d<|d}|d}t�}||_tj}t�|d||�}t	�	|||||��
t�dS)N�@r)r'�user�port�)r+�getpass�getuserr8�
SSHConnectionrr�
verifyHostKey�SSHUserAuthClientr�
addErrback�_ebExit)rr)rY�conn�vhk�uaor.r.r/rK`s
rKcCsJt|jd�r|jj}nt|�}t|�zt��WdSty$YdSw)N�value)�hasattrrer7rEr
rRrS)�frr.r.r/rass
�racGsdSr1r.)rMr.r.r/�_ignore�rhc@seZdZdd�Zdd�ZdS)�FileWrappercCs&||_d|_|�dd�|��|_dS)N�rr>)rg�total�seek�tell�size�r-rgr.r.r/�__init__�szFileWrapper.__init__cCst|j|�Sr1)�getattrrg)r-�attrr.r.r/�__getattr__�szFileWrapper.__getattr__N)r2r3r4rqrtr.r.r.r/rj�srjc@s�eZdZeZdZdZeZd{dd�Zdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd|d$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Z d6d7�Z!d8d9�Z"d:d;�Z#d<d=�Z$d}d?d@�Z%dAdB�Z&dCdD�Z'dEdF�Z(dGdH�Z)dIdJ�Z*dKdL�Z+dMdN�Z,dOdP�Z-dQdR�Z.dSdT�Z/dUdV�Z0dWdX�Z1dYdZ�Z2d[d\�Z3d]d^�Z4e4Z5d_d`�Z6dadb�Z7dcdd�Z8dedf�Z9dgdh�Z:didj�Z;dkdl�Z<dmdn�Z=dodp�Z>dqdr�Z?dsdt�Z@dudv�ZAdwdx�ZBdydz�ZCdS)~�StdioClientzcftp> �
NcCs&||_d|_||_|rdpd|_dS)Nr$r'r)�client�currentDirectory�file�useProgressBar)r-rwrgr.r.r/rq�szStdioClient.__init__cCs|j�d��|j�dS)Nr$)rw�realPath�addCallback�_cbSetCurDir�r-r.r.r/�connectionMade�szStdioClient.connectionMadecCs||_|��dSr1)rx�_newLine�r-�pathr.r.r/r}�szStdioClient._cbSetCurDircCs t|t�r
|�d�}|j�|�S)N�utf-8)�
isinstancer7�encode�	transport�write)r-�msgr.r.r/�_writeToTransport�s

zStdioClient._writeToTransportcCs�|jjjrdSt|t�r|�d�}t�d|�|��}|s$|�	�dS|j
r6|�d�r6d|_|dd�}nd|_|�
|�}|durP|�|j�|�|j�dSdS)Nr�zgot line %s�-r'r)rwr��localClosedr��bytes�decoderr��lstripr�ry�
startswith�ignoreErrors�_dispatchCommandr|�
_cbCommandr`�
_ebCommand)r-�line�dr.r.r/�lineReceived�s$



�zStdioClient.lineReceivedcCs�d|vr|�dd�\}}|��}n|d}}|�d�r+|j}|dd�d|��}n|��}t�d|�t|d|d�}|durHt	�
||�Sd|}|�t�
t|���|��dS)N� r'r$�!zlooking up cmd %szcmd_%szNo command called `%s')r+r�r��cmd_EXEC�strip�upperrr�rrr�
maybeDeferredr�rrU�NotImplementedErrorr�)r-r��command�restrg�errMsgr.r.r/r��s


zStdioClient._dispatchCommandcCs�t�|�|�ttjtt�}|tkr|�|�	d��dS|tjkr2d|j
j|j
jf}|�|�dS|ttfvrId|j
j
|j
jf}|�|�dSdS)Nr$zremote error %i: %s
zlocal error %i: %s
)rr��trapr�r�	SFTPError�OSError�IOErrorr��cmd_HELPre�code�message�errno�strerror)r-rg�er�r.r.r/�
_printFailure�s

�zStdioClient._printFailurecCsd|jjjrdS|�|j�d|_|jr0|j��}|s"|jj��dS|�|�|�	|�
��dSdS)Nr)rwr�r�r��psr�ry�readline�loseConnectionr�r�)r-�lr.r.r/r��s


�zStdioClient._newLinecCsF|durt|t�r|�d�}|�|�|�d�s|�d�|��dS)Nr�rv)r�r7r�r��endswithr�)r-�resultr.r.r/r��s




zStdioClient._cbCommandcCs.|�|�|jr|js|jj��|��dSr1)r�ryr�rwr�r�r�rpr.r.r/r��s
zStdioClient._ebCommandcCs`|�|�\}}|�d�s|d7}|rtj�|j|�pd}|j�|�}|�|j	�|�
|j�|S)Nr(r$)�_getFilenamer��osr��joinrxrw�
openDirectoryr|�_cbCdr`r�)r-r�r��newPathr�r.r.r/�cmd_CD�s
zStdioClient.cmd_CDcCs&|��|j�|j�}|�|j�|Sr1)�closerwr{�namer|�	_cbCurDir)r-�	directoryr�r.r.r/r�szStdioClient._cbCdcCs
||_dSr1�rxr�r.r.r/r�	s
zStdioClient._cbCurDircC�H|�dd�\}}|�|�\}}t|�}|j�|�}|j|j||d�|S)Nr')�grp�r+r�r8rw�getAttrsr|�_cbSetUsrGrp)r-r�r�r�r�r.r.r/�	cmd_CHGRP�zStdioClient.cmd_CHGRPcCsH|�dd�\}}|�|�\}}t|d�}|j�|d|i�}|�t�|S)Nr'��permissions)r+r�r8rw�setAttrsr|rh)r-r��modr�r�r.r.r/�	cmd_CHMODs

zStdioClient.cmd_CHMODcCr�)Nr')�usrr�)r-r�r�r�r�r.r.r/�	cmd_CHOWNr�zStdioClient.cmd_CHOWNcCsPi}|dur|p|d|d<|dur|p|d|d<|j�||�}|�t�|S)N�uid�gid)rwr�r|rh)r-�attrsr�r�r��newr�r.r.r/r�$s
zStdioClient._cbSetUsrGrpcCs�|�|�\}}d|vsd|vr1|r!|�|�\}}tj�|�s dSnd}|�|�}|�|j|�|S|r;|�|�\}}ntj�|�d}t�	||f�t
|dd�}t|j��
|�}|j�|jtji�}|�|j|�|�|j|�|S)N�*�?z'Wildcard get with non-directory target.�r'�wbr)r�r�r��isdir�_remoteGlobr|�_cbGetMultipler+rr��openrrx�childrw�openFiler�FXF_READ�_cbGetOpenFiler`�
_ebCloseLf)r-r��remote�localr��lfr�r.r.r/�cmd_GET,s*�
zStdioClient.cmd_GETcCs|�d||�Sr1)�_cbGetMultipleNext)r-�filesr�r.r.r/r�DszStdioClient._cbGetMultiplecCs�t|tj�r|�|�n|r|�|�|�d�s|�d�|s!dS|�d�d}ttj	�
|tj	�|�d�dd�}t|j
��|�}|j�|j	tji�}|�|j|�|�|j|�|�|j||�|S)N�
rr'r�)r�rrUr�r�r��popr�r�r�r�r+rrxr�rwr�rr�r|r�r`r��addBothr�)r-�resr�r�rgr�r�r�r.r.r/r�Hs 


"zStdioClient._cbGetMultipleNextcCs|��|Sr1)r�)r-rgr�r.r.r/r�ZszStdioClient._ebCloseLfcCs|���|j||�Sr1)r�r|�_cbGetFileSize)r-�rfr�r.r.r/r�^szStdioClient._cbGetOpenFilec
Cs�t�|d�s|��|��d|jS|d|_|jjjjd}|jjjjd}d|_	g}g}|j
��}t|�D]}	|�
d|||d||�}
|�|
�q9tj|d	d
�}|�|j||�|S)Nr�zCan't get non-regular file: %srorrrkr$rr'��fireOnOneErrback)�stat�S_ISREGr�r�rorwr�rbrrlr
�seconds�range�
_cbGetRead�appendr�DeferredListr|�
_cbGetDone)r-r�r�r��
bufferSize�numRequests�dList�chunks�	startTimerNr��dlr.r.r/r�as"


zStdioClient._cbGetFileSizecCs�d}|D],}|dkr
dS||dkr,|�|�}|�|||df�||d|fS|d}qt|jjjjd�}|�|||f�||fS)Nr�eofr'r)rB�insertr8rwr�rbrr�)r-r��end�chunkrN�bufSizer.r.r/�
_getNextChunkts

zStdioClient._getNextChunkc
	CsN|r+t|tj�r+t�d|�|}|�t�|�|||f�}	||	=|�|	|df�nG|rrt�dt	|��|�
|�|�|�t	|�|krit�dt	|�|f�|�|||f�}	||	=|�|	||t	|�f�|jt	|�7_|j
r{|�||�|�|�}
|
s�dS|
\}}t�d|||f�|�||�}|�|j||||||�|S)Nzget read err: %sr�zget read data: %iz#got less than we asked for: %i < %izasking for %i -> %i)r�rrUrr�r��EOFErrorrBr��lenrmr�rlrz�_printProgressBarr��	readChunkr�r�)
r-�datar�r�r��startror��reasonrNr��lengthr�r.r.r/r��s6



zStdioClient._cbGetReadcCs>t�d�|��|��|jr|�d�d|j�d|j��S)Nzget doner��Transferred � to )rr�r�rzr�r��r-�ignoredr�r�r.r.r/r��s

zStdioClient._cbGetDonecCs�|�|�\}}d|vsd|vr.|r!|�|�\}}tj�|j|�}nd}t�|�}|�||�S|r8|�|�\}}ntj�|�d}|�||�S)a#
        Do an upload request for a single local file or a globing expression.

        @param rest: Requested command line for the PUT command.
        @type rest: L{str}

        @return: A deferred which fires with L{None} when transfer is done.
        @rtype: L{defer.Deferred}
        r�r�r$r')	r�r�r�r�rx�glob�_putMultipleFilesr+�_putSingleFile)r-r�r�r�r�r.r.r/�cmd_PUT�s

zStdioClient.cmd_PUTcCs|jd|g|dd�S)aB
        Perform an upload for a single file.

        @param local: Path to local file.
        @type local: L{str}.

        @param remote: Remote path for the request relative to current working
            directory.
        @type remote: L{str}

        @return: A deferred which fires when transfer is done.
        NT)�single��_cbPutMultipleNext)r-r�r�r.r.r/r
�s
zStdioClient._putSingleFilecCs|�d||�S)aV
        Perform an upload for a list of local files.

        @param files: List of local files.
        @type files: C{list} of L{str}.

        @param remote: Remote path for the request relative to current working
            directory.
        @type remote: L{str}

        @return: A deferred which fires when transfer is done.
        Nr)r-r�r�r.r.r/r�s
zStdioClient._putMultipleFilesFc
Cst|tj�r|�|�n|r't|t�r|�d�}|�|�|�d�s'|�d�d}|rP|sPz|�d�}t	|d�}Wnt
yK|�t���d}Ynw|rP|r-|sTdS|rY|}ntj�
|�d}tj�||�}t�|||f�|�||�}	|	�|j||�|	S)a�
        Perform an upload for the next file in the list of local files.

        @param previousResult: Result form previous file form the list.
        @type previousResult: L{str}

        @param files: List of local files.
        @type files: C{list} of L{str}

        @param remotePath: Remote path for the request relative to current
            working directory.
        @type remotePath: L{str}

        @param single: A flag which signals if this is a transfer for a single
            file in which case we use the exact remote path
        @type single: L{bool}

        @return: A deferred which fires when transfer is done.
        r�rvNr�rbr')r�rrUr�r7r�r�r�r�r�rSr�r�r+r�rr��_putRemoteFiler�r)
r-�previousResultr�r%r�currentFile�localStreamr�r�r�r.r.r/r�s8





��	zStdioClient._cbPutMultipleNextcCsRtj�|j|�}tjtjBtjB}|j�	||i�}|�
|j|�|�|j
|�|S)aW
        Do an upload request.

        @param localStream: Local stream from where data is read.
        @type localStream: File like object.

        @param remotePath: Remote path for the request relative to current working directory.
        @type remotePath: L{str}

        @return: A deferred which fires when transfer is done.
        )r�r�r�rxr�	FXF_WRITE�	FXF_CREAT�	FXF_TRUNCrwr�r|�_cbPutOpenFiler`r�)r-rr%r��flagsr�r.r.r/rszStdioClient._putRemoteFilec
Cs�|jjjjd}|jrt|�}g}g}|j��}t|�D]}|�	d||||�}|r.|�
|�qtj|dd�}	|	�
|j||�|	S)Nrr'r�)rwr�rbrrzrjr
r�r��_cbPutWriter�rr�r|�
_cbPutDone)
r-r�r�r�r�r�r�rNr�r�r.r.r/r-s

�zStdioClient._cbPutOpenFilecCsv|�|�}|\}}|�|�|�|�}	|jr%|jt|	�7_|�||�|	r9|�||	�}
|
�|j	||||�|
SdSr1)
r�rm�readrzrlrr�
writeChunkr|r)r-r
r�r�r�r�r�rrorr�r.r.r/r<s


zStdioClient._cbPutWritecCs4|��|��|jr|�d�d|j�d|j��S)Nr�rr)r�rzr�r�r	r.r.r/rKs

zStdioClient._cbPutDonecCst�|�dSr1)r��chdirr�r.r.r/�cmd_LCDR�zStdioClient.cmd_LCDc�J��|�\}}��|�\}}t�fdd�||f�\}}�j�||��t�S)Nc�tj��j|�Sr1�r�r�r�rx��xr~r.r/�<lambda>Y�z$StdioClient.cmd_LN.<locals>.<lambda>)r��maprw�makeLinkr|rh)r-r��linkpath�
targetpathr.r~r/�cmd_LNU��zStdioClient.cmd_LNcCs�g}|��}|rC|drC|dddkrC|�d�dd�}|D]}|dkr+|�d�q|dkr4|�d�q|rC|drC|dddksd�|�}|�|�\}}|sW|jd	}ntj�|j|�}|�|�}|�	|j
|�|S)
Nrr�r'r��verbose�a�allr�r()r+r�r�r�r�rxr�r�r�r|�_cbDisplayFiles)r-r�r�opts�or��fullPathr�r.r.r/�cmd_LS]s&
��

zStdioClient.cmd_LScCsV|��d|vrdd�|D�}d|vrdd�|D�}ndd�|D�}|s&dSd�|�S)Nr2cSsg|]}|d�d�s|�qS)r�.)r���.0rgr.r.r/�
<listcomp>ysz/StdioClient._cbDisplayFiles.<locals>.<listcomp>r0cS�g|]}|d�qS)r'r.r9r.r.r/r;{�cSr<�rr.r9r.r.r/r;}r=rv)�sortr�)r-r�r�linesr.r.r/r3vs
zStdioClient._cbDisplayFilescCs2|�|�\}}tj�|j|�}|j�|i��t�Sr1)	r�r�r�r�rxrw�
makeDirectoryr|rh�r-r�r�r.r.r/�	cmd_MKDIR�szStdioClient.cmd_MKDIRcC�0|�|�\}}tj�|j|�}|j�|��t�Sr1)	r�r�r�r�rxrw�removeDirectoryr|rhrBr.r.r/�	cmd_RMDIR��zStdioClient.cmd_RMDIRcC�t�d|�dS)Nzmkdir %s�r��systemr�r.r.r/�
cmd_LMKDIR��zStdioClient.cmd_LMKDIRcCrDr1)	r�r�r�r�rxrw�
removeFiler|rhrBr.r.r/�cmd_RM�rGzStdioClient.cmd_RMcCrH)Nzls %srI)r-r�r.r.r/�cmd_LLS�rLzStdioClient.cmd_LLScr#)Ncr$r1r%r&r~r.r/r(�r)z(StdioClient.cmd_RENAME.<locals>.<lambda>)r�r*rw�
renameFiler|rh)r-r��oldpath�newpathr.r~r/�
cmd_RENAME�r/zStdioClient.cmd_RENAMEcCs|jj��dSr1)rwr�r��r-r
r.r.r/�cmd_EXIT��zStdioClient.cmd_EXITcCs$d|jj}t|t�r|�d�}|S)NzSFTP version %ir�)rw�versionr�r7r�)r-r
rWr.r.r/�cmd_VERSION�s

zStdioClient.cmd_VERSIONcCsdS)NaeAvailable commands:
cd path                         Change remote directory to 'path'.
chgrp gid path                  Change gid of 'path' to 'gid'.
chmod mode path                 Change mode of 'path' to 'mode'.
chown uid path                  Change uid of 'path' to 'uid'.
exit                            Disconnect from the server.
get remote-path [local-path]    Get remote file.
help                            Get a list of available commands.
lcd path                        Change local directory to 'path'.
lls [ls-options] [path]         Display local directory listing.
lmkdir path                     Create local directory.
ln linkpath targetpath          Symlink remote file.
lpwd                            Print the local working directory.
ls [-l] [path]                  Display remote directory listing.
mkdir path                      Create remote directory.
progress                        Toggle progress bar.
put local-path [remote-path]    Put local file.
pwd                             Print the remote working directory.
quit                            Disconnect from the server.
rename oldpath newpath          Rename remote file.
rmdir path                      Remove remote directory.
rm path                         Remove remote file.
version                         Print the SFTP version.
?                               Synonym for 'help'.
r.rTr.r.r/r��rizStdioClient.cmd_HELPcCs|jSr1r�rTr.r.r/�cmd_PWD�szStdioClient.cmd_PWDcCst��Sr1)r��getcwdrTr.r.r/�cmd_LPWD�szStdioClient.cmd_LPWDcCs|j|_d|jrdpdS)Nz%ssing progess bar.�UzNot u)rzrTr.r.r/�cmd_PROGRESS�s
zStdioClient.cmd_PROGRESScCsF|j�t���d}|sd}|rd|g}tj||dd�St�|�dS)zb
        Run C{rest} using the user's shell (or /bin/sh if they do not have
        one).
        �z/bin/shz-cr')�errortooN)�_pwd�getpwnamr[r\r�getProcessOutputr�rJ)r-r��shell�cmdsr.r.r/r��szStdioClient.cmd_EXECcCs�t�d|�tj�|�\}}d|vsd|vrd}nd}|r7|s7|j�|�}|�|jd�|�	|j
||�|S|j�|�}|�|j|�|S)Nz
looking up %sr�r�r'rr$)rr�r�r�r+rwr�r|�_cbOpenListr`�_ebNotADirectory)r-r6�head�tailrr�r.r.r/r��s�zStdioClient._remoteGlobcCs"g}|��}|�|j|||�|Sr1)rr��_cbReadFile)r-r�rr�r�r.r.r/re�szStdioClient._cbOpenListcCs|j�|�}|�|j|�|Sr1)rwr�r|re)r-rr�rr�r.r.r/rf�szStdioClient._ebNotADirectorycsvt|tj�s.�r��d��|��fdd�|D��n|�|�|��}|�|j||��|S|}|�t	�|�
�|S)Nr�cs g|]}t�|d��r|�qSr>)�fnmatchr9�rr.r/r;s z+StdioClient._cbReadFile.<locals>.<listcomp>)r�rrUr��extendrr�rir�r�r�)r-r��matchedFilesr�rr�rr.rkr/ri�s


zStdioClient._cbReadFilecCs2gd�}|D]
\}}||krnqd|||S)N))l �PB)l�TB)i@�GB)i�MB)i�kB)r'rz%.1fr.)r-ro�_abbrevs�factor�suffixr.r.r/�_abbrevSizes	�zStdioClient._abbrevSizecCsj|dkr#t|d�}|d|8}t|d�}|d|8}d|||fSt|d�}|d|8}d||fS)Ni�<z%i:%02i:%02iz	%02i:%02i)r8)r-�t�hours�minsr.r.r/�_abbrevTimeszStdioClient._abbrevTimec
Cs�|j��|}|j}zt�dt�dtjd��}Wn
t	y%ddg}Ynw|dkr-d}n||}|r;|j
||}nd}|j}|j
rK||j
d}	nd}	d|	|�|�|�|�|�
|�f}
|d	t|�t|
�d	d
}d|�|�|
��}|�|�dS)a�
        Update a console progress bar on this L{StdioClient}'s transport, based
        on the difference between the start time of the operation and the
        current time according to the reactor, and appropriate to the size of
        the console window.

        @param f: a wrapper around the file which is being written or read
        @type f: L{FileWrapper}

        @param startTime: The time at which the operation being tracked began.
        @type startTime: L{float}
        �4Hr�12345679N�Prk�dz%3i%% %s %sps %s r'r��
)r
r�rl�struct�unpack�fcntl�ioctl�tty�
TIOCGWINSZr�ror�rvr{rr�)
r-rgr��diffrl�winSize�speed�timeLeft�front�
percentage�back�spacesr�r.r.r/r(s4
�� zStdioClient._printProgressBarcCs|��}|sdS|ddvrpg}t|�}zPtdt|��D]F}||}||dkr=d�|�d�||dd����fWS|dkr[||=||dvrStd	||����|�||�q|�||�qWntyotd
��w|�dd�}t|�dkr�|ddfS|d|dfS)aW
        Parse line received as command line input and return first filename
        together with the remaining line.

        @param line: Arguments received from command line input.
        @type line: L{str}

        @return: Tupple with filename and rest. Return empty values when no path was not found.
        @rtype: C{tupple}
        )r$r$rz'"r'r$N�\z'"\zbad quote: \zunterminated quote)	r��listr�rr�r��
IndexErrorr�r+)r-r��retrN�cr.r.r/r�Rs2*��zStdioClient._getFilenamer1)NN)F)Dr2r3r4�pwdr`r��	delimiterr
rqrr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr
rrrrrrr!r.r7r3rCrFrKrNrOrSrU�cmd_QUITrXr�rYr[r]r�r�rerfrirvr{rr�r.r.r.r/ru�s�

	


5
*ruzcmd_?c@seZdZdd�ZdS)r]cCs|�t��dSr1)�openChannel�
SSHSessionr~r.r.r/�serviceStarted|rVzSSHConnection.serviceStartedN)r2r3r4r�r.r.r.r/r]{sr]c@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)r�ssessioncCsht�d|j�|jjd�d�rd}nd}|jj||t�|jjd�dd�}|�	|j
�|�t�dS)Nzsession %s openrr(�execr')�	wantReply)
rr��idrbrr��sendRequestr	�NSr|�_cbSubsystemr`ra)r-�foo�requestr�r.r.r/�channelOpen�s�zSSHSession.channelOpencCsdt��|_|j�|�|jj|_d}|jjdr&|jjd}|dkr&t|�}t�	t
|j|��|_dS)Nrr�)r�FileTransferClientrw�makeConnection�dataReceivedrbrr�r�
StandardIOru)r-r�rg�fnr.r.r/r��s

zSSHSession._cbSubsystemcCs:|tjkrt�dt|��tj�|�tj��dSdS)Nzgot %s stderr data)	r
�EXTENDED_DATA_STDERRrr�rr@rIr��flush)r-rxrr.r.r/�extReceived�s

�zSSHSession.extReceivedcCst�d�|j��dS)Nzgot eof)rr�r�loseWriteConnectionr~r.r.r/�eofReceived�s
zSSHSession.eofReceivedcCst�d|�|j�|�dS)Nzremote side closed %s)rr�rb�	sendCloser~r.r.r/�
closeReceived�szSSHSession.closeReceivedcCs$zt��WdStyYdSwr1)r
rRrSr~r.r.r/�closed�s
�zSSHSession.closedcC�|j��dSr1)r�pauseProducingr~r.r.r/�stopWriting�r"zSSHSession.stopWritingcCr�r1)r�resumeProducingr~r.r.r/�startWriting�r"zSSHSession.startWritingN)r2r3r4r�r�r�r�r�r�r�r�r�r.r.r.r/r��sr��__main__)5�__doc__r�rjr[rr�r�r�r�r@r��typingrrr�twisted.conch.clientrrr�twisted.conch.sshrr	r
r�twisted.internetrr
rr�twisted.protocolsr�twisted.pythonrrr�twisted.python.filepathr�ConchOptionsrrLrVrKrarhrj�LineReceiverru�setattrr�r]�
SSHChannelr�r2r.r.r.r/�<module>sJ#o6
�

Spamworldpro Mini