[XMc@s dZddd!ZddlmZddlmZddlmZmZm Z m Z ddl m Z dd l mZdd lmZdd lmZdd lmZdd lZdd lZdd lZdd lZdefdYZdejejfdYZiidd6d6idd6d6idd6d6idd6d6idd6d6idd6d6id d6d!6id"d6d#6Zd$d/d%YZd&d0d'YZ d(d1d)YZ!d*Z"d+d2d,YZ#d-ej$ej%fd.YZ&ej'e&eed S(3s+ Manhole client with a GTK v2.x front-end. s$Revision: 1.9 $i ii(t copyright(treactor(t componentstfailuretlogtutil(tprefixedMethodNames(tpb(tgtk2util(tIManholeClient(t implementsNt OfflineErrorcBseZRS((t__name__t __module__(((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyR !st ManholeWindowcBseZejedZdZdZdZdZ dZ dZ d Z d Z dd Zd Zd ZdZRS(sgtk2manhole.gladetinputtoutputt manholeWindowcCsvi|_tjj|tjj|t|j|_||j_ t |j |_ |jj d|jjdS(Ntkey_press_event(tdefaultsRt GladeKeepert__init__Rt Componentizedt ConsoleInputt_inputRttoplevelt ConsoleOutputt_outputRtconnectt_on_key_press_event(tself((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyR)s  cCs ||_dS(N(R(RR((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyt setDefaults7scCsX|jt}tj||j}|j|j|j|j|j|jdS(N( t getComponentR RtloginRt addCallbackt_cbLogint addErrbackt_ebLogin(Rtclienttd((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyR!:s cCs.|jjd|fd|jjddS(Ns%s went away. :( tlocaltManhole(Rtappendt_manholeWindowt set_title(Rt perspective((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyt_cbDisconnectedAscCsT|jjj}|jjd|fd|j|j|jjd||S(NsConnected to %s R(s Manhole - %s( tbrokert transporttgetPeerRR*tnotifyOnDisconnectR.R+R,(RR-tpeer((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyR#Es cCs!|jjd|jfddS(NsLogin FAILED %s t exception(RR*tvalue(Rtreason((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyR%LscGsddl}ddlm}|jjditjd6|jjddd6|j d6d j t t t jd 6d j t t t jd 6|jtd 6td 6ddS(Ni(tpathsa Twisted Manhole client Versions: %(twistedVer)s Python %(pythonVer)s on %(platform)s GTK %(gtkVer)s / PyGTK %(pygtkVer)s %(module)s %(modVer)s http://twistedmatrix.com/ t twistedVers s t pythonVertplatformt.tgtkVertpygtkVertmoduletmodVerR((tsystosR7RR*Rt longversiontversiontreplaceR:tjointmaptstrtgtkt gtk_versiont pygtk_versiontbasenamet__file__t __version__(RtwidgettunusedR@R7((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyt_on_aboutMenuItem_activateOs   cCs|jdS(N(R!(RRNtuserdata((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyt_on_openMenuItem_activatecscGstjdS(N(Rtstop(RRNRO((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyt_on_manholeWindow_delete_eventfscGstjdS(N(RRS(RRNRO((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyt_on_quitMenuItem_activateiscGs-ddlm}|jtj|jdS(Ni(trebuild(ttwisted.pythonRVtinspectt getmodulet __class__(RRORV((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyton_reload_self_activatels(sinputsoutputRN(R R RtsibpathRLt gladefilet_widgetsRRR!R.R#R%RPtNoneRRRTRUR[(((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyR$s          t monospacetfamilytdefaulttblackt foregroundtstdouts#AA8000tstderrtbluetresulttredR4s#008000R(s#000080Rs#666666tcommandRcBs5eZdZdZdZddZdZRS(cCs||_|j|_xYtjD]K\}}|jj|}x*|jD]\}}|j||qPWq%W|jjjdj d|j dS(NRbi( ttextViewt get_buffertbufferttagdefst iteritemst create_tagt set_propertyt tag_tabletlookupt set_priorityt_captureLocalLog(RRktnametpropsttagtktv((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyRs cCstjt|ddtS(NRt setStdout(Rt startLoggingt _NotafiletFalse(R((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyRuscCsodg}|dk r%|j|n|jj|jj|||jdkrktj|j|_ndS(NRb( R_R*Rmtinsert_with_tags_by_namet get_end_itert _willScrollRHtidle_addt _scrollDown(Rttexttkindttags((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyR*s   cGs2|jj|jjdtddd|_tS(Nig?(Rktscroll_to_iterRmRtTrueR_RR~(RRO((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyRs  N(R R R_RRRuR*R(((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyRs    tHistorycBs;eZddZdZddZdZdZRS(i'cCs"dg|_||_d|_dS(Nti(t ringbuffertmaxhistt histCursor(RR((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyRs  cCse|jjd|t|j|jkr>|jjdnt|jd|_d|jds(R~RtgettkeyvalR_RHtgdkt CONTROL_MASKt SHIFT_MASKtstateR*RERt_ConsoleInput__debug( Rtentryteventt stopSignaltksymtmodstprefixtmasktrvalue((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyRs1 " cCs:|jj}|j\}}|j||t}|S(N(RkRlt get_boundsRR~(RRmtiter1titer2R((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pytgetTextscCs|jjj|dS(N(RkRlR(RR((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pytsetTextscCs|j}ytj|}Wntk ru}tj|j|j}tj||j j j t |dnmt tfk r}|j j j t |dn9X|dk r|j|jj ||jtStStS(NR4(Rtcodetcompile_commandt SyntaxErrorRmtget_iter_at_line_offsettlinenotoffsettplaceRRR*RGt OverflowErrort ValueErrorR_t sendMessageRtclearRR~(RRRRtctetpoint((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyt key_Returns       cCsH|jj}|j|jjdkrD|jj|tStS(Ni( RkRltget_iter_at_markt get_inserttget_lineRRRR~(RRRR((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pytkey_Ups !cCsR|jj}|j|jj|jdkrN|jj|tSt S(Ni( RkRlRRRtget_line_countRRRR~(RRRR((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pytkey_Downs cCs&|jr"ddl}|jndS(Ni(Rtpdbt set_trace(RRRR((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pytkey_ctrl_shift_F9)s  cCs&|jj}|j|jdS(N(RkRltdeleteR(RRm((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyR-scCs|jj}|j\}}|j||t}|jjjt|dy|jj t j |SWn't k r|jjjddnXdS(NRjs!Not connected, command not sent. R4( RkRlRRR~RRR*t pythonifyR R tdoR (RRmRRR((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyR1s N(NN(R R R_RRR~RRRRRRRRt key_ctrl_pt key_ctrl_nRRR(((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyRs          cCs2|jd}d|d|d>> is ... (RRE(Rtlines((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyR>sR}cBs)eZdZdZdZdZRS(sACurry to make failure.printTraceback work with the output widget.cCs||_||_dS(N(RR(RRR((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyRHs cCs|jj||jdS(N(RR*R(Rttxt((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pytwriteLscCsdS(N((R((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pytflushOs(R R t__doc__RRR(((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyR}Fs  t ManholeClientcBsUeZeeidd6ZdZdZdZdZdZ dZ RS(tSettFailurecCs||_|j|j|S(N(R-R2R.(RR-((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyR#Zs cCsx|D]\}}t|tjr>|jjj||q|dkr{t|tjr{|jt |jjdq|jjjt ||qWdS(NR4( t isinstancettypest StringTypestoriginalRR*RRtprintTracebackR}RG(RtmessagesRtcontent((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pytremote_console_s cCsdS(N((Rtxplorer((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pytremote_receiveExploreriscCs|jS(N(t capabilities(R((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pytremote_listCapabilitieslscCs d|_dS(N(R_R-(RR-((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyR.oscCs+|jdkrtn|jjd|S(NR(R-R_R t callRemote(RR((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyRrs ( R R R R RR#RRRR.R(((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyRRs      ((((((RRMttwistedRttwisted.internetRRWRRRRttwisted.python.reflectRttwisted.spreadRttwisted.spread.uiRttwisted.manhole.serviceR tzope.interfaceR RHRRRXt ExceptionR RRRRnRRRRR}tAdaptert ReferenceableRtregisterAdapter(((sB/usr/lib/python2.7/dist-packages/twisted/manhole/ui/gtk2manhole.pyts: " $ M((n  %