
    d7                        d dl Z d dlZd dlZd dlZd dlZ	 d dlZ	 ej                  d    dk(  r,d dlm	Z
 d dlmZ 	 eZeZd dlmZmZ d dlmZ d dlmZmZ d dlZnmej                  d    dk(  r:d dlZ
d dlmZ d dlmZmZ eZeZeZeZej                  d   d	k\  rd dlmZ n(d dlmZ n! e d
jC                  ej                              d Z"d Z#d Z$d Z%e jL                  d        Z'd Z(y# e$ r Y w xY w)    N   )urlparse)intrange)OrderedDict)QueueEmpty         zUnknown python version: {0}c                    	 t         j                  |fz   }t        t        j                  | |            }t        j
                  j                  d      r
t               }|r|g dk(  rt        |       S t        j                         d   j                         }|j                  |       |S # t        $ r t        |       cY S w xY w)zqAbstract platform.linux_distribution() call which is deprecated as of
       Python 3.5 and removed in Python 3.7)full_distribution_namesupported_dists/etc/openwrt_release) r   r   r   )platform_supported_distslistlinux_distributionospathexistsget_openwrt_platform"get_linux_distribution_from_distrostripappendAttributeError)get_full_namer   	supportedosinfo	full_names        ?/usr/lib/python3/dist-packages/azurelinuxagent/common/future.pyget_linux_distributionr#   I   s    A--0BB	'''4 )
 77>>01)+F</5mDD//1!4::<	i  M  A1-@@As   A0B+ 36B+ +CCc                    t        t        j                  |             }t        j                         d   j                         }|j	                  |       d|d   j                         v rt        j                  d      |d<   |S )z?Get the distribution information from the distro Python module.)r   r   marinerT)bestr   )r   distror   r   r   lowerversion)r   r    r!   s      r"   r   r   d   su    
 !!#0	
F
 ))+A.446I
MM) F1IOO%%NN-q	M    c                     g d} t        j                  d      }t        j                  d      }t        dd      5 }|j                         }|D ]X  }|j	                  |      }|j	                  |      }|r|j                  d      | d<   <|s?|j                  d      dk(  sTd| d	<   Z 	 d
d
d
       | S # 1 sw Y   | S xY w)z
    Add this workaround for detecting OpenWRT products because
    the version and product information is contained in the /etc/openwrt_release file.
    )NNNz)^DISTRIB_RELEASE=['\"](\d+\.\d+.\d+)['\"]z^DISTRIB_ID=['\"]([\w-]+)['\"]r   rr   OpenWrtopenwrtr   N)recompileopen	readlinesmatchgroup)resultopenwrt_versionopenwrt_productfhcontentlineversion_matchesproduct_matchess           r"   r   r   y   s    
  Fjj!MNOjj!BCO	$c	* 	*b,,. 	*D-33D9O-33D9O+11!4q	 "((+y8 )F1I	*	* M	* Ms   AB4B4"B44B>c                     t         j                  d   dk(  r!t        | t              xr | j                  dk(  S t         j                  d   dk(  rt        | t
              S t        | t
              S )Nr   r
   r   )sysversion_info
isinstanceOSErrorerrnoFileNotFoundError)	exceptions    r"   is_file_not_found_errorrE      sa     a)W-F)//Q2FF			!		!)%677i!233r*   c               #     K   t         j                  d   dk(  rt        j                   y 	 t	        t
        j                  d      } |   | j                          y y # t        $ r d  Y #w xY w#  | j                          w w xY ww)Nr   r   za+)	r>   r?   
subprocessDEVNULLr1   r   devnull	Exceptionclose)rI   s    r"   subprocess_dev_nullrL      s      a   	 2::t,GM " #  	J	 " #s4   *B
A B
A/,A2 .A//A2 2BB
c                     t         j                  d   dk(  r| j                         S t         j                  d   dk(  r&t         j                  d   dk  r| j                         S | j                         S )Nr   r
   r   r      )r>   r?   tostringtobytes)buffs    r"   array_to_bytesrR      s^    
a}}
aC$4$4Q$71$<}}<<>r*   ))
contextlibr   r>   r   r/   r'   rJ   r?   http.clientclient
httpclienturllib.parser   strustr
memoryview
bytebufferbuiltinsr   r   collectionsr   queuer   r	   rG   httplibunicodebufferxrangelongordereddictImportErrorformatr#   r   r   rE   contextmanagerrL   rR    r*   r"   <module>ri      s     
 	 		

 A!$%$DJ $'" aA !" DJE
C a++
3::3;K;KL
MM6**4    E  		s   C( (C0/C0