/usr/share/cagefs-skeleton/lib/python3.9/site-packages/glances/exports/__pycache__
a ���ca � @ sT d Z ddlZddlmZ ddlmZ ddlmZ ddlZddlZG dd� de�Z dS )zCouchDB interface class.� N)�datetime)�logger)� GlancesExportc s: e Zd ZdZd� fdd� Zdd� Zdd� Zd d � Z� ZS )�Exportz-This class manages the CouchDB export module.Nc s^ t t| �j||d� d| _d| _d| _| jdg d�ddgd�| _| jsPt� d� | � � | _dS ) zInit the CouchDB export IF.)�config�argsN�couchdb)�host�port�db�user�password)Zmandatories�options� )�superr �__init__r r r Z load_conf� export_enable�sys�exit�init�client)�selfr r �� __class__� �C/usr/lib/python3.9/site-packages/glances/exports/glances_couchdb.pyr s zExport.__init__c C s� | j s dS | jdu r&d�| j| j�}nd�| j| j| j| j�}zt�|�}W n@ ty� } z(t � d||f � t�d� W Y d}~nd}~0 0 t � d� z|| j W n ty� |�| j� Y n0 t � d| j � |S )z*Init the connection to the CouchDB server.Nz http://{}:{}/zhttps://{}:{}@{}:{}/z(Cannot connect to CouchDB server %s (%s)r zConnected to the CouchDB serverzThere is already a %s database)r r �formatr r r r ZServer� Exceptionr Zcriticalr r �infor Zcreate)r Z server_uri�s�er r r r - s"