ó ¿œ^c@s›dZddlZddlZddlZddlZddlZdZdd d„ƒYZddlm Z dee fd„ƒYZ d d d „ƒYZ dS( sRPC Client module.iÿÿÿÿNitClientcBs§eZdZed„Zed„Zd„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z d „Zd „Zd d„Zd„Zd„Zd„ZRS(sCRPC Client class. No need to derive a class -- it's fully generic.cCs|j||ƒ|jƒdS(N(t _pre_initt _post_init(tselftaddresstverbose((s)/usr/lib64/python2.7/Demo/pdist/client.pyt__init__scCsÙt|ƒtdƒkr'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|jƒdS(N(t_close(R((s)/usr/lib64/python2.7/Demo/pdist/client.pyt__del__(scCsj|jr|jjƒnd|_|jr;|jjƒnd|_|jr]|jjƒnd|_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||dƒS(Ni(R)(RR"R'((s)/usr/lib64/python2.7/Demo/pdist/client.pyt _send_noreplyFscCs|j||dƒS(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||f‚n|dkrJ|S|}tt|ƒrqtt|ƒ}n|dkr‰tj}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ƒ}~|jdkr¾dt |ƒGHn|d}t|ƒ}||krû|jdkr÷dGHn|S||j|<||kra|jdkr+dGHndd|fSqaWdS(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|jjƒdS(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 SecureClientcBseZd„ZRS(cGsÊddl}t|j|ƒtj|ƒ|jjƒ|jjƒ}|j |j |ƒƒ}|j |ƒ}t t |ƒƒ}|ddkr›|d }n|jj|dƒ|jjƒ|jƒdS(NiÿÿÿÿtLls (tstringtapplyRRMRRRHRtreadlinetatoitstript_encode_challengeR tlongtwriteR(RR'RPtlinet challengetresponse((s)/usr/lib64/python2.7/Demo/pdist/client.pyR†s     (RIRJR(((s)/usr/lib64/python2.7/Demo/pdist/client.pyRN„sRcBs eZdZd„Zd„ZRS(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.pyR˜s 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.pyR”s ((( RKtsysRR-R7R9RLRtsecurityRMRNR(((s)/usr/lib64/python2.7/Demo/pdist/client.pyts     s