a Rf @sbddlZddlZddlZddlmZddlmZddlZddlZ ddl m Z ddl Z ddl mZz ddlZWneydZYn0ddZdejdd Zd Zd Zd Zd ZdZdZdZd ZdZdZd ZdZdZ dZ!Gddde"Z#Gddde#Z$Gddde#Z%Gddde#Z&e'Z(Z)edddZ*dd Z+e+d!rFd"d#Z,ne+d$rZd%d#Z,nd&d#Z,[*[+d'd(Z-Gd)d*d*Z.d+d,Z/d-d.Z0Gd/d0d0Z1d1d2Z2e.e1fZ3Gd3d4d4Z4Gd5d6d6Z5Gd7d8d8Z6Gd9d:d:Z7Gd;d<d<Z8Gd=d>d>Z9dZ:Z;Zd[dDdEZ?dFdGZ@d\dIdJZAGdKdLdLerPejBneCZDGdMdNdNZEGdOdPdPZFGdQdRdReFZGGdSdTdTZHeHZIeJdUkr^eHdVZKzeLeKjMNWn0e#yZOzeLdWeOWYdZO[On dZO[O00e9eKZPePQePRd dXePSdd zePD]ZTeLeTqWn0e#y\ZOzeLdWeOWYdZO[On dZO[O00dS)]N)datetime)Decimal)expat)BytesIOcCs$|dd}|dd}|ddS)N&z&z>)replace)sr 2/opt/alt/python39/lib64/python3.9/xmlrpc/client.pyescapes  r z%d.%diiiDii ipiԁiCiBiiic@seZdZejZdS)ErrorN)__name__ __module__ __qualname__object__str__r r r r rsrc@seZdZddZddZdS) ProtocolErrorcCs&t|||_||_||_||_dSN)r__init__urlerrcodeerrmsgheaders)selfrrrrr r r rs  zProtocolError.__init__cCsd|jj|j|j|jfS)Nz<%s for %s: %s %s>) __class__rrrrrr r r __repr__szProtocolError.__repr__Nrrrrrr r r r rsrc@s eZdZdS) ResponseErrorN)rrrr r r r r!sr!c@seZdZddZddZdS)FaultcKst|||_||_dSr)rr faultCode faultString)rr#r$Zextrar r r rs zFault.__init__cCsd|jj|j|jfS)Nz <%s %s: %r>)rrr#r$rr r r rszFault.__repr__Nr r r r r r"sr"cCs*zt|dkWSty$YdS0dS)NZ0001F)_day0strftime ValueError)Zfmtr r r _try s r)z%YcCs |dSN%Y%m%dT%H:%M:%Sr'valuer r r _iso8601_formatsr/z%4YcCs |dS)Nz%4Y%m%dT%H:%M:%Sr,r-r r r r/scCs|ddS)Nr+)r'zfillr-r r r r/scCsLt|trt|St|ttjfs<|dkr2t}t|}d|ddS)Nrz%04d%02d%02dT%02d:%02d:%02d) isinstancerr/tupletime struct_time localtimer-r r r _strftimes  r8c@sneZdZdddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZdS)DateTimercCs t|tr||_n t||_dSr)r3strr.r8)rr.r r r r.s zDateTime.__init__cCstt|tr|j}|j}nTt|tr2|j}t|}n:t|trH|j}|}n$t|drd|}|}n|}t}||fS)N timetuple) r3r9r.rr/r:hasattrr;NotImplementedrotherr or r r make_comparable4s      zDateTime.make_comparablecCs"||\}}|turtS||kSrrAr=r>r r r __lt__FszDateTime.__lt__cCs"||\}}|turtS||kSrrBr>r r r __le__LszDateTime.__le__cCs"||\}}|turtS||kSrrBr>r r r __gt__RszDateTime.__gt__cCs"||\}}|turtS||kSrrBr>r r r __ge__XszDateTime.__ge__cCs"||\}}|turtS||kSrrBr>r r r __eq__^szDateTime.__eq__cCst|jdSr*)r5strptimer.rr r r r;dszDateTime.timetuplecCs|jSrr-rr r r rlszDateTime.__str__cCsd|jj|jt|fS)Nz<%s %r at %#x>)rrr.idrr r r roszDateTime.__repr__cCst||_dSr)r:stripr.rdatar r r decoderszDateTime.decodecCs$|d||j|ddSNzz )writer.)routr r r encodeus  zDateTime.encodeN)r)rrrrrArCrDrErFrGr;rrrMrQr r r r r9(s r9cCst}|||Sr)r9rMrLr.r r r _datetimezs rScCs t|dSr*)rrH)rLr r r _datetime_typesrTc@s6eZdZd ddZddZddZdd Zd d ZdS) BinaryNcCs>|durd}n&t|ttfs,td|jjt|}||_dS)Nz#expected bytes or bytearray, not %s)r3bytes bytearray TypeErrorrrrLrKr r r rszBinary.__init__cCs t|jdS)Nzlatin-1)r:rLrr r r rszBinary.__str__cCst|tr|j}|j|kSr)r3rUrL)rr?r r r rGs z Binary.__eq__cCst||_dSr)base64 decodebytesrLrKr r r rMsz Binary.decodecCs4|dt|j}||d|ddSNz asciiz )rOrZ encodebytesrLrM)rrPencodedr r r rQs  z Binary.encode)N)rrrrrrGrMrQr r r r rUs  rUcCst}|||Sr)rUrMrRr r r _binarys r`c@s$eZdZddZddZddZdS) ExpatParsercCsDtdd|_}||_|j|_|j|_|j|_ d}| |ddSr) rZ ParserCreate_parser_targetstartZStartElementHandlerendZEndElementHandlerrLZCharacterDataHandlerxml)rtargetparserencodingr r r rszExpatParser.__init__cCs|j|ddS)NF)rbParserKr r r feedszExpatParser.feedcCs6z |j}WntyYn0|`|`|dddS)NrVT)rbAttributeErrorrcrj)rrhr r r closes   zExpatParser.closeN)rrrrrkrmr r r r ras rac@seZdZdddZiZddZddZd d Zeeed<d d Z e ee <d dZ e ee <e Z ddZeee<efddZeee<ddZeee<eee<ddZeee<eee<efddZeee<ddZeee<ddZeee<eee<eed<dS) MarshallerNFcCsi|_d|_||_||_dSr)memorLri allow_none)rrirpr r r rszMarshaller.__init__cCsg}|j}|j}t|tr@|d||j|jd||dn4|d|D]}|d||||dqL|dd|}|S) Nz )r#r$z z z z z )append_Marshaller__dumpr3r"r#r$join)rvaluesrPrOdumpvresultr r r dumpss&     zMarshaller.dumpscCsz|jt|}Wndtyvt|ds:tdt|t|jD]"}||jvrDtdt|qD|jd}Yn0||||dS)N__dict__zcannot marshal %s objects_arbitrary_instance)dispatchtypeKeyErrorr<rY__mro__keys)rr.rOftype_r r r Z__dumps  zMarshaller.__dumpcCs|jstd|ddS)Nz0cannot marshal None unless allow_none is enabledz)rprYrr.rOr r r dump_nilszMarshaller.dump_nilcCs$|d||rdpd|ddS)Nz10z r rr r r dump_bool szMarshaller.dump_boolcCs<|tks|tkrtd|d|tt||ddS)Nzint exceeds XML-RPC limitsz z )MAXINTMININT OverflowErrorr:intrr r r dump_long&s zMarshaller.dump_longcCs |d|t||ddS)Nzz )reprrr r r dump_double1s zMarshaller.dump_doublecCs |d||||ddS)Nzz r )rr.rOr r r r dump_unicode7s zMarshaller.dump_unicodecCs,|dt|}||d|ddSr\)rZr^rM)rr.rOr_r r r dump_bytes=s zMarshaller.dump_bytescCsZt|}||jvrtdd|j|<|j}|d|D]}|||q6|d|j|=dS)Nz"cannot marshal recursive sequencesz z )rIrorYrs)rr.rOirvrwr r r dump_arrayEs   zMarshaller.dump_arraycCst|}||jvrtdd|j|<|j}|d|D]D\}}|dt|ts\td|d||||||dq:|d|j|=dS)Nz%cannot marshal recursive dictionariesz z zdictionary key must be stringz%s z z )rIrorYrsitemsr3r:)rr.rOr rrvkrwr r r dump_structSs     zMarshaller.dump_structcCs |d|t||ddSrN)r8rr r r dump_datetimees zMarshaller.dump_datetimecCs2|jtvr ||_|||`n||j|dSr)rWRAPPERSrOrQrrzrr r r dump_instanceks   zMarshaller.dump_instancer{)NF) rrrrr|ryrsrr}rboolrrZdump_intrfloatr rr:rrWrXrr4listrdictrrrr9rUr r r r rns:      rnc@sjeZdZdDddZddZddZdd Zd d Zd d ZddZ ddZ iZ ddZ e e d<ddZ e e d<ddZee d<ee d<ee d<ee d<ee d<ee d<d d!Zee d"<ee d#<d$d%Zee d&<d'd(Zee d)<ee d*<d+d,Zee d-<d.d/Zee d0<d1d2Zee d3<d4d5Zee d6<d7d8Zee d9<d:d;Zee d<<d=d>Zee d?<d@dAZee dB<dCS)E UnmarshallerFcCsHd|_g|_g|_g|_d|_d|_d|_|jj|_|p:||_||_ dS)NFutf-8) _type_stack_marks_data_value _methodname _encodingrr _use_datetime _use_bytes)r use_datetimeuse_builtin_typesr r r rs  zUnmarshaller.__init__cCs>|jdus|jrt|jdkr4tfi|jdt|jS)Nfaultr)rrr!r"rr4rr r r rms  zUnmarshaller.closecCs|jSr)rrr r r getmethodnameszUnmarshaller.getmethodnamecCs ||_dSr)r)rriZ standaloner r r rfszUnmarshaller.xmlcCshd|vr|dd}|dks&|dkr8|jt|jg|_|jrZ||jvrZtd||dk|_dS)N:arraystructzunknown tag %rr.) splitrrrlenrrrr|r!)rtagattrsr r r rds zUnmarshaller.startcCs|j|dSr)rrr)rtextr r r rLszUnmarshaller.datac Csrz|j|}WnPty^d|vr*YdSz|j|dd}WntyXYYdS0Yn0||d|jS)Nrrrq)r|r~rrtr)rrrr r r res  zUnmarshaller.endc Csjz|j|}WnPty^d|vr*YdSz|j|dd}WntyXYYdS0Yn0|||S)Nrr)r|r~r)rrrLrr r r end_dispatchs  zUnmarshaller.end_dispatchcCs|dd|_dSNr)rrrrKr r r end_nils zUnmarshaller.end_nilZnilcCs:|dkr|dn|dkr(|dntdd|_dS)NrFrTzbad boolean valuer)rrrYrrKr r r end_booleans   zUnmarshaller.end_booleanbooleancCs|t|d|_dSr)rrrrrKr r r end_intszUnmarshaller.end_intZi1Zi2Zi4Zi8rZ bigintegercCs|t|d|_dSr)rrrrrKr r r end_doubleszUnmarshaller.end_doubleZdoublercCs|t|d|_dSr)rrrrrKr r r end_bigdecimalszUnmarshaller.end_bigdecimalZ bigdecimalcCs&|jr||j}||d|_dSr)rrMrrrrKr r r end_strings  zUnmarshaller.end_stringstringnamecCs.|j}|j|dg|j|d<d|_dSr)rpoprr)rrLmarkr r r end_arrays zUnmarshaller.end_arrayrcCs`|j}i}|j|d}tdt|dD]}||d|||<q,|g|j|d<d|_dS)Nrrr%)rrrrangerr)rrLrrrrr r r end_struct s zUnmarshaller.end_structrcCs6t}||d|jr"|j}||d|_dS)Nr]r)rUrMrQrrLrrrrrLr.r r r end_base64s  zUnmarshaller.end_base64rZcCs,t}|||jrt|}||dSr)r9rMrrTrrrr r r end_dateTime s  zUnmarshaller.end_dateTimezdateTime.iso8601cCs|jr||dSr)rrrKr r r end_value(szUnmarshaller.end_valuer.cCs d|_dS)NparamsrrKr r r end_params/szUnmarshaller.end_paramsrcCs d|_dS)NrrrKr r r end_fault3szUnmarshaller.end_faultrcCs"|jr||j}||_d|_dS)N methodName)rrMrrrKr r r end_methodName7s zUnmarshaller.end_methodNamerN)FF)rrrrrmrrfrdrLrerr|rrrrrrrrrrrrrrr r r r rsX   rc@s$eZdZddZddZddZdS)_MultiCallMethodcCs||_||_dSr)_MultiCallMethod__call_list_MultiCallMethod__name)rZ call_listrr r r rDsz_MultiCallMethod.__init__cCst|jd|j|fSNz%s.%s)rrrrrr r r __getattr__Gsz_MultiCallMethod.__getattr__cGs|j|j|fdSr)rrrrrargsr r r __call__Isz_MultiCallMethod.__call__Nrrrrrrr r r r rAsrc@seZdZddZddZdS)MultiCallIteratorcCs ||_dSr)results)rrr r r rPszMultiCallIterator.__init__cCsR|j|}t|tikr.t|d|dn t|tgkrF|dStddS)Nr#r$rz#unexpected type in multicall result)rr}r"r()rritemr r r __getitem__Ss  zMultiCallIterator.__getitem__N)rrrrrr r r r rLsrc@s,eZdZddZddZddZddZd S) MultiCallcCs||_g|_dSr)_MultiCall__server_MultiCall__call_list)rserverr r r rmszMultiCall.__init__cCsd|jjt|fS)Nz <%s at %#x>)rrrIrr r r rqszMultiCall.__repr__cCs t|j|Sr)rrrr r r rtszMultiCall.__getattr__cCs6g}|jD]\}}|||dq t|jj|S)N)rr)rrrrrsystemZ multicall)rZmarshalled_listrrr r r rwszMultiCall.__call__N)rrrrrrrr r r r r\srFcCsrtrHtrH|rt}tj}n|r&t}t}nt}t}tdd||t}t|}n"t||d}trbt|}nt |}||fS)NTFrr) FastParserFastUnmarshallerrTrZr[r`rSr"rra)rrZ mkdatetimeZmkbytesrgrhr r r getparsers    rcCst|trd}n|rt|tr|s&d}tr4t|}n t||}||}|dkr^dt|}nd}|rx|d|d|df}n|r|d|d f}n|Sd |S) Nr%rz$ z z z z z z rq)r3r"r4FastMarshallerrnryr:rt)r methodnameZmethodresponserirpmrLZ xmlheaderr r r rys6    rycCs2t||d\}}|||||fSNr)rrkrmr)rLrrpur r r loadss  rcCsPtstt}tjd|dd}||Wdn1s>0Y|S)Nwbr%)modefileobjZ compresslevel)gzipNotImplementedErrorrGzipFilerOgetvalue)rLrgzfr r r gzip_encodes (r@c Cststtjdt|dP}z$|dkr0|}n||d}WntyZtdYn0Wdn1sp0Y|dkrt||krtd|S)Nrbrrrr%z invalid dataz#max gzipped payload length exceeded)rrrrreadOSErrorr(r)rLZ max_decoderZdecodedr r r gzip_decode)s  ,rc@seZdZddZddZdS)GzipDecodedResponsecCs.tstt||_tjj|d|jddS)Nrr)rrrriorr)rresponser r r rGszGzipDecodedResponse.__init__cCs,ztj|W|jn |j0dSr)rrrmrrr r r rmOszGzipDecodedResponse.closeN)rrrrrmr r r r rCsrc@s$eZdZddZddZddZdS)_MethodcCs||_||_dSr _Method__send _Method__name)rsendrr r r r\sz_Method.__init__cCst|jd|j|fSr)rrrrr r r r_sz_Method.__getattr__cGs||j|Srrrr r r rasz_Method.__call__Nrr r r r rYsrc@seZdZdeZdZdZdddddZdd d Zdd d Z d dZ ddZ ddZ ddZ ddZddZddZddZdS) TransportzPython-xmlrpc/%sTNFr )rcCs&||_||_d|_t||_g|_dSN)NN)r_use_builtin_types _connectionr_headers_extra_headers)rrrrr r r rxs  zTransport.__init__c CsdD]v}z|||||WStjjy:|r6Yqtyx}z(|sb|jtjtjtjfvrdWYd}~qd}~00qdS)N)rr%) single_requesthttpclientZRemoteDisconnectedrerrnoZ ECONNRESETZ ECONNABORTEDZEPIPE)rhosthandler request_bodyverboserer r r requestszTransport.requestcCsz8|||||}|}|jdkr6||_||WSWn.tyLYntyf|Yn0|ddr|| t |||j|j t | dS)Nzcontent-lengthrq) send_requestZ getresponseZstatusrparse_responser" Exceptionrm getheaderrrreasonrZ getheaders)rrrrrZ http_connZrespr r r r s$     zTransport.single_requestcCst|j|jdSr)rrrrr r r rszTransport.getparsercCsri}t|tr|\}}tj|\}}|rdtj|}t|d}d | }dd|fg}ng}|||fS)NrrqZ AuthorizationzBasic ) r3r4urllibparseZ _splituserZunquote_to_bytesrZr^rMrtr)rrx509ZauthZ extra_headersr r r get_host_infos   zTransport.get_host_infocCsL|jr||jdkr|jdS||\}|_}|tj|f|_|jdS)Nrr%)rrr r r ZHTTPConnectionrrZchostrr r r make_connections  zTransport.make_connectioncCs |j\}}|rd|_|dSr)rrm)rr connectionr r r rms zTransport.closecCs||}|j|j}|r$|d|jrJtrJ|jd|dd|dn |d||d|d|jf| ||| |||S)Nr%ZPOSTT)Zskip_accept_encoding)zAccept-Encodingr)z Content-Typeztext/xmlz User-Agent) rrr Zset_debuglevelaccept_gzip_encodingrZ putrequestrr user_agent send_headers send_content)rrrrdebugr rr r r rs         zTransport.send_requestcCs|D]\}}|||qdSr) putheader)rr rkeyvalr r r r#s zTransport.send_headerscCsR|jdur0|jt|kr0tr0|ddt|}|dtt|||dS)NContent-EncodingrzContent-Length)encode_thresholdrrr&rr:Z endheaders)rr rr r r r$ s   zTransport.send_contentcCst|dr*|dddkr$t|}q.|}n|}|\}}|d}|sJqj|jr^tdt|||q:||urz| | | S)Nrr)rqrizbody:) r<rrrrrprintrrkrm)rrstreamrrrLr r r r1s      zTransport.parse_response)FF)F)F)rrr __version__r"r!r*rrr rrrrmrr#r$rr r r r rjs   ! rcs.eZdZd dddfdd ZddZZS) SafeTransportFr Nrcontextcstj|||d||_dS)Nrrr)superrr0)rrrrr0rr r rRs zSafeTransport.__init__cCst|jr||jdkr|jdSttjds2td||\}|_}|tjj|dfd|ji|p`if|_|jdS)Nrr%HTTPSConnectionz1your version of http.client doesn't support HTTPSr0) rr<r r rrr r4r0rr r r r[s    zSafeTransport.make_connection)FF)rrrrr __classcell__r r r3r r.Os r.c@sVeZdZddddddZddZd d Zd d Zd dZddZddZ ddZ dS) ServerProxyNFr r/c Cstj|} | jdvrtd| j|_tjddg| dd|_|jsPd|_|dur| jdkrpt } d| i} nt } i} | f|||d| }||_ |pd |_ ||_ ||_dS) N)r httpszunsupported XML-RPC protocolrqrz/RPC2r7r0r1r)rrZurlsplitZschemerZnetloc_ServerProxy__hostZ urlunsplit_ServerProxy__handlerr.r_ServerProxy__transport_ServerProxy__encoding_ServerProxy__verbose_ServerProxy__allow_none) rZuri transportrirrprrrr0rrZ extra_kwargsr r r rs.     zServerProxy.__init__cCs|jdSr)r:rmrr r r Z__closeszServerProxy.__closecCsPt|||j|jd|jd}|jj|j|j||jd}t |dkrL|d}|S)N)rirpxmlcharrefreplace)rr%r) ryr;r=rQr:rr8r9r<r)rrrrrr r r Z __requests  zServerProxy.__requestcCsd|jj|j|jfS)Nz <%s for %s%s>)rrr8r9rr r r rszServerProxy.__repr__cCs t|j|Sr)r_ServerProxy__requestrr r r rszServerProxy.__getattr__cCs.|dkr|jS|dkr|jStd|fdS)Nrmr>zAttribute %r not found)_ServerProxy__closer:rl)rattrr r r rs zServerProxy.__call__cCs|Srr rr r r __enter__szServerProxy.__enter__cGs |dSr)rArr r r __exit__szServerProxy.__exit__)NNFFFF) rrrrrAr@rrrrCrDr r r r r6zs  r6__main__zhttp://localhost:8000ZERROR )FF)NNNF)FF)r)UrZsysr5rdecimalrZ http.clientr Z urllib.parserZ xml.parsersrr rrr ImportErrorr version_infor-rrZ PARSE_ERRORZ SERVER_ERRORZAPPLICATION_ERRORZ SYSTEM_ERRORZTRANSPORT_ERRORZNOT_WELLFORMED_ERRORZUNSUPPORTED_ENCODINGZINVALID_ENCODING_CHARZINVALID_XMLRPCZMETHOD_NOT_FOUNDZINVALID_METHOD_PARAMSZINTERNAL_ERRORrrrr!r"rrZBooleanr&r)r/r8r9rSrTrUr`rrarnrrrrrrrrryrrrrrrrrr.r6ZServerrrr+Z currentTimeZgetCurrentTimerwZmultiZgetDatapowaddrr r r r s              R #!(C %  ' K  f+i