ok

Mini Shell

Direktori : /proc/thread-self/root/proc/self/root/lib64/python2.7/Demo/sockets/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/lib64/python2.7/Demo/sockets/gopher.pyc

�
Afc@s�ddlZddlZddlZddlZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZidd6dd6dd6dd6dd	6dd
6dd6dd6dd
6dd6dd6dd6ZdZdZd�Zd �Zd!�Zd"�Zd#�Zd$�Zd%�Zd&�Zd'�Zd(�Zd)�Z d*�Z!d+�Z"d,�Z#i	ed6ed6e"d	6e"d
6ed6e d6e!d
6e"d6e#d6Z$d-d3d.��YZ%d/d4d0��YZ&d1�Z'd2�Z(e(�dS(5i����Ntsgopher.micro.umn.eduiFt0t1t2t3t4t5t6t7t8t9t+tss<TEXT>s<DIR>s<CSO>s<ERROR>s<BINHEX>s<DOS>s
<UUENCODE>s<SEARCH>s<TELNET>s<BINARY>s<REDUNDANT>s<SOUND>s
s	cCsh|st}n*t|�td�kr9tj|�}ntjtjtj�}|j||f�|S(NR(tDEF_PORTttypetstringtatoitsockettAF_INETtSOCK_STREAMtconnect(thosttportR((s+/usr/lib64/python2.7/Demo/sockets/gopher.pytopen_socket)s	cCs:t||�}|j|t�|jd�|jd�S(Nitr(RtsendtCRLFtshutdowntmakefile(tselectorRRR((s+/usr/lib64/python2.7/Demo/sockets/gopher.pytsend_request3s
cCs)t|||�}g}x|j�}|s6dGHPn|dtkrS|d }n|dtkrp|d }n|dkr�Pn|s�dGHqn|d}tj|dt�}t|�dkr�d	|fGHqnt|�dkr�d
|dfGHn|jd|�|j|�qW|j	�|S(Ns(Unexpected EOF from server)i����i����t.s(Empty line from server)iiis(Bad line from server: %r)s(Extra info from server: %r)(
RtreadlineRRtsplitfieldstTABtlentinserttappendtclose(RRRtftlisttlinettypechartparts((s+/usr/lib64/python2.7/Demo/sockets/gopher.pytget_menu:s6



cCs g}t||||j�|S(N(tget_alt_textfileR%(RRRR(((s+/usr/lib64/python2.7/Demo/sockets/gopher.pytget_textfileXscCs�t|||�}x�|j�}|s0dGHPn|dtkrM|d }n|dtkrj|d }n|dkrzPn|d dkr�|d}n||�qW|j�dS(Ns(Unexpected EOF from server)i����i����Ris..i(RR RR&(RRRtfuncR'R)((s+/usr/lib64/python2.7/Demo/sockets/gopher.pyR-^s 


cCs,t|||�}|j�}|j�|S(N(RtreadR&(RRRR'tdata((s+/usr/lib64/python2.7/Demo/sockets/gopher.pyt
get_binaryqs
cCs@t|||�}x'|j|�}|s.Pn||�qWdS(N(RR0(RRRR/t	blocksizeR'R1((s+/usr/lib64/python2.7/Demo/sockets/gopher.pytget_alt_binaryxscGs�t}t}t}t|�}|dkrA|drA|d}n|dkrd|drd|d}n|dkr�|dr�|d}n|dkr�td�nyt|||�WnAtjk
r�}dG|GHtj	d�nt
k
r�dGHnXdS(Niiiis
too many argss
Socket error:s

[Goodbye](tDEF_SELECTORtDEF_HOSTR
R#tRuntimeErrortbrowse_menuRterrortsystexittKeyboardInterrupt(targsRRRtntmsg((s+/usr/lib64/python2.7/Demo/sockets/gopher.pytbrowser�s&


	
cCs�t|||�}x�dGHdGt|�GHdG|GdG|GHHx�tt|��D]u}||}|d|d}}tjt|d�d�dG|Gtj|�r�t|GHqNd	t|�d
GHqNWHx�ytd�}Wnt	k
r�HdSX|s�dSytj
|�}	Wntjk
r,dGHq�nXd|	koJt|�knsZd
GHq�nPq�W||	d}|d}|dd!\}
}}tj|�r�t|}
y|
|
||�Wq�t
tjfk
r�dGtjGdGtjGHq�XqdGHqWdS(Ns----- MENU -----s	Selector:sHost:s Port:iiit:s<TYPE=t>sChoice [CR == up a level]: s#Choice must be a number; try again:sChoice out of range; try again:iis***sUnsupported object type(R,treprtrangeR#Rtrjustttypenamethas_keyt	raw_inputtEOFErrorRt
atoi_errorttypebrowsertIOErrorRR9R:texc_typet	exc_value(RRRR(tititemR*tdescriptiontstrtchoicet
i_selectorti_hostti_porttbrowserfunc((s+/usr/lib64/python2.7/Demo/sockets/gopher.pyR8�sR
"
"

cCs�d}y8tjdd�}t|�}t||||j�Wntk
r\}dG|GHnX|rp|j�nt�}|s�dSt|�}yt||||j�dGHWntk
r�}dG|GHnX|j�dS(Ns
${PAGER-more}twsIOError:sDone.(	tNonetostpopent	SaveLinesR-twritelnRLR&t
open_savefile(RRRtxtpR?R'((s+/usr/lib64/python2.7/Demo/sockets/gopher.pytbrowse_textfile�s&

		
cCs�x�dGHdGt|�GHdG|GdG|GHHytd�}Wntk
rNHPnXtj|�}|shPnd|krdGHqnt|t|||�qWdS(Ns----- SEARCH -----s	Selector:sHost:s Port:sQuery [CR == up a level]: s	s"Sorry, queries cannot contain tabs(RCRHRIRtstripR8R"(RRRtquery((s+/usr/lib64/python2.7/Demo/sockets/gopher.pyt
browse_search�s"
cCsp|rdGt|�GHnt|�td�kr?t|�}ntjd|d|�}|rldG|GHndS(Ns	Log in asRsset -x; exec telnet t sExit status:(RCRRZtsystem(RRRtsts((s+/usr/lib64/python2.7/Demo/sockets/gopher.pyt
browse_telnet�scCsFt�}|sdSt|�}t||||jd�|j�dS(Niii (R^tSaveWithProgressR4twriteR&(RRRR'R_((s+/usr/lib64/python2.7/Demo/sockets/gopher.pyt
browse_binary�s	cCst|||�dS(N(Rk(RRR((s+/usr/lib64/python2.7/Demo/sockets/gopher.pytbrowse_soundsR\cBs#eZd�Zd�Zd�ZRS(cCs
||_dS(N(R'(tselfR'((s+/usr/lib64/python2.7/Demo/sockets/gopher.pyt__init__scCs|jj|d�dS(Ns
(R'Rj(RmR)((s+/usr/lib64/python2.7/Demo/sockets/gopher.pyR]scCs%|jj�}|r!dG|GHndS(NsExit status:(R'R&(RmRg((s+/usr/lib64/python2.7/Demo/sockets/gopher.pyR&s(t__name__t
__module__RnR]R&(((s+/usr/lib64/python2.7/Demo/sockets/gopher.pyR\s		RicBs#eZd�Zd�Zd�ZRS(cCs
||_dS(N(R'(RmR'((s+/usr/lib64/python2.7/Demo/sockets/gopher.pyRnscCs1tjjd�tjj�|jj|�dS(Nt#(R:tstdoutRjtflushR'(RmR1((s+/usr/lib64/python2.7/Demo/sockets/gopher.pyRjs
cCs&H|jj�}|r"dG|GHndS(NsExit status:(R'R&(RmRg((s+/usr/lib64/python2.7/Demo/sockets/gopher.pyR& s(RoRpRnRjR&(((s+/usr/lib64/python2.7/Demo/sockets/gopher.pyRis		cCs2ytd�}Wntk
r%HdSXtj|�}|s?dS|ddkr�tj|d�}ytj|d�}Wn'tk
r�}t|�GdG|GHdSXdGt|�GdGH|S|dd	kr�tj	j
|�}nyt|d�}Wn'tk
r}t|�GdG|GHdSXd
Gt|�GdGH|S(Ns<Save as file [CR == don't save; |pipeline or ~user/... OK]: it|iRXRAsPiping throughs...t~s	Saving to(RHRIRYRRbRZR[RLRCtpatht
expandusertopen(tsavefiletcmdR`R?R'((s+/usr/lib64/python2.7/Demo/sockets/gopher.pyR^'s6

cCs
tjdr"dGHtjd�n�tjdrWttjdtjdtjd�n�tjdr�y-tjtjd�}d}tjd}Wn4tjk
r�tjd}tjd}d}nXt|||�n+tjdr�tdtjd�nt�dS(Nis(usage: gopher [ [selector] host [port] ]iiiR(R:targvR;R@RRRJ(RRR((s+/usr/lib64/python2.7/Demo/sockets/gopher.pyttestEs$

(




((()RR:RZRR5R6R
t
T_TEXTFILEtT_MENUtT_CSOtT_ERRORtT_BINHEXtT_DOSt
T_UUENCODEtT_SEARCHtT_TELNETtT_BINARYtT_REDUNDANTtT_SOUNDRFRR"RRR,R.R-R2R4R@R8RaRdRhRkRlRKR\RiR^R|(((s+/usr/lib64/python2.7/Demo/sockets/gopher.pyt<module>s\	
								.			
					

Zerion Mini Shell 1.0