a „oeóRã@sldZdZdeZddlZddlZddlZddlZddlZz ddlZWn"e yfe dƒe dƒYn0ddl Z ddl mZddlZ ddl mZejZejje_dej_dej_d ej_zeejd ƒZWnd ZYn0erèe eƒeZeZeZe Z!e"Z#e!Z$d d „Z%dd„Z&dd„Z'dd„Z(dd„Z)dd„Z*dd„Z+dd„Z,Gdd„de-ƒZ.dd„Z/Gd d!„d!e-ƒZ0dS)"a÷adodbapi.remote - A python DB API 2.0 (PEP 249) interface to Microsoft ADO Copyright (C) 2002 Henrik Ekelund, version 2.1 by Vernon Cole * http://sourceforge.net/projects/pywin32 * http://sourceforge.net/projects/adodbapi This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA django adaptations and refactoring thanks to Adam Vandenberg DB-API 2.0 specification: http://www.python.org/dev/peps/pep-0249/ This module source should run correctly in CPython versions 2.5 and later, or IronPython version 2.7 and later, or, after running through 2to3.py, CPython 3.0 or later. z2.6.0.4zadodbapi.remote véNzE* * * Sorry, server operation requires Pyro4. Please "pip import" it.é )ÚProgrammingErrorgD@ÚpickleZADODBAPI_VERBOSEFcCst |||¡S©N)ÚdatetimeÚdate)ÚyearÚmonthÚday©r ú0C:\Program Files\Certbot\pkgs\adodbapi\remote.pyÚDateMsr cCst |||¡Sr)rÚtime)ÚhourÚminuteÚsecondr r r ÚTimeQsrcCst ||||||¡Sr)r)rr r rrrr r r Ú TimestampUsrcCstt |¡dd…ŽS)Né)r rÚgmtime©Zticksr r r Ú DateFromTicksYsrcCstt |¡dd…ŽS)Nré)rrrrr r r Ú TimeFromTicks]srcCstt |¡dd…ŽS)Nr)rrrrr r r ÚTimestampFromTicksasrc OsZtj ||¡}| dd¡d|vrPztjd}WntyFd}Yn0||d<d|vs`|dsŽztjd}Wnty„d}Yn0||d<|d|}d }|�rz2t |¡}d |vrÆt |d ƒ|_ |  ¡}W�qWqžtj j j�y|d 8}|�rt d ¡nt d |¡‚Yqž0qžt||ƒ}|�rˆzt |¡} W�qˆWnBtj j j�y‚|d 8}|�rpt d ¡nt d |¡‚Yn0�q&d |v�r t |d ƒ| _ tƒ} |�rVz|  || ¡W�qVWnŽtj j j�y|d 8}|�ròt d ¡nt dt|ƒ¡‚YnJt�yP} z0t dt|ƒt| ƒt ¡df¡‚WYd} ~ n d} ~ 00�q¦| S)z:Create and open a remote db-api database connection objectZpyro_connectionz1PYRO:ado.connection@%(proxy_host)s:%(proxy_port)sZ proxy_portZ PROXY_PORTi‹#Ú proxy_hostZ PROXY_HOSTz[::1]rZ comm_timeoutézCannot create connection to=%sz,Cannot create ADO connection object using=%sz)Pyro error creating connection to/thru=%sz0Error creating remote connection to=%s, e=%s, %séN)ÚadodbapiZprocess_connect_stringZprocessÚ setdefaultÚosÚenvironÚKeyErrorÚPyro4ZProxyÚfloatZ _pyroTimeoutZmake_connectionZcoreÚerrorsZ PyroErrorrÚsleepÚapiÚ DatabaseErrorÚfix_uriÚ ConnectionÚconnectÚreprÚ_BaseExceptionÚsysÚexc_info) ÚargsÚkwargsZpportZphostZado_uriZ auto_retryÚ dispatcherÚuriZconn_uriZ host_connZmyConnÚer r r r+es†ÿ         ÿ  ÿ ÿ   ÿÿÿr+cCsF| ¡}| d¡}t|ƒdkr(| d¡}t|ƒdkrB|d |¡S|S)zMconvert a generic pyro uri with '0.0.0.0' into the address we actually calledz[::0]rz0.0.0.0r)ZasStringÚsplitÚlenÚjoin)r3r1ÚuÚsr r r r)³s    r)c@sÚeZdZejZejZejZejZejZej Z ej Z ej Z ej Z ej Z ejZedd„ƒZdd„Zdd„Zdd„Zd d „Zd d „Zd d„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Z d#S)$r*cCstS)z;Return a reference to the DBAPI module for this Connection.)r'©Úselfr r r ÚdbapiÎszConnection.dbapicCs0d|_i|_d|_d|_tj|_d|_i|_dS)NFé)Úproxyr1Ú errorhandlerÚsupportsTransactionsr'Ú paramstyleÚtimeoutÚcursorsr:r r r Ú__init__ÓszConnection.__init__cCsŠ||_trtdtt|ƒfƒ||_|j |¡}|durN| tj dt|ƒ¡|  d¡|_ |  d¡|_ |  d¡|_ tr†tdt|ƒƒdS)Nz%s attempting: "%s"TzProxy returns error message=%sr@rArBz$adodbapi.remote New connection at %X)r1ÚverboseÚprintÚversionr,r>r+Ú_raiseConnectionErrorr'ÚOperationalErrorÚgetIndexedValuer@rArBÚid)r;r1Zconnection_makerÚretr r r r+Üs ÿ   zConnection.connectcCs&|j}|durtj}||d||ƒdSr)r?r'ÚstandardErrorHandler©r;Z errorclassZ errorvalueZehr r r rHðsz Connection._raiseConnectionErrorcCsjt|j ¡ƒdd…D] }| ¡qz.|j ¡trDtdt|ƒƒt  |d¡Wnt ydYn0dS)aEClose the connection now (rather than whenever __del__ is called). The connection will be unusable from this point forward; an Error (or subclass) exception will be raised if any operation is attempted with the connection. The same applies to all cursor objects trying to use the connection. Nz'adodbapi.remote Closed connection at %Xr>) ÚlistrCÚvaluesÚcloser>rErFrKÚobjectÚ __delattr__Ú Exception©r;Zcrsrr r r rQös ÿ  ÿ zConnection.closecCs z|j ¡Wn Yn0dSr)r>rQr:r r r Ú__del__ szConnection.__del__cCs.|js dS|j ¡}|r*| tjd|¡dS)aHCommit any pending transaction to the database. Note that if the database supports an auto-commit feature, this must be initially off. An interface method may be provided to turn it back on. Database modules that do not support transactions should implement this method with void functionality. NzError during commit: %s)r@r>ÚcommitrHr'rI©r;Úresultr r r rWs  ÿzConnection.commitcCs$|j ¡}|r | tjd|¡dS)a In case a database does provide transactions this method causes the the database to roll back to the start of any pending transaction. Closing a connection without committing the changes first will cause an implicit rollback to be performed. zError during rollback: %sN)r>ÚrollbackrHr'rIrXr r r Ú _rollback!s   ÿzConnection._rollbackcCs.|dvr|jr|j ||¡t |||¡dS)N)rArBÚ autocommit)r>Zsend_attribute_to_hostrRÚ __setattr__)r;ÚnameÚvaluer r r r],szConnection.__setattr__cCsX|dkr |jr|jS| d¡‚n4|dvr2| |¡S|dkrF| d¡‚n| d|¡‚dS)NrZz,this data provider does not support Rollback)Z dbms_nameZ dbms_versionZconnection_stringr\r>z#Attempting to use closed connectionz#No remote access for attribute="%s")r@r[rrJ)r;Úitemr r r Ú __getattr__2sÿÿÿ  zConnection.__getattr__cCs|j |¡}|Sr)r>Zget_attribute_for_remote)r;ÚindexÚrr r r rJJs zConnection.getIndexedValuecCs t|ƒ}|S)z0Return a new Cursor Object using the connection.)ÚCursor)r;ZmyCursorr r r ÚcursorNszConnection.cursorcCs||j|j<dS)z3message from a new cursor proclaiming its existenceN©rCrKrUr r r Ú _i_am_hereSszConnection._i_am_herecCs z|j|j=Wn Yn0dS)zÚget_table_namesr:r r r rmgszConnection.get_table_namesN)!Ú__name__Ú __module__Ú __qualname__r'ÚWarningÚErrorZInterfaceErrorZ DataErrorr(rIZIntegrityErrorÚ InternalErrorZNotSupportedErrorrrAÚpropertyr<rDr+rHrQrVrWr[r]rarJrergrhrirlrmr r r r r*¿s:   r*cCsª|dur dSt|tƒrdi}t| ¡ƒD]8\}}t|tƒrVt d¡}| |¡|||<q&|||<q&|Sg}|D]8}t|tƒršt d¡}| |¡| |¡ql| |¡ql|S)zcpickle barfs on buffer(x) so we pass as array.array(x) then restore to original form for .execute()NÚB)Ú isinstanceÚdictrOÚitemsÚmemoryViewTypeÚarrayZ fromstringÚappend)ÚxZnewargsÚargÚvalZnewvalZnewargr r r Ú fixpickleks&           rc@s´eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z d*dd„Z dd„Z dd„Zd+dd„Zdd„Zd,dd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd-d(d)„ZdS).rdcCsjd|_d|_||_|jj|_d|_t|_|j ¡|_|  |¡t j |_ t rftdtt|ƒt|jƒfƒdS)Nz%s New cursor at %X on conn %X)Úcommandr?Ú connectionr>ÚrsÚNotImplementedZ convertersZ build_cursorrKrgr'Z RS_REMOTEZrecordset_formatrErFrG)r;r�r r r rD‡s   ÿÿzCursor.__init__cCs6||_z|`Wnty Yn0|j |j|¡dSr)r€Ú descriptionÚAttributeErrorr>Z crsr_preparerK)r;Ú operationr r r Úprepare—s  zCursor.preparecCs t|jdƒSr)ÚiterÚfetchoner:r r r Ú__iter__ŸszCursor.__iter__cCs| ¡}|r|St‚dSr)r‰Ú StopIteration)r;rcr r r Ú__next__¢szCursor.__next__cCs|S)ú8Allow database cursors to be used with context managers.r r:r r r ri¨szCursor.__enter__cCs | ¡dS)r�N©rQrjr r r rl¬szCursor.__exit__cCsì|dkr(zt|jdƒWSYdS0|dkrfz |j |j¡dd…|_|jWStydYdS0|dkr¦zt|j |j¡ƒ}Wntyši}Yn0||_ |S|dkr´t j ‚z|j  |j|¡WSt yæt  d|¡‚Yn0dS)NZnumberOfColumnsrr„Ú columnNamesZ remote_cursorz1Failure getting attribute "%s" from proxy cursor.)r6r‚r>Zcrsr_get_descriptionrKr„Ú TypeErrorrwZcrsr_get_columnNamesr�r'rIZcrsr_get_attribute_for_remoter…rs)r;Úkeyrcr r r ra°s8  ÿ   ÿzCursor.__getattr__cCs`|dkr|j |j|¡|dkrN|tjvr<|j |j|¡n| tjd|¡t  |||¡dS)NZ arraysizerAzinvalid paramstyle ="%s") r>Zcrsr_set_arraysizerKr'Zaccepted_paramstylesZcrsr_set_paramstyleÚ_raiseCursorErrorrrRr])r;r‘r_r r r r]Ðs  ÿzCursor.__setattr__cCs(|j}|durtj}||j|||ƒdSr)r?r'rMr�rNr r r r’ÜszCursor._raiseCursorErrorNcCs¨|jdur| td¡||_z|`Wnty6Yn0z|`WntyRYn0t|ƒ}tdkrzt dt |t |ƒfƒ|j   |j||¡}|r¤| |d|d¡dS)Nú$Attempted operation on closed cursorrz %s executing "%s" with params=%srr)r�r’rr€r„r…r�rrErFrGr,r>Z crsr_executerK)r;r†Ú parametersÚfprYr r r Úexecuteâs. ÿ   ÿþzCursor.executecCs–|jdur| td¡||_z|`Wnty6Yn0z|`WntyRYn0dd„|Dƒ}tdkr€tdt |t |ƒfƒ|j   |j ||¡dS)Nr“cSsg|] }t|ƒ‘qSr )r)Ú.0r|r r r Ú óz&Cursor.executemany..rz"%s executemany "%s" with params=%s)r�r’rr€r„r…r�rErFrGr,r>Zcrsr_executemanyrK)r;r†Zseq_of_parametersÚsqr r r Ú executemanyüs* ÿ   ÿþzCursor.executemanycCsZz|`WntyYn0z|`Wnty6Yn0tdkrLtdtƒ|j |j¡S)Nrz %s nextset) r„r…r�rErFrGr>Z crsr_nextsetrKr:r r r Únextsets   zCursor.nextsetcCsŒ|jdur| td¡||_z|`Wnty6Yn0z|`WntyRYn0t|ƒ}tdkrzt dt |t |ƒfƒ|j   |j||¡S)Nr“rz%s callproc "%s" with params=%s)r�r’rr€r„r…r�rrErFrGr,r>Z crsr_callprocrK)r;Zprocnamer”r•r r r Úcallproc!s* ÿ   ÿþzCursor.callprocc Csrz|j |j¡}Wn2tyD}z| tj|¡WYd}~n2d}~00|durRdS|g|_t |jd|¡dSdS)Nrr) r>Z crsr_fetchonerKr-r’r'r(r‚ÚSQLrows)r;Úf1r4r r r r‰9s$ÿzCursor.fetchonec Csrz:|j |j|¡|_|js gWSt |jt|jƒ|¡}|WStyl}z| tj |¡WYd}~n d}~00dSr) r>Zcrsr_fetchmanyrKr‚r'ržr6rTr’r()r;Úsizercr4r r r Ú fetchmanyFszCursor.fetchmanyc Cslz4|j |j¡|_|jsgWSt |jt|jƒ|¡WStyf}z| tj |¡WYd}~n d}~00dSr) r>Z crsr_fetchallrKr‚r'ržr6rTr’r()r;r4r r r ÚfetchallPszCursor.fetchallcCsŠ|jdurdS|j |¡z|j |j¡Wn Yn0z|`Wn Yn0z|`Wn Yn0d|_d|_tr†tdt|ƒƒdS)Nz#adodbapi.remote Closed cursor at %X) r�rhr>Z crsr_closerKr„r‚rErFr:r r r rQYs(  ÿz Cursor.closecCsz | ¡Wn Yn0dSrrŽr:r r r rVps zCursor.__del__cCsdSrr )r;Zsizesr r r Ú setinputsizesvszCursor.setinputsizescCsdSrr )r;r Úcolumnr r r Ú setoutputsizeyszCursor.setoutputsize)N)N)N)N)rnrorprDr‡rŠrŒrirlrar]r’r–r›rœr�r‰r¡r¢rQrVr£r¥r r r r rd†s(      rd)1Ú__doc__Ú __version__rGrzrr r.rr#Ú ImportErrorrFÚexitrZadodbapi.apibaseZapibaser'Zadodbapi.process_connect_stringrr-ÚutilÚ excepthookZconfigZPREFER_IP_VERSIONZ COMMTIMEOUTZ SERIALIZERÚintr!rEÚstrZ unicodeTypeZlongTypeZ StringTypesÚbytesZmakeByteBufferÚ memoryviewryZBinaryr rrrrrr+r)rRr*rrdr r r r ÚsZ      N -