3 �h>`� � @ s� d dl mZ d dlZd dlZejdk r.d dlZd dlmZ d dl Z d dlZd dlZd dl Zd dlZd dlZd dlZd dlZd dlZd dlmZmZ d dlmZmZ d dlmZ d dlmZ d d lmZm Z d gZ!G dd � d eeeej�Z"dS ) � )�absolute_importN� )�GObject)�parse_config_setting� get_config)� RpcChannel�ConnectionState)�SETroubleshootServerInterface)�SETroubleshootDatabaseInterface)�Retry�get_error_from_socket_exception�ServerConnectionHandlerc @ s� e Zd Zejjdejffejjdejejejejffejjdejejffejjdejejffejjdejejejffd�Z dd� Z dd� Zddd�Zd d � Z dd� Zd d� Zdd� Zdd� Zdd� Zdd� Zdd� ZdS )r N)�alert�connection_state_changed�signatures_updated� database_bindzasync-errorc C s� t j| dd� tjj| � | jjd| j� | jd| � | jd| � tdd�| _tdd�| _ || _ d | _t| j | jd d�| _d| _d | _d S )NZsealert)�channel_typeZchangedZSEAlertZSETroubleshootDatabaseNotifyZgeneral�pkg_version�rpc_versionFg �?)Znotify_intervalTZaudit_listener)r �__init__r �connection_state�connect�on_connection_state_changeZconnect_rpc_interfacer r r �username�retry_connection_if_closedr �retry_connection�get_connection_retry_interval�connection_retry�report_connect_failure� database_name)�selfr � r! �&/usr/lib/python3.6/serverconnection.pyr 0 s z ServerConnectionHandler.__init__c C sZ | j d||||� |tj@ s,|tjtjB @ rV| jrV|tj@ rV| jjtj� | j j � d S )Nr )�emitr �OPEN�HUP�ERRORr �RETRYr �updater �start)r r �flagsZflags_addedZ flags_removedr! r! r"