V Qc@sdZddlZddlZddlZddlZddlZdZdd dYZddlm Z dee fdYZ d d d YZ dS( sRPC Client module.iNitClientcBseZdZedZedZdZdZdZdZ dZ dZ d Z d Z d Zd Zd dZdZdZdZRS(sCRPC Client class. No need to derive a class -- it's fully generic.cCs|j|||jdS(N(t _pre_initt _post_init(tselftaddresstverbose((s)/usr/lib64/python2.7/Demo/pdist/client.pyt__init__scCst|tdkr'd|f}n||_||_|jrTdt|GHntjtjtj|_|jj||jrdGHnd|_ d|_ i|_ |jj d|_ |jj d|_dS(NitsConnecting to %s ...s Connected.itrtw(ttypet_addresst_verbosetreprtsockettAF_INETt SOCK_STREAMt_sockettconnectt_lastidt_nextidt_repliestmakefilet_rft_wf(RRR((s)/usr/lib64/python2.7/Demo/pdist/client.pyRs       cCs|jd|_dS(Ns.methods(t_callt_methods(R((s)/usr/lib64/python2.7/Demo/pdist/client.pyR%scCs|jdS(N(t_close(R((s)/usr/lib64/python2.7/Demo/pdist/client.pyt__del__(scCsj|jr|jjnd|_|jr;|jjnd|_|jr]|jjnd|_dS(N(RtclosetNoneRR(R((s)/usr/lib64/python2.7/Demo/pdist/client.pyR+s     cCs?||jkr2t||}t||||St|dS(N(Rt_stubtsetattrtAttributeError(Rtnametmethod((s)/usr/lib64/python2.7/Demo/pdist/client.pyt __getattr__3s cCs ||_dS(N(R (RR((s)/usr/lib64/python2.7/Demo/pdist/client.pyt _setverbose:scGs|j||S(N(t_vcall(RR"targs((s)/usr/lib64/python2.7/Demo/pdist/client.pyR=scCs|j|j||S(N(t_recvt_vsend(RR"R'((s)/usr/lib64/python2.7/Demo/pdist/client.pyR&@scGs|j||S(N(R)(RR"R'((s)/usr/lib64/python2.7/Demo/pdist/client.pyt_sendCscGs|j||dS(Ni(R)(RR"R'((s)/usr/lib64/python2.7/Demo/pdist/client.pyt _send_noreplyFscCs|j||dS(Ni(R)(RR"R'((s)/usr/lib64/python2.7/Demo/pdist/client.pyt_vsend_noreplyIsicCsy|j}|d|_|s&| }n|||f}|jdkrVdt|GHntj|j}|j||S(Nissending request: %s(RR R tpickletPicklerRtdump(RR"R't wantreplytidtrequesttwp((s)/usr/lib64/python2.7/Demo/pdist/client.pyR)Ls    cCs|j|\}}}||kr:td||fn|dkrJ|S|}tt|rqtt|}n|dkrtj}n||kr|}n||dS(Ns request/reply id mismatch: %d/%ds posix.errors mac.error(s posix.errors mac.error(t_vrecvt RuntimeErrorRthasattrt __builtin__tgetattrtosterror(RR1t exceptiontvaluetridtx((s)/usr/lib64/python2.7/Demo/pdist/client.pyR(Vs      cCs?|j|jj|rR|jdkr7d|GHn|j|}|j|=|St|}x|jdkr|d|GHntj|j}|j}~|jdkrdt |GHn|d}t|}||kr|jdkrdGHn|S||j|<||kra|jdkr+dGHndd|fSqadS(Nis"retrieving previous reply, id = %dswaiting for reply, id = %ds got reply: %sisgot itsgot higher id, assume all ok( t_flushRthas_keyR tabsR-t UnpicklerRtloadR R(RR1treplytaidtrpR=tarid((s)/usr/lib64/python2.7/Demo/pdist/client.pyR4es6            cCs|jjdS(N(Rtflush(R((s)/usr/lib64/python2.7/Demo/pdist/client.pyR?}s(t__name__t __module__t__doc__tVERBOSERRRRRR$R%RR&R*R+R,R)R(R4R?(((s)/usr/lib64/python2.7/Demo/pdist/client.pyRs"              (tSecurityt SecureClientcBseZdZRS(cGsddl}t|j|tj||jj|jj}|j |j |}|j |}t t |}|ddkr|d }n|jj|d|jj|jdS(NitLls (tstringtapplyRRMRRRHRtreadlinetatoitstript_encode_challengeR tlongtwriteR(RR'RPtlinet challengetresponse((s)/usr/lib64/python2.7/Demo/pdist/client.pyRs     (RIRJR(((s)/usr/lib64/python2.7/Demo/pdist/client.pyRNsRcBs eZdZdZdZRS(sJHelper class for Client -- each instance serves as a method of the client.cCs||_||_dS(N(t_clientt_name(RtclientR"((s)/usr/lib64/python2.7/Demo/pdist/client.pyRs cGs|jj|j|S(N(R[R&R\(RR'((s)/usr/lib64/python2.7/Demo/pdist/client.pyt__call__s(RIRJRKRR^(((s)/usr/lib64/python2.7/Demo/pdist/client.pyRs ((( RKtsysRR-R7R9RLRtsecurityRMRNR(((s)/usr/lib64/python2.7/Demo/pdist/client.pyts     s