a oeR@sldZdZdeZddlZddlZddlZddlZddlZz ddlZWn"e yfe de dYn0ddl Z ddl mZddlZ ddl mZejZejje_dej_dej_d ej_zeejd ZWnd ZYn0ere eeZeZeZe Z!e"Z#e!Z$d d Z%ddZ&ddZ'ddZ(ddZ)ddZ*ddZ+ddZ,Gddde-Z.ddZ/Gd d!d!e-Z0dS)"aadodbapi.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 vNzE* * * Sorry, server operation requires Pyro4. Please "pip import" it. )ProgrammingErrorgD@pickleZADODBAPI_VERBOSEFcCst|||SN)datetimedate)yearmonthdayr 0C:\Program Files\Certbot\pkgs\adodbapi\remote.pyDateMsr cCst|||Sr)rtime)hourminutesecondr r r TimeQsrcCst||||||Sr)r)rr r rrrr r r TimestampUsrcCstt|ddS)N)r rgmtimeZticksr r r DateFromTicksYsrcCstt|ddS)Nr)rrrrr r r TimeFromTicks]srcCstt|ddS)Nr)rrrrr r r TimestampFromTicksasrc OsZtj||}|ddd|vrPztjd}WntyFd}Yn0||d<d|vs`|dsztjd}Wntyd}Yn0||d<|d|}d }|rz2t|}d |vrt |d |_ | }WqWqtj j jy|d 8}|rtd ntd |Yq0qt||}|rzt|} WqWnBtj j jy|d 8}|rptd ntd |Yn0q&d |vrt |d | _ t} |rVz| || WqVWntj j jy|d 8}|rtd ntdt|YnJtyP} z0tdt|t| tdfWYd} ~ n d} ~ 00q| 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_timeoutzCannot 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, %sN)adodbapiZprocess_connect_stringZprocess setdefaultosenvironKeyErrorPyro4ZProxyfloatZ _pyroTimeoutZmake_connectionZcoreerrorsZ PyroErrorrsleepapi DatabaseErrorfix_uri Connectionconnectrepr_BaseExceptionsysexc_info) argskwargsZpportZphostZado_uriZ auto_retry dispatcheruriZconn_uriZ host_connZmyConner 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)ZasStringsplitlenjoin)r3r1usr r r r)s    r)c@seZdZejZejZejZejZejZej Z ej Z ej Z ej Z ej Z ejZeddZddZddZddZd d Zd d Zd dZddZddZddZddZddZddZddZddZdd Zd!d"Z d#S)$r*cCstS)z;Return a reference to the DBAPI module for this Connection.)r'selfr r r dbapiszConnection.dbapicCs0d|_i|_d|_d|_tj|_d|_i|_dS)NF)proxyr1 errorhandlersupportsTransactionsr' paramstyletimeoutcursorsr:r r r __init__szConnection.__init__cCs||_trtdtt|f||_|j|}|durN|tj dt|| d|_ | d|_ | d|_ trtdt|dS)Nz%s attempting: "%s"TzProxy returns error message=%sr@rArBz$adodbapi.remote New connection at %X)r1verboseprintversionr,r>r+_raiseConnectionErrorr'OperationalErrorgetIndexedValuer@rArBid)r;r1Zconnection_makerretr r r r+s    zConnection.connectcCs&|j}|durtj}||d||dSr)r?r'standardErrorHandlerr;Z errorclassZ errorvalueZehr r r rHsz Connection._raiseConnectionErrorcCsjt|jddD] }|qz.|jtrDtdt|t |dWnt 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>) listrCvaluescloser>rErFrKobject __delattr__ Exceptionr;Zcrsrr r r rQs    zConnection.closecCs z|jWn 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'rIr;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;namevaluer r r r],szConnection.__setattr__cCsX|dkr |jr|jS|dn4|dvr2||S|dkrF|dn|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;indexrr 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 existenceNrCrKrUr r r _i_am_hereSszConnection._i_am_herecCs z|j|j=Wn Yn0dS)zget_table_namesr:r r r rmgszConnection.get_table_namesN)!__name__ __module__ __qualname__r'WarningErrorZInterfaceErrorZ DataErrorr(rIZIntegrityError InternalErrorZNotSupportedErrorrrApropertyr<rDr+rHrQrVrWr[r]rarJrergrhrirlrmr r r r r*s:   r*cCs|dur dSt|trdi}t|D]8\}}t|trVtd}|||||<q&|||<q&|Sg}|D]8}t|trtd}||||ql||ql|S)zcpickle barfs on buffer(x) so we pass as array.array(x) then restore to original form for .execute()NB) isinstancedictrOitemsmemoryViewTypearrayZ fromstringappend)xZnewargsargvalZnewvalZnewargr r r fixpickleks&           rc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ d*ddZ ddZ ddZd+ddZddZd,ddZd d!Zd"d#Zd$d%Zd&d'Zd-d(d)ZdS).rdcCsjd|_d|_||_|jj|_d|_t|_|j|_| |t j |_ t rftdtt|t|jfdS)Nz%s New cursor at %X on conn %X)commandr? connectionr>rsNotImplementedZ convertersZ build_cursorrKrgr'Z RS_REMOTEZrecordset_formatrErFrG)r;rr r r rDs   zCursor.__init__cCs6||_z|`Wnty Yn0|j|j|dSr)r descriptionAttributeErrorr>Z crsr_preparerK)r; operationr r r prepares  zCursor.preparecCs t|jdSr)iterfetchoner:r r r __iter__szCursor.__iter__cCs|}|r|StdSr)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 riszCursor.__enter__cCs |dS)rNrQrjr r r rlszCursor.__exit__cCs|dkr(zt|jdWSYdS0|dkrfz |j|jdd|_|jWStydYdS0|dkrzt|j|j}Wntyi}Yn0||_ |S|dkrt j z|j |j|WSt yt d|Yn0dS)NZnumberOfColumnsrr columnNamesZ remote_cursorz1Failure getting attribute "%s" from proxy cursor.)r6rr>Zcrsr_get_descriptionrKr TypeErrorrwZcrsr_get_columnNamesrr'rIZcrsr_get_attribute_for_remoterrs)r;keyrcr r r ras8     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;rr_r r r r]s  zCursor.__setattr__cCs(|j}|durtj}||j|||dSr)r?r'rMrrNr r r rszCursor._raiseCursorErrorNcCs|jdur|td||_z|`Wnty6Yn0z|`WntyRYn0t|}tdkrzt dt |t |f|j |j||}|r||d|ddS)N$Attempted operation on closed cursorrz %s executing "%s" with params=%srr)rrrrrrrrrErFrGr,r>Z crsr_executerK)r;r parametersfprYr r r executes.    zCursor.executecCs|jdur|td||_z|`Wnty6Yn0z|`WntyRYn0dd|D}tdkrtdt |t |f|j |j ||dS)NrcSsg|] }t|qSr )r).0r|r r r z&Cursor.executemany..rz"%s executemany "%s" with params=%s)rrrrrrrrErFrGr,r>Zcrsr_executemanyrK)r;rZseq_of_parameterssqr r r executemanys*    zCursor.executemanycCsZz|`WntyYn0z|`Wnty6Yn0tdkrLtdt|j|jS)Nrz %s nextset) rrrrErFrGr>Z crsr_nextsetrKr:r r r nextsets   zCursor.nextsetcCs|jdur|td||_z|`Wnty6Yn0z|`WntyRYn0t|}tdkrzt dt |t |f|j |j||S)Nrrz%s callproc "%s" with params=%s)rrrrrrrrrErFrGr,r>Z crsr_callprocrK)r;Zprocnamerrr 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-rr'r(rSQLrows)r;f1r4r r r r9s$zCursor.fetchonec Csrz:|j|j||_|js gWSt|jt|j|}|WStyl}z|tj |WYd}~n d}~00dSr) r>Zcrsr_fetchmanyrKrr'rr6rTrr()r;sizercr4r r r fetchmanyFszCursor.fetchmanyc Cslz4|j|j|_|jsgWSt|jt|j|WStyf}z|tj |WYd}~n d}~00dSr) r>Z crsr_fetchallrKrr'rr6rTrr()r;r4r r r fetchallPszCursor.fetchallcCs|jdurdS|j|z|j|jWn Yn0z|`Wn Yn0z|`Wn Yn0d|_d|_trtdt|dS)Nz#adodbapi.remote Closed cursor at %X) rrhr>Z crsr_closerKrrrErFr:r r r rQYs(  z Cursor.closecCsz |Wn Yn0dSrrr:r r r rVps zCursor.__del__cCsdSrr )r;Zsizesr r r setinputsizesvszCursor.setinputsizescCsdSrr )r;rcolumnr r r setoutputsizeyszCursor.setoutputsize)N)N)N)N)rnrorprDrrrrirlrar]rrrrrrrrrQrVrrr r r r rds(      rd)1__doc__ __version__rGrzrr r.rr# ImportErrorrFexitrZadodbapi.apibaseZapibaser'Zadodbapi.process_connect_stringrr-util excepthookZconfigZPREFER_IP_VERSIONZ COMMTIMEOUTZ SERIALIZERintr!rEstrZ unicodeTypeZlongTypeZ StringTypesbytesZmakeByteBuffer memoryviewryZBinaryr rrrrrr+r)rRr*rrdr r r r sZ      N -