File: //lib/python3.6/site-packages/glances/exports/__pycache__/glances_couchdb.cpython-36.pyc
3
Eo�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| _| jddddgddgd �| _| jsRtj d
� | j
� | _dS )zInit the CouchDB export IF.)�config�argsN�couchdb�host�port�db�user�password)ZmandatoriesZoptions� )�superr �__init__r r r
Z load_conf�
export_enable�sys�exit�init�client)�selfr r )� __class__� �%/usr/lib/python3.6/glances_couchdb.pyr s
zExport.__init__c C s� | j s
dS | jdkr&dj| j| j�}ndj| j| j| j| j�}ytj|�}W n> tk
r� } z"t j
d||f � tjd� W Y dd}~X nX t j
d� y|| j W n tk
r� |j| j� Y nX t j
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"