File: //lib64/python3.9/site-packages/lsm/__pycache__/_common.cpython-39.pyc
a
    B�:f=K  �                   @   sT  d dl Z d dlZd dlZd dlZd dlZd dlZzd dlmZ W n ey^   d dl	mZ Y n0 d dl
Z
z d dlmZm
Z
 d dlmZ W n. ey�   d dlmZm
Z
 d dlmZ Y n0 d dlZd dlZd dlZd dlZd dlZdMdd�Zdd	� ZG d
d� de�ZdZdZd
ddddddddddddddddddddddddd�Zg d�ZdNdd�Zdd � Zd!d"� Z dOd#d$�Z!d%d&� Z"d'd(� Z#d)d*� Z$d+d,� Z%d-d.� Z&d/d0� Z'd1d2� Z(G d3d4� d4e)�Z*ed5d6d7�ed8d9d7�ed:d;d7�G d<d=� d=e)����Z+dPd>d?�Z,d@dA� Z-G dBdC� dCe�Z.G dDdE� dEe�Z/dFdG� Z0dHdI� Z1G dJdK� dKej2�Z3e4dLk�rPe�5�  dS )Q�    N)�Sequence)�URLError�	HTTPError)�urlparseTc                    sH   d� � � fdd�}� fdd�}t ||r,|ndd|����fdd�}|S )	z�
    Creates the get/set properties for the given name.  It assumes that the
    actual attribute is '_' + name
    TODO: Expand this with domain validation to ensure the values are correct.
    �_c                    s
   t | � �S �N)�getattr��self��attribute_name� �1/usr/lib64/python3.9/site-packages/lsm/_common.py�getter.   s    z default_property.<locals>.getterc                    s   t | � |� d S r   ��setattr)r
   �valuer   r
   r   �setter1   s    z default_property.<locals>.setterNc                    s   t | � �� | S r   r   )�cls)�name�propr
   r   �	decorator6   s    z#default_property.<locals>.decorator)�property)r   Z	allow_set�docr   r   r   r
   )r   r   r   r   �default_property%   s    r   c                 C   s$  t | t�rttjt| ���t | t�rxt| �}d|v r\d|v rHttjd��d|v r\ttjd��t	dt
��  � ttj|��z*t
jr�t | t
j�r�ttjdt| � ��W n ty�   Y n0 tjr�t | t�r�ttjt| ���t | tj	�r�ttjt| ���t
�� }t	d| � ttjd	tt| �� |��d S )
Nz
urlopen errorz	Errno 111zConnection refusedz	Errno 113zHost is downzUnexpected network error:
zSSL Certificate error (%s)zUnexpected exception:
zUnexpected exception (TYPE= %s))�
isinstancer   �LsmError�ErrorNumber�PLUGIN_AUTH_FAILED�strr   �NETWORK_CONNREFUSED�NETWORK_HOSTDOWN�error�	traceback�
format_exc�
NETWORK_ERROR�sslZCertificateError�AttributeError�six�PY3�ConnectionError�socket�
PLUGIN_BUG�type)�expZdescZstack_tracer
   r
   r   �common_urllib2_error_handler=   s>