403Webshell
Server IP : 209.209.40.120  /  Your IP : 216.73.217.112
Web Server : Microsoft-IIS/10.0
System : Windows NT NEWWWW 10.0 build 17763 (Windows Server 2019) i586
User : NEWWWW$ ( 0)
PHP Version : 8.3.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Python312/Lib/site-packages/mysql/connector/fabric/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Python312/Lib/site-packages/mysql/connector/fabric/__pycache__/connection.cpython-312.pyc
�

��f����dZddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
Z
ddlZddlZ	ddl
mZmZmZddlZddlmZej2ddk(r
	dd	lmZd
Zn		dd	lmZd
ZddlZddlmZdd
l m!Z!ddl"m#Z#ddl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*ddl+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1ddl0m2Z2m3Z3ddl4m5Z5ddl6m7Z7ddl0m8Z8ddl9m:Z:m;Z;m<Z<e1jze1j|fZ?e1jze1j�e1j�e1j�e1j�fZDgaEdZFddd�ZGiZHdZIdZJdZKdZLdZMdZNdZOdZPdZQdZRdZSdZTdZUdZVeWfd dfeXeYeWejej�ge[e<�z�d!dfeXe[fd"dfeYfd#eOfeWfd$dfeWfd%dfeWfd&eUfeYfd'eLfeYfd(eKfd)�	Z\e
j�d*�Z^Gd+�d,e_�Z`Gd-�d.e_�ZaGd/�d0e_�ZbGd1�d2eb�ZcGd3�d4e_�ZdGd5�d6ed�Zed7�Zfd8�Zgd9�Zhd:�ZierGd;�d<ej��ZkGd=�d>e�ZlGd?�d@e_�ZmGdA�dBe_�ZnGdC�dDen�ZoGdE�dFen�ZpGdG�dHe_�Zqy#e$rddlmZmZmZddlmZddlmZY��(wxYw#e$rdZY��wxYw#e$rdZY��wxYw)Iz,Implementing communication with MySQL Fabric�N)�	b16decode)�bisect)�md5)�Fault�ServerProxy�	Transport)�
BadStatusLine�)�HTTPSConnectionTF)�MySQLConnection)�MySQLConverter)�MySQLConnectionPool)�Error�InterfaceError�NotSupportedError�MySQLFabricError�
InternalError�
DatabaseError)�MySQLCursor�MySQLCursorBuffered�MySQLCursorRaw�MySQLCursorBufferedRaw)�	errorcode�)�FabricMySQLServer�FabricShard)�FabricCache)�WeightedRoundRobin��version)�PY2�	isunicode�
UNICODE_TYPES�xmlrpci~i~)r$�mysql��GLOBAL�LOCAL�FAULTYzName of group of serverszSharding keyzList of tables in queryz#Read-Only, Write-Only or Read-Writez+Identity of the shard for direct connection�z+GLOBAL for accessing Global Group, or LOCALzAttempts for getting connectionz$Seconds to wait between each attempt)	�group�key�tables�mode�shard�mapping�scope�attempts�
attempt_delayzmyconnpy-fabricc�6�eZdZdZd�Zd�Zd�Zd	d�Zd�Zd�Z	y)
�MySQLRPCProtocolz0Class using MySQL protocol to query Fabric.
    c�~�t�|_t|||||�|_|jj	�y�N)r
�	converter�FabricMySQLConnection�handler�connect��self�fabric�host�port�connect_attempts�
connect_delays      �CC:\Python312\Lib\site-packages\mysql/connector/fabric/connection.py�__init__zMySQLRPCProtocol.__init__�s6��'�)���,�V�T�4�-=�-:�<���	
������c	���	g}t|j��D]�\}}|}|jj|�}|jj	|�}|jj|�}|j
dj|t|�����	|S#t$r1}tjjjd|z��d}~wwxYw)z,Process query parameters given as dictionaryz{0}={1}z)Failed processing pyformat-parameters; %sN)�list�itemsr8�to_mysql�escape�quote�append�format�str�	Exceptionr%�	connector�errors�ProgrammingError)r=�params�resr,�value�conv�errs       rC�_process_params_dictz%MySQLRPCProtocol._process_params_dict�s���	��C�"�6�<�<�>�2�
=�
��U����~�~�.�.�t�4���~�~�,�,�T�2���~�~�+�+�D�1���
�
�9�+�+�C��T��;�<�
=��J��	�	C��/�/�(�(�9�9�;�c�A�C�
C��	C�s�B B%�%	C�.,C�Cc���	|}|D�cgc]}|jj|���}}|D�cgc]}|jj|���}}|D�cgc]}|jj|���}}|D�cgc]
}t	|���}}t|�Scc}wcc}wcc}wcc}w#t$r1}tjjjd|z��d}~wwxYw)zProcess query parameters.z'Failed processing format-parameters; %sN)r8rIrJrKrN�tuplerOr%rPrQrR)r=rSrT�irWs     rC�_process_paramsz MySQLRPCProtocol._process_params�s���
	��C�7:�;�!�4�>�>�*�*�1�-�;�C�;�58�9��4�>�>�(�(��+�9�C�9�47�8�q�4�>�>�'�'��*�8�C�8�#&�'�a�3�q�6�'�C�'�
��:���<��9��8��'���	A��/�/�(�(�9�9�9�C�?�A�
A��	A�sJ�B3�"B�B3�"B$�B3�"B)�:B3�B.�B3�B3�3	C-�<,C(�(C-Nc���|sd}|jjjd��}g}|j||d��D]!}|j	|j���#|S)zYExecutes the given query

        Returns a list containing response from Fabric
        �T)�
dictionary)�multi)r:�
connection�cursor�executerL�fetchall)r=�stmtrS�cur�resultsrTs      rC�_execute_cmdzMySQLRPCProtocol._execute_cmd�se��
��F��l�l�%�%�,�,��,�=�����;�;�t�V�4�;�8�	+�C��N�N�3�<�<�>�*�	+��rEc��g}|r"|j|�}|j|�|r"|j|�}|j|�dj|�}|S)z6Process arguments to create query parameters.
        z, )r\�extendrX�join)r=�args�kwargsrSs    rC�
create_paramszMySQLRPCProtocol.create_params�sZ������'�'��-�D��M�M�$����.�.�v�6�F��M�M�&�!����6�"���
rEc�*�|j|i|��}dj|||�}d}	|j|�}t|�}|S#tt
jtf$r-}	dj||t|	���}
t|
��d}	~	wwxYw)z�Executes the given command with MySQL protocol

        Executes the given command with the given parameters.

        Returns an iterator to navigate to navigate through the result set
        returned by Fabric
        zCALL {0}.{1}({2})N�+Executing {group}.{command} failed: {error}�r+�command�error)	rnrMrh�FabricMySQLSetr�socketrsrrN)r=r+rrrlrmrS�cmd�fab_set�data�exc�msgs           rCrczMySQLRPCProtocol.execute�s���$��#�#�T�4�V�4��!�(�(����@����	&��$�$�S�)�D�$�T�*�G�����v�|�|�^�4�	&�?�F�F��W�C��H�G�>�C� ��%�%��	&�s�A�B�%(B
�
Br7)
�__name__�
__module__�__qualname__�__doc__rDrXr\rhrnrcr^rErCr5r5�s%����� �
��rEr5c��eZdZdZd�Zd�Zy)�XMLRPCProtocolz2Class using XML-RPC protocol to query Fabric.
    c�`�t|||||�|_|jj�yr7)�FabricXMLRPCConnectionr:r;r<s      rCrDzXMLRPCProtocol.__init__�s*��-�f�d�D�.>�
�O��������rEc
��	t|jj|�}t||�}d}	||i|��}	t|	�}|S#t$r+}t	dj||t
|�����d}~wwxYw#ttjtf$r-}dj||t
|���}
t|
��d}~wwxYw)z�Executes the given command with XML-RPC protocol

        Executes the given command with the given parameters

        Returns an iterator to navigate to navigate through the result set
        returned by Fabric
        z'{group}.{command} not available ({err}))r+rrrWNrprq)�getattrr:�proxy�AttributeError�
ValueErrorrMrN�	FabricSetrrursr)r=r+rrrlrm�grprvryrwrxrzs           rCrczXMLRPCProtocol.execute�s���	=��$�,�,�,�,�e�4�C��#�w�'�C�
��	&���'��'�D���o�G�����	=��F�M�M��W�#�c�(�N�<�=�
=��	=���v�|�|�^�4�	&�?�F�F��W�C��H�G�>�C� ��%�%��	&�s.�,A�A=�	A:�&A5�5A:�=C�(C�CN)r{r|r}r~rDrcr^rErCr�r��s����
rEr�c��eZdZdZd�Zy)�FabricMySQLResponsezHClass used to parse a response got from Fabric with MySQL protocol.
    c�|�|dd}|d|d|d}}}|rt|��||_||_|d|_y)Nr�fabric_uuid�ttl�messager)r�fabric_uuid_strr��
coded_rows)r=rx�infor�r�rss      rCrDzFabricMySQLResponse.__init__sU���A�w�q�z��)-�m�)<�d�5�k�)-�i�� %�#��� ��'�'�.�������q�'��rEN)r{r|r}r~rDr^rErCr�r�s���	"rEr�c�4��eZdZdZ�fd�Zd�Zd�Zd�Z�xZS)rtz^Iterator to navigate through the result set returned from Fabric
    with MySQL Protocol.
    c����tt|�|�|jdj	�|_|j|_tjd|j
�|_	y)�)Initialize the FabricSet object.
        r�	ResultSetN)
�superrtrDr��keys�_FabricMySQLSet__names�_FabricMySQLSet__rows�collections�
namedtuple�_FabricMySQLSet__result�r=rx�	__class__s  �rCrDzFabricMySQLSet.__init__(sP���	�n�d�,�T�2����q�)�.�.�0����o�o���#�.�.�{�D�L�L�I��
rEc�,�t|j�S�z.The number of rows in the result set.
        )�lenr��r=s rC�rowcountzFabricMySQLSet.rowcount0����4�;�;��rEc#�VK�|jD]}|jdi|�����y�w)�UIterate over the rows of the result set.

        Each row is a named tuple.
        Nr^)r�r��r=�rows  rC�rowszFabricMySQLSet.rows5s/����
�;�;�	'�C��$�-�-�&�#�&�&�	'�s�')c�@�|jdi|j|��S)�GIndexing method for a row.

        Each row is a named tuple.
        r^)r�r��r=�indexs  rCr�zFabricMySQLSet.row=s!��
�t�}�}�2�t�{�{�5�1�2�2rE�	r{r|r}r~rDr�r�r��
__classcell__�r�s@rCrtrt$s����J� �
'�3rErtc��eZdZdZdZd�Zy)�FabricResponsez4Class used to parse a response got from Fabric.
    rc���|\}}}}}|rt|��|tjk7r*tdjtj|����||_||_||_||_y)z-Initialize the FabricResponse object
        zdSupported protocol has version {sversion}. Got a response from MySQL Fabric with version {gversion}.)�sversion�gversionN)rr��SUPPORTED_VERSIONrM�format_versionr�r�r�)r=rxr�r�r�rsr�s       rCrDzFabricResponse.__init__Ks��?C�;���#�u�d�� ��'�'��^�=�=�=� �=�=C�V�+�=�=�+�>D�>-��
�-���.��������rEN)r{r|r}r~r�rDr^rErCr�r�Es�����rEr�c�4��eZdZdZ�fd�Zd�Zd�Zd�Z�xZS)r�zEIterator to navigate through the result set returned from Fabric
    c�~���tt��|�t�j�dk(sJ��jddd�_�jdd�_t�fd��jD��st�j�dk(sJ�tjd�j
��_
y)	r�rrr��namesr�c3�`�K�|]%}t�j�t|�k(���'y�wr7)r��_FabricSet__names)�.0r�r=s  �rC�	<genexpr>z%FabricSet.__init__.<locals>.<genexpr>hs#�����H�S�3�t�|�|�$��C��0�H�s�+.r�N)r�r�rDr�r�r��_FabricSet__rows�allr�r��_FabricSet__resultr�s` �rCrDzFabricSet.__init__as����	�i��'��-��4�?�?�#�q�(�(�(����q�)�&�1�'�:����o�o�a�(��0����H�D�K�K�H�H��4�;�;��1�$�	%�%�#�.�.�{�D�L�L�I��
rEc�,�t|j�Sr�)r�r�r�s rCr�zFabricSet.rowcountlr�rEc#�PK�|jD]}|j|����y�w)r�N)r�r�r�s  rCr�zFabricSet.rowsqs,����
�;�;�	&�C��$�-�-��%�%�	&�s�$&c�:�|j|j|�S)r�)r�r�r�s  rCr�z
FabricSet.rowys��
�t�}�}�d�k�k�%�0�1�1rEr�r�s@rCr�r�^s����	J� �
&�2rEr�c��|sgat|ttf�s|g}|D]<}t|t�r
|dk\r|dkstd��tj
|��>y)axAdd MySQL error to be reported to Fabric

    This function adds error_codes to the error list to be reported to
    Fabric. To reset the custom error reporting list, pass None or empty
    list.

    The error_codes argument can be either a MySQL error code defined in the
    errorcode module, or list of error codes.

    Raises AttributeError when code is not an int.
    i�i�zUnknown or invalid error code.N)�REPORT_ERRORS_EXTRA�
isinstancerGrZ�intr�rL)�error_codes�codes  rC�extra_failure_reportr��sa��� ���k�D�%�=�1�"�m���)���$��$�T�T�\�d�T�k� �!A�B�B��"�"�4�(�)rEc�(�dj||��S)z�Create an XMLRPC URI for connecting to Fabric

    This method will create a URI using the host and TCP/IP
    port suitable for connecting to a MySQL Fabric instance.

    Returns a URI.
    zhttp://{host}:{port}�r?r@)rMr�s  rC�_fabric_xmlrpc_urir��s��"�(�(�d��(�>�>rEc�^�tjtjt||��S)z!Create a UUID using host and port)�uuid�uuid3�
NAMESPACE_URLr�r�s  rC�_fabric_server_uuidr��s!���:�:�d�(�(�*<�T�4�*H�I�IrEc��tstd��t|||g�r&|std��|s|r|r|std��|||d�Sy)zvValidate the SSL argument.

    Raises AttributeError is required argument is not set.

    Returns dict or None.
    �Python does not support SSLzMissing ssl_ca argument.z;ssl_key and ssl_cert need to be both specified, or neither.)�car,�certN)�HAVE_SSLr�anyr�)�ssl_ca�ssl_key�ssl_certs   rC�_validate_ssl_argsr��sf����:�;�;�
�F�G�X�&�'�� �!;�<�<��x�'�h� �)��
�
���
�	
�rEc�0��eZdZdZ�fd�Zd�Zdd�Z�xZS)�FabricHTTPSHandlerz Class handling HTTPS connectionsc���tr'tjj|�||_yt�|�
�||_y��
InitializeN)r!�urllib2�HTTPSHandlerrDr��_ssl_config)r=�
ssl_configr�s  �rCrDzFabricHTTPSHandler.__init__�s9�����$�$�-�-�d�3� *�D���� �"�)�D�rEc�:�|j|j|�S)zOpen HTTPS connection)�do_open�get_https_connection)r=�reqs  rC�
https_openzFabricHTTPSHandler.https_open�s���<�<�� 9� 9�3�?�?rEc�R�t||jd|jd��S)zReturns a HTTPSConnectionr,r�)�key_file�	cert_file)rr�)r=r?�timeouts   rCr�z'FabricHTTPSHandler.get_https_connection�s.��"���)�)�%�0��*�*�6�2��
rE)i,)r{r|r}r~rDr�r�r�r�s@rCr�r��s���.�	*�	@�	rEr�c�d��eZdZdZdj	ej�Z	d�fd�	Zdd�Z	�xZ
S)�FabricTransportz"Custom XMLRPC Transport for FabriczMySQL Connector Python/{0}c�H��trtj|d��nt�|�	d��||_||_||_||_||_||_g|_|jrJ|j
r>tj�|_tj|j�|_
nd|_
d|_|r#|jj|�d|_nd|_|jr&|jj|j�yy)r�F)�use_datetimeN�https�http)r!rrDr��	_username�	_password�
_use_datetime�verbose�	_handlersr��HTTPPasswordMgrWithDefaultRealm�_passmgr�HTTPDigestAuthHandler�
_auth_handlerrL�_scheme)r=�username�passwordr�r��
https_handlerr�s      �rCrDzFabricTransport.__init__�s��������t�%�8��G��%��0�!���!���)������!���!�������>�>�d�n�n�#�C�C�E�D�M�!(�!>�!>�t�}�}�!M�D��!%�D�� �D�M���N�N�!�!�-�0�"�D�L�!�D�L�����N�N�!�!�$�"4�"4�5�rEc�P�dj|j||��}|jr2|jjd||j|j
�|jr$tjdj|��tj|j�}d|jd�}tj|||��}	|j|j|��S#tj tj"f$r~}		d}
|	j$d	k(rd
}|	j$}
n|	j&}dj||
��}n*#t($rd
t+|	�vrd}nt+|	�}YnwxYwt-d|z��d}	~	wt.$rt-d��wxYw)zSend XMLRPC requestz{scheme}://{host}{handler})�schemer?r:NzFabricTransport: {0}ztext/xml)zContent-Typez
User-Agent)�headers���i�zPermission deniedz{reason} ({code}))�reasonr��SSLz	SSL errorzConnection with Fabric failed: z(Connection with Fabric failed: check SSL)rMrr��add_passwordr�r�r��_LOGGER�debugr��build_openerr��
user_agent�Request�parse_response�open�URLError�	HTTPErrorr�rr�rNrr	)
r=r?r:�request_bodyr��uri�openerrr�ryr�rrzs
             rC�requestzFabricTransport.requests��*�1�1����7;�W�2�N���=�=��M�M�&�&�t�S�$�.�.�'+�~�~�
7��<�<��M�M�0�7�7��<�=��%�%�t�~�~�6��'��/�/�
���o�o�c�<��A��	M��&�&�v�{�{�3�'7�8�8��� � �'�"3�"3�4�	J�
#����8�8�s�?�0�F��8�8�D� �Z�Z�F�)�0�0��T�0�J���!�
#��C��H�$�%�C��c�(�C��	
#��
!�!B�S�!H�I�I���	M� �!K�L�L�	M�s6�C1�1#F%�?E�F
�$E<�9F
�;E<�<F
�
F%)rFN)r)r{r|r}r~rMr �VERSION_TEXTrrDrr�r�s@rCr�r��s.���,�-�4�4�W�5I�5I�J�J�?C�6�@%MrEr�c��eZdZdZdddeedddddefd�Zed��Z	ed��Z
ed��Zdd�Zdd	�Z
d
�Zd�Zdd�Zdd
�Zdd�Zdd�Zedfd�Zd�Zy)�Fabricz%Class managing MySQL Fabric instancesNFc
��|dk(rt|_n+|dk(rt|_ntdj	|���|s	t
|}i|_d|_d|_d|_	||_
||_t�|_
i|_||_||_t#||	|
�|_||_||_|r
|rt+d��|xs||_||_y)r�r$r%z0Protocol not supported by MySQL Fabric, was '{}'N�<z&can not specify both user and username)r��_protocol_classr5rrM�MYSQL_FABRIC_PORT�_fabric_instances�_fabric_uuid�_ttl�_version_token�_connect_attempts�_connect_delayr�_cache�_group_balancers�
_init_host�
_init_portr��_ssl�_report_errors�	_protocolr�r�r�)
r=r?rrr@rArB�
report_errorsr�r�r��user�protocols
             rCrDzFabric.__init__1s����x��#1�D� �
��
 �#3�D� � ��"�F�8�,�.�
.��$�X�.�D�!#��� �����	�"���!1���+���!�m��� "���������&�v�w��A��	�+���!����H��E�F�F��)����!��rEc��|jS)z0Return username used to authenticate with Fabric)r�r�s rCrzFabric.usernameW����~�~�rEc��|jS)z0Return password used to authenticate with Fabric)r�r�s rCrzFabric.password\r0rEc��|jS)zReturn the SSL configuration)r)r�s rCr�zFabric.ssl_configas���y�y�rEc���|xs|j}|xs|j}|j||||j|j��}|j|�\}}}}|st
d��|j|k(rytjdj|���||_||_|dkDr||_|D]�}|j||d|d|j|j��}	|	jj}
|
|jvs�X|	|j|
<tj!d	j|	jj"|	jj$�
����y)z�Get MySQL Fabric Instances

        This method uses host and port to connect to a MySQL Fabric server
        and get all the instances managing the same metadata.

        Raises InterfaceError on errors.
        )rArBz%Failed getting list of Fabric serversNz.Loading Fabric configuration version {version}rrr?r@z%Added new Fabric server {host}:{port}r�)r'r(rr#r$�get_fabric_serversrr"rr�rMr r!r:r�rrr?r@)r=r?r@�fabinstr��fabric_versionr��fabricsr>�inst�	inst_uuids           rC�seedzFabric.seedfs����&�t�����&�t�����&�&�t�T�4�8<�8N�8N�59�5H�5H�'�J��59�4K�4K��5�1��^�S�'�� �!H�I�I����.�0�����<�C�C�&�
D�
(�	)�(���,�����7��D�I��		I�F��'�'��f�V�n�f�V�n�9=�9O�9O�6:�6I�6I�(�K�D����)�)�I��� 6� 6�6�48��&�&�y�1��
�
�;�B�B�!�\�\�.�.�T�\�\�5F�5F�C�H�I�		IrEc���|r9tjdj|���|j|d��ytjd�t	�|_y)zWReset cached information

        This method destroys all cached information.
        z#Resetting cache for group '{group}'�r+F��	use_cachezResetting cacheN)rrrM�get_group_serversrr%�r=r+s  rC�reset_cachezFabric.reset_cache�sS��
��M�M�?�F�F��G��
��"�"�5�E�"�:��M�M�+�,�%�-�D�KrEc�R�d}d}|jst|dz��tr-|jj�}|j||}n%|jt	|j�|}|j
js|j
j�|S)z�Get a MySQL Fabric Instance

        This method will get the next available MySQL Fabric Instance.

        Raises InterfaceError when no instance is available or connected.
        rz"No MySQL Fabric instance availablez (not seeded?))rrr!r�rGr:�is_connectedr;)r=�nxt�errmsg�
instance_listr8s     rC�get_instancezFabric.get_instance�s�����5���%�%� ��*:�!:�;�;�� �2�2�7�7�9�M��)�)�-��*<�=�D��)�)�$�t�/E�/E�*F�s�*K�L�D��|�|�(�(��L�L� � �"��rEc��|jsyt|�}tj�}|tvs|t
vrItjd||�|j�}	|jdd|||�}t|�yy#ttjf$r)}tjdt|��Yd}~yd}~wwxYw)z{Report failure to Fabric

        This method sets the status of a MySQL server identified by
        server_uuid.
        NzReporting error %d of server %s�threat�report_failurez&Failed reporting server to Fabric (%s))r*r�ru�getfqdn�
REPORT_ERRORSr�rrrGrcr�rrsrN)r=�server_uuid�errno�current_hostr8rxrys       rCrJzFabric.report_failure�s����"�"���E�
���~�~�'���M�!�U�.A�%A��M�M�;�U�%�
'��$�$�&�D�
(��|�|�H�.>�$/��u�F���t�$�&B���6�<�<�(�
(��
�
�F�!�#�h�(�(��
(�s�% B�C	� C�C	c�N�|xs|j�}g}d}	|jddd|jz�}|j�D]*}|j	|j
|jd���,		t!j"|j$�}	d	}
|	|
|j(|fS#ttjf$rU}|jt|�|jj
|jj��}t|��d}~wttf$r[}|jdj|�|jj
|jj��}t|��d}~wwxYw#t$rt!j&�}	Y��wxYw)
a�Get all MySQL Fabric instances

        This method looks up the other MySQL Fabric instances which uses
        the same metadata. The returned list contains dictionaries with
        connection information such ass host and port. For example:

        [
            {'host': 'fabric_prod_1.example.com', 'port': 32274 },
            {'host': 'fabric_prod_2.example.com', 'port': 32274 },
        ]

        Returns a list of dictionaries
        z;Looking up Fabric servers failed using {host}:{port}: {err}�dump�fabric_nodesz	protocol.r�)rWr?r@Nz No Fabric server available ({0})r)rGrcr+r�rLr?r@rrursrMrNr:r�	TypeErrorr�r��UUIDr��uuid4r�)r=�
fabric_cnxr8�result�err_msg�fsetr�ryrzr�r6s           rCr4zFabric.get_fabric_servers�sr���0�T�.�.�0����O��	&��<�<��� +�d�n�n� <�>�D��y�y�{�
D���
�
�s�x�x����B�C�
D�	'��)�)�D�$8�$8�9�K����N�D�H�H�f�<�<��#�v�|�|�$�	&��.�.�S��X�D�L�L�4E�4E�&*�l�l�&7�&7�!�9�C� ��%�%���>�*�	&��.�.�6�=�=�c�B��\�\�&�&�T�\�\�->�->�!�@�C�!��%�%��		&���	'��*�*�,�K�	'�s8�AB*�9F�*F�AD�F�%AE;�;F�F$�#F$c
�H�|r)|jj|�}|r|jS|j�}g}	|j	dd|j
|�}g}	|j�D]�}
|
j|k(s�t|
j|
j|
j |
j"|
j$|
j&|
j(�}|j+|�|j&t,k(s��|	j+|j.|j(f���|jj1||�|	rt3|	�|j4|<|S#ttjf$r,}djt|�|��}t|��d}~wwxYw)a?Get all MySQL servers in a group

        This method returns information about all MySQL part of the
        given high-availability group. When use_cache is set to
        True, the cached information will be used.

        Raises InterfaceError on errors.

        Returns list of FabricMySQLServer objects.
        rQ�serversz:Looking up MySQL servers failed for group {group}: {error})rsr+N)r%�group_searchr[rGrcr"rrursrMrNrr��group_idrrMr?r@r.�status�weightrL�STATUS_SECONDARYr��cache_grouprr&)r=r+r>�entryr8rWrYryrz�weightsr��mysqlservers            rCr?zFabric.get_group_servers�si����K�K�,�,�U�3�E���}�}�$�� � �"����	&��<�<��	�4�3F�3F��N�D����9�9�;�		K�C��|�|�u�$�/��O�O�S�\�\�3�8�8�S�X�X��H�H�c�j�j�#�*�*����
�
�k�*��%�%�)9�9��N�N�K�$4�$4�k�6H�6H�#I�J�		K�	
������v�.��+=�w�+G�D�!�!�%�(��
��+�v�|�|�$�	&�&�'-�v�C��H�E�v�'J�
� ��%�%��	&�s�E�F!�5'F�F!c��|r
|rtd��d}|j|d��}|st|j|����d}g}|D]=}|jt
k(r|j
|��(|jtk(s�<|}�?|ttfvs	|tk(r>|s:|j|��t|dzj|rdnd	||xs|�
���|S|s|r|S||jvr:|j|j�d}	|D]}
|	|
jk(s�|
cS|j|��t|j||����)
a�Get a MySQL server from a group

        The method uses MySQL Fabric to get the correct MySQL server
        for the specified group. You can specify mode or status, but
        not both.

        The mode argument will decide whether the primary or a secondary
        server is returned. When no secondary server is available, the
        primary is returned.

        Status is used to force getting either a primary or a secondary.

        The returned tuple contains host, port and uuid.

        Raises InterfaceError on errors; ValueError when both mode
        and status are given.

        Returns a FabricMySQLServer object.
        z-Either mode or status must be given, not bothz-No MySQL server available for group '{group}'Tr=r<Nz {query}={value}r^r.)�queryr+rUr)r+r.)r�r?rrMr^r`rL�STATUS_PRIMARY�MODE_WRITEONLY�MODE_READWRITErAr&�get_nextr�)r=r+r.r^rEr[�primary�	secondary�server�next_secondaryrds           rC�get_group_serverzFabric.get_group_server$s���(�F��?�A�
A�A���(�(��$�(�?��� ����U��!;�<�<����	��	!�F��}�}� 0�0�� � ��(����.�0� ��		!��N�N�3�3�v��7O��� � �u� �-�$�f�/A�&A�%I�%I�&,�(�&�� �.�D�&J�&*�+�+��N��W��N�
�d�+�+�
+�!�2�2�5�9�B�B�D�Q�G�N�(�
'��!�[�%5�%5�5�&�&�
'�	
���u��%��V�]�]��T�]�B�C�CrEc
�r�t|ttf�std��g}|D]z}t|ttf�s|stdj	|���t|ttf�r|d}|d}n|}|}|jdj	||���||j
�}	|jdd|jdj|��}|j�D]}}|j j#t%|j&|j(|j*|j,|j.|j0|j2|j4���y#ttjf$r+}	d	j	t|	��
�}
t|
��d}	~	wwxYw)a�Get and cache the sharding information for given tables

        This method is fetching sharding information from MySQL Fabric
        and caches the result. The tables argument must be sequence
        of sequences contain the name of the database and table. If no
        database is given, the value for the database argument will
        be used.

        Examples:
          tables = [('salary',), ('employees',)]
          get_sharding_information(tables, database='employees')

          tables = [('salary', 'employees'), ('employees', employees)]
          get_sharding_information(tables)

        Raises InterfaceError on errors; ValueError when something is wrong
        with the tables argument.
        �tables should be a sequencez#No database specified for table {0}rrz{0}.{1}rQ�sharding_information�,z0Looking up sharding information failed : {error}�rsN)r�rGrZr�rMrLrGrcr"rkrrursrNrr�r%�sharding_cache_tabler�schema_name�
table_name�column_name�lower_bound�shard_id�	type_namer]�global_group)r=r-�database�patterns�table�dbase�tblr8rYryrzr�s            rC�get_sharding_informationzFabric.get_sharding_information`s���&�&�4��-�0��:�;�;����	:�E��e�d�E�]�3�H� �!F�!M�!M��"����%�$���/��a����A�h�� �����O�O�I�,�,�U�C�8�9�	:�� � �"��		&��<�<��.��0C�0C�����"��D��9�9�;�	�C��K�K�,�,��C�O�O�S�^�^�S�_�_��O�O�S�\�\�3�=�=��L�L�#�*:�*:�<�
�	���v�|�|�$�	&�D�K�K��#�h�L� �C� ��%�%��	&�s�4-E2�2F6�&F1�1F6c���t|ttf�std��g�|D�]�}	|j	d�\}}|jj||�}|s]|j|f|�|jj||�}|s,ttjdj||�����|dk(r|j|j|��cS|jd	k(r;	t|�}	|j }
|
t#|
|	�dz
}|j$|}�nZ|jdk(rbt|t&j(t&j&f�std
��d}|j*D]}
||
k\s�	|
}n	|j$|}n�|jdk(rCt/|�std��d}|j*D]}
||
k\s�	|
}n	|j$|}n�|jdk(rdt1t3|��}|j*d}|j*D]"}
|j5�t7|
�k\s� |
}n|j$|}n$t9dj|j����j;|d�t=�fd��D��r���td��|j�d|��S#t$rtdj|���wxYw#t$rtd
��wxYw#t,$rtdj|���wxYw#t,$rtdj|���wxYw)a"Get MySQL server information for a particular shard

        Raises DatabaseError when the table is unknown or when tables are not
        on the same shard. ValueError is raised when there is a problem
        with the methods arguments. InterfaceError is raised for other errors.
        rq�.z5tables should be given as <database>.<table>, was {0}z"Unknown table '{database}.{table}')r}r)rNrzr'�r.�RANGEz Key must be an integer for RANGEr�RANGE_DATETIMEzAKey must be datetime.date or datetime.datetime for RANGE_DATETIMENzKey invalid; was '{0}'�RANGE_STRINGzKey must be a unicode value�HASHrzUnsupported sharding type {0}r+c3�.�K�|]}|�dk(���y�w)rNr^)r�r+�groupss  �rCr�z*Fabric.get_shard_server.<locals>.<genexpr>�s�����>�e�u��q�	�)�>�s�z'Tables are located in different shards.r)r�rGrZr��splitrMr%�sharding_searchr�rr�ER_BAD_TABLE_ERRORror|�
shard_typer�r�r�partitioning�datetime�date�
keys_reversed�KeyErrorr"rrN�digestrrrLr�)r=r-r,r1r.�dbobjr}rrb�	range_key�
partitionsr��	partition�partkey�md5keyr�s               @rC�get_shard_serverzFabric.get_shard_server�s�����&�4��-�0��:�;�;����F	?�E�
-�"'�+�+�c�"2���%��K�K�/�/��%�@�E���-�-�u�h��A����3�3�H�e�D���'�'�:�:�@�G�G�%-�U�H�<�=�=�
�� ��,�,�U�-?�-?�d�,�K�K����7�*�I� #�C��I�#�Z�Z�
�"�6�*�i�#@�1�#D�E��!�.�.�u�5�	��!�!�%5�5�!�#��
�
�x�7H�7H�'I�J�$�)�*�*���$�2�2��G��g�~� '����K� %� 2� 2�5� 9�I��!�!�^�3� ��~�$�%B�C�C���$�2�2��G��g�~� '����K� %� 2� 2�5� 9�I��!�!�V�+��S��X����+�+�B�/��$�2�2��G��}�}��)�G�*<�<� '����"�.�.�u�5�	�$�3�:�:�5�;K�;K�L�N�N�
�M�M�)�G�,�-��>�v�>�>�#�=�?�?�KF	?�P�$�$�V�A�Y�T�$�:�:��K�
-� ��$�f�U�m�-�-�
-��*"�I�$�%G�H�H�I��" �K�$�%=�%D�%D�S�%I�J�J�K�� �K�$�%=�%D�%D�S�%I�J�J�K�s/�K�/K6�
L�L5�$K3�6L�$L2�5$Mc�P�|j�}|j||g|��i|��S)aiExecute a Fabric command from given group

        This method will execute the given Fabric command from the given group
        using the given arguments. It returns an instance of FabricSet.

        Raises ValueError when group.command is not valid and raises
        InterfaceError when an error occurs while executing.

        Returns FabricSet.
        )rGrc)r=r+rrrlrmr8s      rCrczFabric.execute�s/��� � �"���t�|�|�E�7�<�T�<�V�<�<rE)NNr7)T)r{r|r}r~�_CNX_ATTEMPT_MAX�_CNX_ATTEMPT_DELAY�DEFAULT_FABRIC_PROTOCOLrD�propertyrrr�r:rArGrJr4r?ror��SCOPE_LOCALr�rcr^rErCrr-s���/�&*�T��"2�1�$��d�T��1�
$"�L������������+I�Z(��((�2(=�T+�Z:D�x5�n3>�D�T;�l=rErc�p�eZdZdZeeeefd�Ze	d��Z
e	d��Ze	d��Zd�Z
e	d��Zd�Zy	)
�FabricConnectionzIBase Class for a class holding a connection to a MySQL Fabric server
    c��t|t�std��||_||_||_||_||_y)r�z'fabric must be instance of class FabricN)r�rr��_fabric�_host�_portr#r$r<s      rCrDzFabricConnection.__init__�s?��
�&�&�)��F�G�G������
���
�!1���+��rEc��|jS)z6Returns server IP or name of current Fabric connection)r�r�s rCr?zFabricConnection.host����z�z�rEc��|jS)z0Returns TCP/IP port of current Fabric connection)r�r�s rCr@zFabricConnection.portr�rEc�B�t|j|j�S)z7Returns UUID of the Fabric server we are connected with)r�r�r�r�s rCr�zFabricConnection.uuids��#�4�:�:�t�z�z�:�:rEc��y�zConnect with MySQL FabricNr^r�s rCr;zFabricConnection.connects��rEc��y)��Check whether connection with Fabric is valid

        Return True if we can still interact with the Fabric server; False
        if Not.

        Returns True or False.
        Nr^r�s rCrCzFabricConnection.is_connecteds��	
rEc�f�dj|j|j|j��S)Nz"{class_}(host={host}, port={port}))�class_r?r@)rMr�r�r�r�s rC�__repr__zFabricConnection.__repr__*s/��3�:�:��>�>�������;�
�	
rEN)r{r|r}r~rr�r�r�rDr�r?r@r�r;rCr�r^rErCr�r��sw���(�(?�@�"2�1�,����������;��;�
��
��
�
rEr�c�l��eZdZdZedeef�fd�	Zed��Z	ed��Z
d�Zd�Zed��Z
�xZS)	r�zCClass holding a connection to a MySQL Fabric server through XML-RPCr$c�B��tt|�|||||�d|_yr�)r�r�rD�_proxy�r=r>r?r@rArBr�s      �rCrDzFabricXMLRPCConnection.__init__6s*���	�$�d�4��D�$� 0�-�	
���rEc��|jS)z5Returns the XMLRPC Proxy of current Fabric connection)r�r�s rCr�zFabricXMLRPCConnection.proxy?s���{�{�rEc�B�t|j|j�S)z4Returns the XMLRPC URI for current Fabric connection)r�r�r�r�s rCrzFabricXMLRPCConnection.uriDs��"�$�*�*�d�j�j�9�9rEc� �|jr|jS|j}|j}d}d}||k7r�|dz
}	|jj
r1tstd��t|jj
�}nd}t|jj|jjd|��}t|j|d��}|j�|dkDrt/j0|�||k7r��yy#t$r|cYSt j"$rd}||k(rtdj%|���t&j)dj%|j*|j,|�	��Yd}~��d}~wwxYw)
z�Return the XMLRPC server proxy instance to MySQL Fabric

        This method tries to get a valid connection to a MySQL Fabric
        server.

        Returns a XMLRPC ServerProxy instance.
        Nrrr�)r�r)�	transportr��'Connection to MySQL Fabric failed ({0})�*Retrying {host}:{port}, attempts {counter}�r?r@�counter)rCr�r#r$r�r�r�rr�r�rrrr�_some_nonexisting_methodrrursrMrrr?r@�time�sleep)r=r2�delayr�r�rr�rys        rC�_xmlrpc_get_proxyz(FabricXMLRPCConnection._xmlrpc_get_proxyIsm������;�;���)�)���#�#��������!��q�L�G�
J��<�<�*�*�#�,�-J�K�K�$6�t�|�|�7N�7N�$O�M�$(�M�+�D�L�L�,A�,A�,0�L�L�,A�,A�45�:G�I�	�$�D�H�H�	�1�M���.�.�0��q�y��
�
�5�!�7��!�� �
����<�<�
J��h�&�(�A�H�H��M�O�O��
�
�@�G�G�!�Y�Y�T�Y�Y��H�I�J�J��	
J�s �B(D
�
F
�F
�)AF�F
c�.�|j�|_yr�)r�r�r�s rCr;zFabricXMLRPCConnection.connectvs���,�,�.��rEc�x�	|jj�y#t$rYyttf$rYywxYw)r�FT)r�r�rrSr�r�s rCrCz#FabricXMLRPCConnection.is_connectedzs@��	��K�K�0�0�2����	���>�*�	��	�s��	9�9�9)r{r|r}r~rr�r�rDr�r�rr�r;rCr�r�s@rCr�r�2s`���M�*;�H�*E�"2�1�������:��:�+"�Z/����rEr�c�\��eZdZdZedeef�fd�	Zed��Z	d�Z
d�Zed��Z�xZ
S)r9zT
    Class holding a connection to a MySQL Fabric server through MySQL protocol
    r%c�D��tt|�|||||��d|_y)r�)r@rArBN)r�r9rD�_connectionr�s      �rCrDzFabricMySQLConnection.__init__�s0���	�#�T�3��D�t�-�]�	4�	
� ��rEc��|jS)z*Returns the MySQL RPC Connection to Fabric)r�r�s rCraz FabricMySQLConnection.connection�s�����rEc��|jr|jS|j}|j}d}||k7r�|dz
}	|j|j
|jj|jjd�}|jjrItstd��|jjd|d<|jjd|d<td
i|��Syy#t$rd}||k(rtd	j|���tj!d
j|j"|j$|���Yd}~nd}~wwxYw|dkDrt'j(|�||k7r��F��)z�Return the connection instance to MySQL Fabric through MySQL RPC

        This method tries to get a valid connection to a MySQL Fabric
        server.

        Returns a MySQLConnection instance.
        rr)r?r@r-rr�r,r�r�r�r�r�r�Nr^)rCr�r#r$r�r�r�rrr�r�rrr�rMrrr?r@r�r�)r=r2r�r��dbconfigrys      rC�_get_connectionz%FabricMySQLConnection._get_connection�sn������#�#�#��)�)���#�#������!��q�L�G�
J� �J�J� �J�J� �L�L�1�1� $��� 5� 5�	���<�<�*�*�#�,�-J�K�K�*.�,�,�*A�*A�%�*H�H�Y�'�+/�<�<�+B�+B�6�+J�H�Z�(�&�2��2�2��"��""�
J��h�&�(�A�H�H��M�O�O��
�
�@�G�G�!�Y�Y�T�Y�Y��H�I�J�J��	
J���q�y��
�
�5�!�3��!�s�B,C-�-	E�6AE�Ec�.�|j�|_yr�)r�r�r�s rCr;zFabricMySQLConnection.connect�s���/�/�1��rEc�V�	|jj�S#t$rYywxYw)r�F)r�rCr�r�s rCrCz"FabricMySQLConnection.is_connected�s.��	��#�#�0�0�2�2���	��	�s��	(�()r{r|r}r~rr�r�rDr�rar�r;rCr�r�s@rCr9r9�sP����+<�G�*D�"2�1� �� �� �)"�V2����rEr9c��eZdZdZd�Zd�Zed��Zed��Zdd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�ZeZdd�Zd�Zd�Zd�Zd�Zd�Zy)�MySQLFabricConnectionz1Connection to a MySQL server through MySQL Fabricc��d|_d|_d|_d|_i|_|j�d|vrt
d��|r|jdi|��yy)r�Nr>z+Configuration parameters for Fabric missingr^)�
_mysql_cnxr��_fabric_mysql_server�
_mysql_config�_cnx_properties�reset_propertiesr��store_config)r=rms  rCrDzMySQLFabricConnection.__init__�se��������$(��!�!���!��������6�!��J�K�K���D���'��'�rEc��|jd�rtdj|����t|j|�S)z7Return the return value of the MySQLConnection instance�cmd_zHCalling {attr} is not supported for connections managed by MySQL Fabric.)�attr)�
startswithrrMr�r�)r=r�s  rC�__getattr__z!MySQLFabricConnection.__getattr__�s?���?�?�6�"�#� � &��D�� 1�3�
3��t����-�-rEc�H�|jr|jjSy)z+Returns the Fabric UUID of the MySQL serverN)r�r�r�s rCr�z!MySQLFabricConnection.fabric_uuid�s"���$�$��,�,�1�1�1�rEc��|jS)zReturns connection properties)r�r�s rC�
propertiesz MySQLFabricConnection.propertiess���#�#�#rENc��|s"|jr|jj}|jj|��y)z'Reset cache for this connection's groupr<N)r�r+r�rAr@s  rCrAz!MySQLFabricConnection.reset_caches3����2�2��-�-�3�3�E���� � �u� �-rEc��|jduS)z\Check whether we are connected with the MySQL server

        Returns True or False
        N)r�r�s rCrCz"MySQLFabricConnection.is_connecteds��
���d�*�*rEc�n�i|_tj�D]\}}|d|j|<�y)z�Resets the connection properties

        This method can be called to reset the connection properties to
        their default values.
        r
N)r��_CNX_PROPERTIESrH)r=r,r�s   rCr�z&MySQLFabricConnection.reset_propertiess<�� "���(�.�.�0�	0�I�C��(,�Q��D� � ��%�	0rEc��	|j�|j}|j�D�]\}}|tvrtdj
|���|ret|t|d�sOdjt|dD�cgc]}|j��c}�}tdj
||����|dk(r|r|ds|drtd	��|d
vr|r|drtd��|dk(r|ttfvrtd
��|dk(r|ttfvrtd��|�t|d||<��|||<��y#t$rY��BwxYwcc}w)atSet one or more connection properties

        Arguments to the set_property() method will be used as properties.
        They are validated against the _CNX_PROPERTIES constant.

        Raise ValueError in case an invalid property is being set. TypeError
        is raised when the type of the value is not correct.

        To unset a property, set it to None.
        zInvalid property connection {0}rz or z({name} is not valid, excepted {typename})�name�typenamer+r,r-z>'group' property can not be set when 'key' or 'tables' are set)r,r-z@'key' and 'tables' property can not be set together with 'group'r1zInvalid value for 'scope'r.zInvalid value for 'mode'Nr
)�closerr�rHr�r�rMr�rkr{rSr��SCOPE_GLOBALri�
MODE_READONLY)r=r��propsr�rU�atype�valid_types_strs       rC�set_propertyz"MySQLFabricConnection.set_propertys���	��J�J�L�
�$�$��%�+�+�-�	$�K�D�%��?�*� �5�<�<�T�B�D�D��z�%���1F�q�1I�J�"(�+�+�1@��1F�q�1I�J��U�^�^�J�#L���>�E�E�!�O�F�=�>�>����E��5�\�U�8�_� �'�(�(��*�*�u��w�� �0�1�1����U�;��2M�%M� �!<�=�=����E�"�M�23�%3� �!;�<�<��}�-�d�3�A�6��d��#��d��=	$��
�	��	��Ks�E�E
�	E�Ec�6�t|t�r||_ydg}|D]!}||vs�tdj	|����|d}|jdt�}	|jdt|�}t||�}	t||_y#t$rtdj	|���wxYw#t$rUtjd�td	i|��|_|jj�|jt|<YywxYw)
z�Configure the Fabric connection

        The config argument can be either a dictionary containing the
        necessary information to setup the connection. Or config can
        be an instance of Fabric.
        r?z8Missing configuration parameter '{parameter}' for fabric)�	parameterr.r@z{0} protocol is not availablezNew Fabric connectionNr^)r�rr�r�rM�getr�rr�rr��FABRICSrrr:)r=�config�
required_keys�required_keyr?r.r@rMs        rC�_configure_fabricz'MySQLFabricConnection._configure_fabricPs&���f�f�%�!�D�L�#�H�M� -�
E���v�-�$�%�%+�V�l�V�%C�E�E�
E�
�&�>�D��z�z�*�.E�F�H�
F��z�z�&�*;�H�*E�F��.�d�D�9�K�
4�&�{�3�����
F�$�3�:�:�8�D�F�F�
F���
4��
�
�5�6�%�/��/������!�!�#�'+�|�|���$�
4�s�B�B:�$B7�:AD�Dc��|j�}d|vr|j|d�|d=d|vrtjd�d|d<|j�}d|vr|d=d|vr|d=d|vr|d=	t	tt
j����}|jd
i|��||_y#t$r}td	j|���d}~wwxYw)a�Store configuration of MySQL connections to use with Fabric

        The configuration found in the dictionary kwargs is used
        when instanciating a MySQLConnection object. The host and port
        entries are used to connect to MySQL Fabric.

        Raises ValueError when the Fabric configuration parameter
        is not correct or missing; AttributeError is raised when
        when a paramater is not valid.
        r>�unix_socketz'MySQL Fabric does not use UNIX sockets.N�	pool_name�	pool_size�pool_reset_session)r�z'Connection configuration not valid: {0}r^)�copyr�r�warningrrNr�rU�
set_configr�rMr�)r=rmr��test_config�poolrWs      rCr�z"MySQLFabricConnection.store_configqs���������v���"�"�6�(�#3�4��x� ��F�"��O�O�E�F�$(�F�=�!��k�k�m���+�%��K�(��+�%��K�(��;�.��0�1�	G�&��T�Z�Z�\�1B�C�D��D�O�O�*�k�*�
$����	�	G� �9�@�@��E�G�
G��	G�s�09B1�1	C�:C�Cc��|j�ry|j}|d}|d}|jj�}d}||k7r�|dz
}	d}|drD|ddk(r|d	st	d
��|j
j
|d|d	|d|d��}n6|d
r&|d
}|j
j||d��}nt	d��|j|d<|j|d<	t!j"j$di|��|_||_yy#t$r�}tjdj||��||k(rtdj|���|dkDr9tjdj|��tj|�Yd}~��id}~wwxYw#t*$r�}||k(re|j-|j.�|j
j1|j2|j4�tdj|���|dkDrtj|�Yd}~��d}~wwxYw)a�Get a MySQL server based on properties and connect

        This method gets a MySQL server from MySQL Fabric using already
        properties set using the set_property() method. You can specify how
        many times and the delay between trying using attempts and
        attempt_delay.

        Raises ValueError when there are problems with arguments or
        properties; InterfaceError on connectivity errors.
        Nr2r3rrr-r1r(r,z*Scope 'LOCAL' needs key property to be setr.)r1r.r+r�z*Missing group or key and tables propertiesz-Trying to get MySQL server (attempt {0}; {1})zError getting connection: {0}zWaiting {0}r?r@z&Reported faulty server to Fabric ({0})r^)rCr�r�r�r�r�r�rorrrrMr�r�r?r@r%rPr;r�r�rrAr+rJr�rN)	r=r�r2r3r�r�r+rdrys	         rC�_connectzMySQLFabricConnection._connect�sh��������$�$����$���o�.�
��%�%�*�*�,������!��q�L�G�
�����?��W�~��0��u��(�H�J�J�"&�,�,�"?�"?��h���u��#�G�n�"�6�]�#@�#,�K��7�^�!�'�N�E�"&�,�,�"?�"?��E�&�M�#@�#3�K�%�D�F�F� +�/�/�H�V��*�/�/�H�V��

�"'�/�/�"9�"9�"E�H�"E���-8��)��_"��&"�

��
�
�C�J�J���&�'��h�&�(�)H�)O�)O��*��� �1�$��M�M�-�"6�"6�}�"E�F��J�J�}�-���

��"�
��h�&��$�$�[�%6�%6�7��L�L�/�/��0@�0@�#�)�)�L�(�@�G�G��L�N�N� �1�$��J�J�}�-���
�s3�BD�/$F5�	F2�%BF-�-F2�5	I
�>BI�I
c���	|j�|jj�d|_d|_y#t$rY�t$r�wxYw#d|_d|_wxYw)z Close connection to MySQL serverN)�rollbackr�r�r�rr�r�s rC�
disconnectz MySQLFabricConnection.disconnect�sb��		-��M�M�O��O�O�!�!�#�#�D�O�(,�D�%��
�	���	��	��#�D�O�(,�D�%�s!�*;�	A�A�
A�A�A#c�2�|j�|rtd��|rtd��|jdurtd��|xs|j}|xs|j
}d}|dur|dz}|dur|dz}ttttf}|||�S)aiInstantiates and returns a cursor

        This method is similar to MySQLConnection.cursor() except that
        it checks whether the connection is available and raises
        an InterfaceError when not.

        cursor_class argument is not supported and will raise a
        NotSupportedError exception.

        Returns a MySQLCursor or subclass.
        z.Custom cursors not supported with MySQL Fabricz7Prepared Statements are not supported with MySQL FabricTzUnread result found.rrr
)
rr�_unread_resultr�	_buffered�_rawrrrr)r=�buffered�raw�prepared�cursor_class�cursor_type�typess       rCrbzMySQLFabricConnection.cursor�s���	
�
�
���#�@�B�
B��#�I�K�
K����$�&�� 6�7�7��-�t�~�~����T�Y�Y�����t���1��K��$�;��1��K�
���"�	
��#��k�"�D�)�)rEc��|jtvrD|j�|j�t	djt
|�����|�)z�Handles MySQL errors

        This method takes a mysql.connector.errors.Error exception
        and checks the error code. Based on the value, it takes
        certain actions such as clearing the cache.
        z,Temporary error ({error}); retry transactionrt)rN�RESET_CACHE_ON_ERRORrArrrMrN�r=rys  rC�handle_mysql_errorz(MySQLFabricConnection.handle_mysql_errorsP���9�9�,�,������O�O��"�$�$*�F��S��F�$:�<�
<��	rEc��	|jj�y#t$r}|j|�Yd}~yd}~wwxYw)z�Commit current transaction

        Raises whatever MySQLConnection.commit() raises, but
        raises MySQLFabricError when MySQL returns error
        ER_OPTION_PREVENTS_STATEMENT.
        N)r��commitrrrs  rCrzMySQLFabricConnection.commit#s8��	)��O�O�"�"�$���	)��#�#�C�(�(��	)����	A�<�Ac��	|jj�y#t$r}|j|�Yd}~yd}~wwxYw)z�Rollback current transaction

        Raises whatever MySQLConnection.rollback() raises, but
        raises MySQLFabricError when MySQL returns error
        ER_OPTION_PREVENTS_STATEMENT.
        N)r�rrrrs  rCrzMySQLFabricConnection.rollback/s8��	)��O�O�$�$�&���	)��#�#�C�(�(��	)�rc��|j�	|jj|�S#t$r}|j	|�Yd}~yd}~wwxYw)z�Send a statement to the MySQL server

        Raises whatever MySQLConnection.cmd_query() raises, but
        raises MySQLFabricError when MySQL returns error
        ER_OPTION_PREVENTS_STATEMENT.

        Returns a dictionary.
        N)rr��	cmd_queryrr)r=�	statementrys   rCrzMySQLFabricConnection.cmd_query;sH��	
�
�
��	)��?�?�,�,�Y�7�7���	)��#�#�C�(�(��	)���-�	A�A�Ac��|j�	|jj|�S#t$r}|j	|�Yd}~yd}~wwxYw)z�Send one or more statements to the MySQL server

        Raises whatever MySQLConnection.cmd_query_iter() raises, but
        raises MySQLFabricError when MySQL returns error
        ER_OPTION_PREVENTS_STATEMENT.

        Returns a dictionary.
        N)rr��cmd_query_iterrr)r=�
statementsrys   rCrz$MySQLFabricConnection.cmd_query_iterJsH��	
�
�
��	)��?�?�1�1�*�=�=���	)��#�#�C�(�(��	)�rr7)NNNN)r{r|r}r~rDr�r�r�r�rArCr�r�r�r�rrr�rbrrrrrr^rErCr�r��s���;�(� .������$��$�.�+�0�1$�f4�B%$�NB�H-�
�E�'*�R� 
)�
)�
)�
)rEr�)rr~�sysr�r�r��base64rr�hashlibr�loggingrur��	xmlrpclibrrrr��httplibr	�ImportError�
xmlrpc.client�urllib.requestr�http.client�version_inforr��mysql.connectorr%rar�
conversionr
�poolingrrQrrrrrrrbrrrrr*rrr�cachingr�	balancingrr �catch23r!r"r#�CR_SERVER_LOST�ER_OPTION_PREVENTS_STATEMENTr�CR_SERVER_GONE_ERROR�CR_CONN_HOST_ERROR�CR_CONNECTION_ERROR�CR_IPSOCK_ERRORrLr�r�rr�r�r��_GETCNX_ATTEMPT_DELAY�_GETCNX_ATTEMPT_MAXr�rhri�
STATUS_FAULTY�STATUS_SPAREr`rgr�r��_SERVER_STATUS_FAULTYrNrZr�r�rGr��	getLoggerr�objectr5r�r�rtr�r�r�r�r�r�r�r�r�rr�r�r9r�r^rErC�<module>r=sT��03�
��������
��*�7�7��%����A��!���+����/����(�'�)������,� �)��3�3����
�*�*������
�"�"�
� � �
�!�!�
����
���"���
���

�����������
������
����������� ���f�0�$�
7��3��X�.�.��=�=�"�$(��$7�8�
9��D�"��t�}�7��>��V�:�N�K��f�C�T�
J����D�!��f�C�����:�$�&��f�D�+�-���$�'�
�
�-�
.��Y�v�Y�x �V� �F"�&�"�3�(�3�B�V��2 2�� 2�F)�4?�J�
�4��W�1�1��2KM�i�KM�\L=�V�L=�^3
�v�3
�lX�-�X�vN�,�N�by)�F�y)��i%�*�;�;�$�)�)�	*�������������s5�I�I2�#J�I/�.I/�2I=�<I=�J�
J

Youez - 2016 - github.com/yon3zu
LinuXploit