File: //usr/lib/python3.6/site-packages/glances/exports/__pycache__/glances_json.cpython-36.pyc
3
Eo�c� � @ sT d Z ddlZddlmZ ddlmZmZ ddlmZ ddl m
Z
G dd� de
�ZdS ) zJSON interface class.� N)�
json_dumps)�PY3�listkeys)�logger)�
GlancesExportc s2 e Zd ZdZd � fdd� Zdd� Zdd� Z� ZS )
�Exportz*This class manages the JSON export module.Nc s� t t| �j||d� |j| _y:tr<t| jd�| _| jj� nt| jd�| _| jj� W n< t k
r� } z t
jdj|�� t
jd� W Y dd}~X nX t
jdj| j�� d| _i | _dS ) zInit the JSON export IF.)�config�args�w�wbzCannot create the JSON file: {}� NzExporting stats to file: {}T)�superr �__init__Zexport_json_file�
json_filenamer �open� json_file�close�IOErrorr Zcritical�format�sys�exit�infoZ
export_enable�buffer)�selfr r �e)� __class__� �"/usr/lib/python3.6/glances_json.pyr s zExport.__init__c C s t jd| j � | jj� dS )zClose the JSON file.zFinalise export interface %sN)r �debugZexport_namer r )r r r r r ) s zExport.exitc C s� || j � d kr�| ji kr�tjdjt| j�| j�� trlt| jd�� | _ | j j
djt| j��� W dQ R X n2t| jd�� | _ | j j
djt| j��� W dQ R X i | _tt
||��| j|<