!;Vc@sdZddlmZddlZddlZddlZddlmZmZddl Z ddl Z ddl Z ddl Z e j ddee jddd d gZe jd d d dd gZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZdefdYZd efd!YZd"efd#YZd$efd%YZd&efd'YZ i d(dgej"6d)egej#6d*egej$6d+egej%6d,egej&6d-egej'6d.egej(6d/egej)6d0e gej*6Z+ddd1Z,d2Z-d3Z.d4efd5YZ/d6efd7YZ0d8efd9YZ1d:e1fd;YZ2d<e2fd=YZ3d>e4fd?YZ5d@e2fdAYZ6dBe1fdCYZ7dDe1fdEYZ8dFe1fdGYZ9dHe1fdIYZ:dJe1fdKYZ;dLe1fdMYZ<dNe1fdOYZ=dPe1fdQYZ>dRe1fdSYZ?dTe1fdUYZ@dVe1fdWYZAdXe1fdYYZBdZZCd[ZDeDZEd\e2fd]YZFd^efd_YZGd`eGfdaYZHdbeGfdcYZIdde2fdeYZJeJZKdfZLdgZMdS(hsxclient - RAD python client language binding This module is the main implementation of the RAD python language binding. i(twrapsN(t RADPackert RADUnpackertignoretcategorytTypettypetsubtypetnullablet Parametertnametvaluet_SchemecBseZdZdZdZRS(s RAD Search Schemes. ii(t__name__t __module__t__doc__tGLOBtREGEX(((s../common/client.pyR 7st_OpcBs8eZdZdZdZdZdZdZdZdZ RS(s RAD protocol Operations. iiiiiii( R RRtINVOKEtGETATTRtSETATTRtLOOKUPtLISTtSUBtUNSUB(((s../common/client.pyR=st_ErrorcBsDeZdZdZdZdZdZdZdZdZ dZ d Z RS( s RAD protocol error codes. iiiiiiiii( R RRtOKtOBJECTtNOMEMtNOTFOUNDtPRIVtSYSTEMtEXISTStMISMATCHtILLEGAL(((s../common/client.pyRHst _RequestErrorcBs;eZdZdZdZdZdZdZRS(s A RAD protocol request error. cCs)tt|j||_||_dS(s Create a _RequestError object. N(tsuperR$t__init__t_errort_payload(tselfterrortpayload((s../common/client.pyR&Ws cCsdt|jd|jfS(s! Return a _RequestError message. s%s (%d)i(t_ErrorsR'(R)((s../common/client.pyt get_message]scCs|jS(s! Return a _RequestError payload. (R((R)((s../common/client.pyt get_payloadascCs|jS(s Return a _RequestError error. (R'(R)((s../common/client.pyt get_errorescCsd|jS(NsRequest error: (R-(R)((s../common/client.pyt__str__is(R RRR&R-R.R/R0(((s../common/client.pyR$Us     t_ContainerErrorcBs;eZdZddddZdZdZdZRS(s A RAD error base class. cCstt|j||_|dk r|jdk rj|jjt|j |j |j||_ q|jdk r|jjt|j |j ||_ qd|_ n d|_ dS(s" Create a _ContainerError object. N( R%R1R&t_msgtNoneRRt_unpackRR.RR((R)tmsgtexR*tconn((s../common/client.pyR&os   cCs|jS(s# Return a _ContainerError message. (R2(R)((s../common/client.pyR-scCs|jS(s# Return a _ContainerError payload. (R((R)((s../common/client.pyR.scCs!|jr|jjS|jSdS(N(R(R0R2(R)((s../common/client.pyR0s  N(R RRR3R&R-R.R0(((s../common/client.pyR1ms   t ObjectErrorcBs eZdZddddZRS(s A RAD ObjectError. cCstt|j||_|dk r|jdk rj|jjt|j |j |j||_ q|jdk r|jjt|j |j ||_ qd|_ n d|_ dS(s" Create a _ContainerError object. N( R%R1R&R2R3RRR4RR.RR((R)R5R6R*R7((s../common/client.pyR&s   N(R RRR3R&(((s../common/client.pyR8st NomemErrorcBseZdZRS(s A RAD No Memory Error. (R RR(((s../common/client.pyR9st NotFoundErrorcBseZdZRS(s A RAD Not Found Error. (R RR(((s../common/client.pyR:st PrivErrorcBseZdZRS(s A RAD Privilege Error. (R RR(((s../common/client.pyR;st SystemErrorcBseZdZRS(s A RAD System Error. (R RR(((s../common/client.pyR<st ExistsErrorcBseZdZRS(s A RAD Exists Error. (R RR(((s../common/client.pyR=st MismatchErrorcBseZdZRS(s A RAD Mismatch Error. (R RR(((s../common/client.pyR>st IllegalErrorcBseZdZRS(s A RAD Illegal Error. (R RR(((s../common/client.pyR?ssno errorsobject-specific errors out of memorys not foundsinsufficient privilegess system errorsalready existss type mismatchsillegal accesscCsV|jdkr2t|jd||||n t|jd||d|dS(s Raise a RAD error. iN(R'R,R3(R6R5R*R7((s../common/client.pyt _raise_errors#cCsB|j}|j}tjj|}|tjd|dS(s* Read a packed RAD time from an unpacker. t microsecondsi(t unpack_hypert unpack_inttdatetimetutcfromtimestampt timedelta(tunpackertsecondstnanostdtval((s../common/client.pyt _read_times  cCs|jdkp$|jj|dk}|rI|tjddd}n"|tjdddd|j}|tjdd}|j|d|j|dddS(s! Write a RAD time into a packer. iittzinfoRAi@BiN(RLR3t utcoffsetRDRFt pack_hypertpack_int(tpackertdatatnaivetdeltat timestamp((s../common/client.pyt _write_times'"tRADArraycBs,eZdZedZedZRS(s A RAD Array (list). cCsL|r,|dk }|j||s,dSn|j||jj|dS(s9 Pack the supplied array value into the supplied packer. N(R3t pack_boolt pack_arrayRt_get_array_packer(tclstapackerR Rtatypetisdata((s../common/client.pyt_packs   cCs3|r|j rdS|j|jj||S(s3 Unpack an array value from the supplied unpacker. N(t unpack_boolR3t unpack_arrayRt_get_array_unpacker(RZt aunpackerRR\R7((s../common/client.pyR4s(R RRt classmethodR^R4(((s../common/client.pyRVs tRADDictcBs,eZdZedZedZRS(s Derived (dict) RAD Types. c Cs|\}}|r8|dk }|j||s8dSn|jt|x>|D]6}|jj||t|jj|||tqRWdS(s3 Pack the supplied value into the supplied packer. N(R3RWROtlenRR^tFalse( RZRPR RtstypetktypetvtypeR]tkey((s../common/client.pyR^s    c Cs|\}}|r#|j r#dSt}|j}xHt|D]:} |jj|t|} |jj|t||| s(t _get_unpacker(RZRtR7Ru((Rbs../common/client.pyRa6scCst||jS(s* Return a packer for the supplied object. (tgetattrt_packer(RZRt((s../common/client.pyRsCscCst||jS(s- Return an unpacker for the supplied object. (Rwt _unpacker(RZRt((s../common/client.pyRvHscCsC|r,|dk }|j||s,dSn|j||dS(s3 Pack the supplied value into the supplied packer. N(R3RWRs(RZRPR RR]((s../common/client.pyR^Ms   cCs/|r|j}|sdSn|j|S(s, Unpack a value from the supplied unpacker. N(R_R3Rv(RZRGRR7R]((s../common/client.pyR4Ws  N(R RRRxRyR3R&RcRYRaRsRvR^R4(((s../common/client.pyRp!s    t RADObjectcBs\eZdZedZedZedZedZdZdZ RS(s+ An abstract class for all Base RAD Types. cs%|jfd}|S(sh Return a packer suitable for use when packing an array of the supplied object. cs|tS(s1 Return a closure which uses the correct packer. (Rf(R (R[Rt(s../common/client.pyRrms(Rs(RZRtRr((R[Rts../common/client.pyRYescs(|jfd}|S(sm Return an unpacker suitable for use when unpacking an array of the supplied object. cstS(s3 Return a closure which uses the correct unpacker. (Rf((RbR7Rt(s../common/client.pyRuzs(Rv(RZRtR7Ru((RbR7Rts../common/client.pyRarscCs|jS(s* Return a packer for the supplied object. (R^(RZRt((s../common/client.pyRsscCs|jS(s- Return an unpacker for the supplied object. (R4(RZRt((s../common/client.pyRvscCs0t|t|kr(|j|jkStSdS(N(Rt__dict__Rf(R)tother((s../common/client.pyt__eq__scCs|j| S(N(R}(R)R|((s../common/client.pyt__ne__s( R RRRcRYRaRsRvR}R~(((s../common/client.pyRzbs   t RADStructcBs5eZdZedZedZdZRS(s Derived (struct) RAD Types. cCs|r,|dk }|j||s,dSnx|jD]}|djdk r|djj|t||d|dj|djq6|djj|t||d|djq6WdS(s3 Pack the supplied value into the supplied packer. Nii(R3RWt_fieldsRRR^RwR(RZRPR RR]tattr((s../common/client.pyR^s    c Cs|r|j rdS|j|}x|jD]}|djdk rt||d|djj||dj|dj|q0t||d|djj||dj|q0W|S(s, Unpack a value from the supplied unpacker. iiN( R_R3t__new__RRtsetattrRR4R(RZRGRR7RmR((s../common/client.pyR4s c Csfd|jj}d}x?|jD]4}|d||dt||df7}d}q W|d7}|S(Ns%s(ts %s%s = %ris, t)(t __class__R RRw(R)tbuftseptfield((s../common/client.pyt__repr__s(  (R RRRcR^R4R(((s../common/client.pyRst RADEnumInitcBseZdZdZRS(s; A metaclass to simplify the creation of RAD Enumerations. cCs]tj||||d}x:|dD].}t||||d||d}q'WdS(Nit_slotst_valuesi(RR&R(tmcsR tbasestmydictRmtenum((s../common/client.pyR&s (R RRR&(((s../common/client.pyRstRADEnumcBsYeZdZdZedZedZdZdZdZ dZ RS(s Enumerated (enum) RAD Types. cCs5tt|j|jj||_||_dS(N(R%RR&Rtindext_indexRq(R)R ((s../common/client.pyR&scCs@|r,|dk }|j||s,dSn|j|jdS(N(R3RWt pack_uintR(RZRPR RR]((s../common/client.pyR^s   cCs:|r|j rdS|j}||j|}|S(N(R_R3t unpack_uintR(RZRGRR7tvalRm((s../common/client.pyR4s  cCs*t||jr"|j|jkStSdS(N(t isinstanceRR{Rf(R)R|((s../common/client.pyR}scCs|j| S(N(R}(R)R|((s../common/client.pyR~scCs|j|jj|jS(N(RRRRq(R)((s../common/client.pyR0scCs0|j|jj|j}d|jj|fS(Ns%s(value = %s)(RRRRqRR (R)R((s../common/client.pyRs( R RRR&RcR^R4R}R~R0R(((s../common/client.pyRs     t RADBooleancBs#eZdZdZdZdZRS(s Boolean (boolean) RAD Type. RWR_cCsE|dkr%tt|j|ntt|jt|dS(N(R3R%RR&tbool(R)R ((s../common/client.pyR&s (R RRRxRyR&(((s../common/client.pyRst RADIntegercBs#eZdZdZdZdZRS(s Integer (integer) RAD Type. RORCcCsE|dkr%tt|j|ntt|jt|dS(N(R3R%RR&tint(R)R ((s../common/client.pyR& s (R RRRxRyR&(((s../common/client.pyRst RADUIntegercBs#eZdZdZdZdZRS(s' Unsigned Integer (uinteger) RAD Type. RRcCsE|dkr%tt|j|ntt|jt|dS(N(R3R%RR&R(R)R ((s../common/client.pyR&s (R RRRxRyR&(((s../common/client.pyRstRADLongcBs#eZdZdZdZdZRS(s Long (long) RAD Type. RNRBcCsE|dkr%tt|j|ntt|jt|dS(N(R3R%RR&tlong(R)R ((s../common/client.pyR&$s (R RRRxRyR&(((s../common/client.pyRstRADULongcBs#eZdZdZdZdZRS(s! Unsigned Long (ulong) RAD Type. t pack_uhypert unpack_uhypercCsE|dkr%tt|j|ntt|jt|dS(N(R3R%RR&R(R)R ((s../common/client.pyR&1s (R RRRxRyR&(((s../common/client.pyR+stRADFloatcBs#eZdZdZdZdZRS(s Float (float) RAD Type. t pack_floatt unpack_floatcCsE|dkr%tt|j|ntt|jt|dS(N(R3R%RR&tfloat(R)R ((s../common/client.pyR&>s (R RRRxRyR&(((s../common/client.pyR8st RADDoublecBs#eZdZdZdZdZRS(s Double (double) RAD Type. t pack_doublet unpack_doublecCsE|dkr%tt|j|ntt|jt|dS(N(R3R%RR&R(R)R ((s../common/client.pyR&Ks (R RRRxRyR&(((s../common/client.pyREstRADTimecBs5eZdZedZedZdZRS(s Time (time) RAD Type. cCst||dS(N(RU(RZRPR R((s../common/client.pyR^UscCs t|S(N(RK(RZRGRR7((s../common/client.pyR4YscCsH|dkr%tt|j|ntt|jtj|dS(N(R3R%RR&RDttime(R)R ((s../common/client.pyR&]s (R RRRcR^R4R&(((s../common/client.pyRRst RADStringcBs#eZdZdZdZdZRS(s String (string) RAD Type. t pack_stringt unpack_stringcCsE|dkr%tt|j|ntt|jt|dS(N(R3R%RR&tstr(R)R ((s../common/client.pyR&js (R RRRxRyR&(((s../common/client.pyRdst RADOpaquecBs#eZdZdZdZdZRS(s Opaque (opaque) RAD Type. t pack_opaquet unpack_opaquecCsE|dkr%tt|j|ntt|jt|dS(N(R3R%RR&R(R)R ((s../common/client.pyR&ws (R RRRxRyR&(((s../common/client.pyRqstRADVoidcBs5eZdZedZedZdZRS(s Void RAD Type. cCsdS(N((RZtvpackerR R((s../common/client.pyR^scCsdS(N(R3(RZRRR7((s../common/client.pyR4scCstt|j|dS(N(R%RR&(R)R ((s../common/client.pyR&s(R RRRcR^R4R&(((s../common/client.pyR~st RADSecretcBs#eZdZdZdZdZRS(s Secret (string) RAD Type. RRcCsE|dkr%tt|j|ntt|jt|dS(N(R3R%RR&R(R)R ((s../common/client.pyR&s (R RRRxRyR&(((s../common/client.pyRscsfd}|S(s. Class decorator. Identifies class stability. cs |_|S(N(t_rad_stability(tklass(t stability(s../common/client.pytinners ((RR((Rs../common/client.pytClassStabilityscsfd}|S(s0 Method decorator. Identifies method stability. cs(_tfd}|S(Ncs ||S(N((targstkwargs(tf(s../common/client.pyt wrapped_fs(RR(RR(R(Rs../common/client.pytwraps ((RR((Rs../common/client.pytMethodStabilityst RADInterfacecBseZdZiZdddddZedZedZdZ dZ dZ dZ d Z d Zd Zd Zd ZRS(s+ Abstract, base class for all RAD objects. icCs||_||_|rX|j|jkrLtd|jt|fn||_n(t|ji|jd6d|j|_|r||_ n|t j |j|jfRR RRR^Rt get_bufferRt _make_requestRRt_read_responseR4R$R@RR'( R)tmethtresultR*RtmpackerRmt argpackertsertrespRtR6((s../common/client.pyt_invokes8   &   c Cst}|j|j|j||jjtj|j}yz|jj |}|dk r|j dk r|j j ||j|j |j}n|j j ||j|j}|SWn<tk r}t|d||j|jf||jnXdS(s5 Remotely retrieve a property and return the result. sError getting %s from %s: %dN(RRNRRRRRRRRR3RRR4RR$R@RR'( R)RRR*tppackerRRRtR6((s../common/client.pyt_getter s    c Cs5t}|j|j|j|t}|jtkr`|dkr`td|n|jdk r|j j |||j|jn|j j |||j|j |j |j jtj|j }y|j j|Wn?tk r0}t|d|j|j|jf||j nXdS(s Remotely update a property. s0Non-nullable property '%s' cannot be set to NonesError setting %s on %s: %dN(RRNRRRRfR3R>RRR^RRRRRRRR$R@RR'( R)RRR*R RRQRR6((s../common/client.pyt_setters"    " cCs d|jjt|jfS(Ns%s(%s)(RR RR(R)((s../common/client.pyR4sN(R RRRR3R&RcR^R4R0RRRRRRRR(((s../common/client.pyRs       "  t _ADRPatterncBsMeZdZdZdZdZdZdZdZdZ RS(sD A RAD ADR pattern class. Base pattern matching class. cCs||_||_||_dS(s Base Pattern class constructor. Arguments: kvs: dictionary key/value pairs pattern: string string representation of this pattern scheme: _Scheme the pattern _Scheme this instance belongs to N(t_kvst_patternt_scheme(R)tkvstpatterntscheme((s../common/client.pyR&?s  cCs|s dS|j|jkS(Ni(R(R)R|((s../common/client.pyt__cmp__RscCs|jS(N(R(R)((s../common/client.pyR0XscCs d|jS(s+ A string representation of this instance. s Pattern: (R(R)((s../common/client.pyR[scCs|jS(N(R(R)((s../common/client.pyt get_pattern_scCs|jS(N(R(R)((s../common/client.pyt get_schemebscCs |j|S(N(R(R)Rj((s../common/client.pyt get_valuees( R RRR&RR0RRRR(((s../common/client.pyR8s      tADRRegexPatterncBs eZdZdZdZRS(s The ADRRegexPattern class serves as a pattern to match object names. An ADRRegexPattern is an "Extended Regular Expression" (ERE) which may be used to match the names of RAD objects. cCs[djg|jD]\}}d||f^q}tt|j||tjdS(s Create a pattern object using the supplied dictionary. Arguments: kvs: dictionary of keys and values the regex pattern Returns: ADRRegexPattern a new ADRRegexPattern t,s%s=%sN(tjointitemsR%RR&R R(R)RtktvR((s../common/client.pyR&qs 8cCsTxM|jD]B}y(tj|j||j|s7tSWq tk rKq Xq WtS(s Match the pattern object against the supplied name. Arguments: name: ADRName the name to match Returns: Boolean True/false (Rtretmatcht_kvpairsRfRtTrue(R)R Rj((s../common/client.pyRs   (R RRR&R(((s../common/client.pyRis tADRGlobPatterncBs eZdZdZdZRS(s The ADRGlobPattern class serves as a pattern to match object names. An ADRGlobPattern is an glob style pattern which may be used to match the names of RAD objects. cCs[djg|jD]\}}d||f^q}tt|j||tjdS(s Create a pattern object using the supplied dictionary. Arguments: kvs: dictionary of keys and values the glob pattern Returns: ADRGlobPattern a new ADRGlobPattern Rs%s=%sN(RRR%RR&R R(R)RRRR((s../common/client.pyR&s 8cCsTxM|jD]B}y(tj|j||j|s7tSWq tk rKq Xq WtS(s Match the pattern object against the supplied name. Arguments: name: ADRName the name to match Returns: Boolean True/false (RtfnmatchRRfRR(R)R Rj((s../common/client.pyRs   (R RRR&R(((s../common/client.pyRs RcBskeZdZd d dZdZedZed dZdZ dZ dZ dZ RS( s5 The ADRName class serves as an object name. cCstt|j||_|dkr1d}n||_||_|dkr^|j}nt|t sy|j }n||_ dS(s Create a Name object using the supplied name and version details. Arguments: name: string representation of name Returns: ADRName a new ADRName iiN(ii( R%RR&RR3RRt_ADRName__proxy_from_strRRRt_proxy(R)tdomaintkvpairsRtversion((s../common/client.pyR&s        cCs|jd}d}g}xg|D]_}|jd||jfy(|jd||j|jdfWq tk r~q q Xq Wx:|D]2}yttj||SWqtk rqXqWtd|dS( NRtbindingstservers rad.%s.%ss rad.%s.%s_%disCan't locate class: %s(RR( RtappendRRRRwtsystmodulest ValueError(R)t klassnametmodstmodnamestmodtmodname((s../common/client.pyt__proxy_from_strs        cCs|r,|dk }|j||s,dSn|j|j|jt|jx2|jD]'}|j||j|j|q\WdS(N(R3RWRRRReR(RZtnpackerR RR]Rj((s../common/client.pyR^s   c Cs|r|j rdSi}|j}|j}x6t|D](}|j} |j} | || \}}|dkrB|d7}n||d|j|7}qW|S(Nt:iRt=(Rt enumerateR(R)R RmRj((s../common/client.pyR0s    cCs%dt||jd|jdfS(s+ A string representation of this instance. sName: %s Version: (%s.%s)ii(RR(R)((s../common/client.pyR'sN( R RRR3R&RRcR^R4R}RR0R(((s../common/client.pyRs    cCsVt|dr|jjSt|dr2|jjSt|drK|jjS|jSdS(s. Return the stability level of the component. tfgettfsettfdelN(thasattrRRRR(t component((s../common/client.pytrad_get_stability0s   cCstj|jS(s' Return the module version of the obj. (tinspectt getmoduletvers(Rt((s../common/client.pytrad_get_version<s(NRt functoolsRRDRRtrad.encodings.xdrRRt collectionsRRtwarningstfilterwarningstDeprecationWarningt namedtupleRR tobjectR RRRR$R1R8R9R:R;R<R=R>R?R3RRRRRR R!R"R#R,R@RKRURVRdRpRzRRRRRRRRRRRRRRRRRRtPropertyStabilityRRRRRtRADNameRR(((s../common/client.pyt s          !  A10 *           1--j