OwlCyberSecurity - MANAGER
Edit File: connection.cpython-312.pyc
� U��g� � � � d Z ddlZddlZddlZddlZddlmZ ddlmZ ddlm Z ddl Z ddlZddlZ ddl mZmZmZ ddlZddlmZ ej2 d dk( r dd lmZ d Zn dd lmZ d ZddlZddlmZ dd 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/ ddl0m1Z1 ddl0m2Z2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl0m8Z8 ddl9m:Z:m;Z;m<Z< e1jz e1j| fZ?e1jz e1j� e1j� e1j� e1j� fZDg aEdZFddd�ZGi ZHdZIdZJdZKdZLdZMdZNdZOdZPdZQdZRdZSdZTdZUdZVeWfd df eXeYeWej ej� g e[e<� z � d!dfeXe[fd"dfeYfd#eOfeWfd$dfeWfd%dfeWfd&eUfeYfd'eLfeYfd(eKfd)� Z\ e j� d*� Z^ G d+� d,e_� Z` G d-� d.e_� Za G d/� d0e_� Zb G d1� d2eb� Zc G d3� d4e_� Zd G d5� d6ed� Zed7� Zfd8� Zgd9� Zhd:� Zier G d;� d<ej� � Zk G d=� d>e� Zl G d?� d@e_� Zm G dA� dBe_� Zn G dC� dDen� Zo G dE� dFen� Zp G dG� dHe_� Zqy# e$ r ddlmZmZmZ ddlmZ ddlmZ Y ��(w xY w# e$ r dZY ��w xY w# e$ r dZY ��w xY w)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 serverszSharding 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 � e Zd ZdZd� Zd� Zd� Zd d�Zd� Zd� Z y) �MySQLRPCProtocolz0Class using MySQL protocol to query Fabric. c �~ � t � | _ t |||||� | _ | j j � y �N)r � converter�FabricMySQLConnection�handler�connect��self�fabric�host�port�connect_attempts� connect_delays �x/opt/hc_python/lib64/python3.12/site-packages/../../../lib/python3.12/site-packages/mysql/connector/fabric/connection.py�__init__zMySQLRPCProtocol.__init__� s6 � �'�)���,�V�T�4�-=�-:�<��� ������ c �� � g }t |j � � D ]� \ }}|}| j j |� }| j j |� }| j j |� }|j dj |t |� � � �� |S # t $ r1}t j j j d|z � �d}~ww xY w)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��;�<� 3� �J�� � C��/�/�(�(�9�9�;�c�A�C� C�� C�s �B B% �% C�.,C�Cc �� � |}|D �cg c] }| j j |� �� }}|D �cg c] }| j j |� �� }}|D �cg c] }| j j |� �� }}|D �cg c] }t |� �� }}t |� S c c}w c c}w c c}w c c}w # t $ r1}t j j j d|z � �d}~ww xY w)zProcess query parameters.z'Failed processing format-parameters; %sN)r8 rI rJ rK rN �tuplerO r% rP rQ rR )r= rS rT �irW s rC �_process_paramsz MySQLRPCProtocol._process_params� s� � � ��C�7:�;�s�!�4�>�>�*�*�1�-�s�C�;�58�9�S��4�>�>�(�(��+�S�C�9�47�8�C�q�4�>�>�'�'��*�C�C�8�#&�'�3�a�3�q�6�3�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}| j j j d�� }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�resultsrT s rC �_execute_cmdzMySQLRPCProtocol._execute_cmd� s` � � ��F��l�l�%�%�,�,��,�=�����;�;�t�V�4�;�8�C��N�N�3�<�<�>�*� 9� �rE c � � g }|r"| j |� }|j |� |r"| j |� }|j |� dj |� }|S )z6Process arguments to create query parameters. z, )r\ �extendrX �join)r= �args�kwargsrS s rC � create_paramszMySQLRPCProtocol.create_params� sZ � � ����'�'��-�D��M�M�$����.�.�v�6�F��M�M�&�!����6�"��� rE c �* � | j |i |��}dj |||� }d} | j |� }t |� }|S # t t j t f$ r-} dj ||t | � �� } t | � �d} ~ ww xY w)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) rn rM rh �FabricMySQLSetr �socketrs r rN )r= r+ rr rl rm rS �cmd�fab_set�data�exc�msgs rC rc zMySQLRPCProtocol.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__rD rX r\ rh rn rc r^ rE rC r5 r5 � s% � ���� � ��rE r5 c � � e Zd ZdZd� Zd� Zy)�XMLRPCProtocolz2Class using XML-RPC protocol to query Fabric. c �` � t |||||� | _ | j j � y r7 )�FabricXMLRPCConnectionr: r; r<