Edit File: db_info_lib.cpython-37.opt-1.pyc
B 5/9e� � @ s@ d dl mZ d dlZd dlZd dlmZmZ G dd� de�ZdS )� )�absolute_importN)�run_command�ExternalProgramFailedc @ sH e Zd Zdd� Zedd� �Zdd� Zdd� Zd d � Zdd� Z d d� Z dS )� MysqlInfoc C s | � � | _d S )N)�retrieve_server_info�mysqld_v)�self� r �py/clconfig/db_info_lib.py�__init__ s zMysqlInfo.__init__c C s( yt �d� dS tk r" dS X dS )zP Find mysql server binary :return: path to mysql binary z/usr/sbin/mysqldz/usr/libexec/mysqldN)�os�stat�OSErrorr r r r � get_binary s zMysqlInfo.get_binaryc C s* yt | �� dg�S tk r$ dS X dS )zx Get server information through `<mysql_server_binary> -V` command :return: full command output z-VN)r r r )r r r r r s zMysqlInfo.retrieve_server_infoc C s | � � | �� | �� d�S )a& Return gathered data :return: dict( 'vendor': MySQL|MariaDB|Percona, 'version': server version in the form of {major}.{minor} or {major}.{minor}-{release} for percona, 'cll-lve': patches from CL applied or not (True|False) ) )Zvendor�versionzcll-lve)� get_vendor�get_version� is_patched)r r r r �get( s z MysqlInfo.getc C sJ | j dkrdS t�d�}y|�| j �d �� d S tk rD dS X dS )z� Extract MySQL vendor from server info :return: MySQL|MariaDB|Percona or `unknown` if failed to apply regex or None if there is no server info (this usually means that there are no MySQL installed) Nz(?<=\().+(?=\sServer)r �unknown)r �re�compile�findall�split� IndexError)r �pr r r r 7 s zMysqlInfo.get_vendorc C sH | j dkrdS t�d�}y|�| j �d �d�S tk rB dS X dS )aF Retrieve MySQL server version from server info :return: X.X.X e.g. 10.2.16|5.6.39, includes release for percona (X.X.X-X.X e.g. 5.6.40-84.0) or `unknown` if failed to apply regex or None if there is no server info (this usually means that there are no MySQL installed) Nz(?<=Ver\s)[0-9\.\-]+r �-r )r r r r �rstripr )r r r r r r I s zMysqlInfo.get_versionc C s | j dkrdS d| j kS )a Retrieve information about CL patch by `cll-lve` in server info :return: True if contains `cll-lve` seq False otherwise or None if there is no server info (this usually means that there are no MySQL installed) Nzcll-lve)r )r r r r r [ s zMysqlInfo.is_patchedN)�__name__� __module__�__qualname__r �staticmethodr r r r r r r r r r r s r ) Z __future__r r r Zclcommon.utilsr r �objectr r r r r �<module> s