3
J_                 @   sD   d dl Z d dlZd dlZd dlZejdZejdZdZdd ZdS )    Nz^\s*\d+\s*\[Modem\s*\]z^card [0-9].*[mM]odemzsl-modem-daemonc       	   #   C   s2  y6t d$}x|D ]}tj|rtgS qW W d Q R X W n. tk
rd } ztjd| W Y d d }~X nX ytjj	 }y
|d= W n t
k
r   Y nX d|d< tjddg|tjtjdd	}|j \}}|jd
krtjd|j|f  d S W n  tk
r   tjd d S X x$|j D ]}tj|rtgS qW d S )Nz/proc/asound/cardsz%could not open /proc/asound/cards: %sZLANGUAGECLC_ALLaplayz-lT)envstdoutstderrZuniversal_newlinesr   zaplay -l failed with %i: %szcould not open aplay -l)openmodem_rematchpkgIOErrorloggingdebugosenvironcopyKeyError
subprocessPopenPIPEZcommunicate
returncodeerrorOSErrorZ	exception
splitlinesmodem_as_subdevice_re)	Z	apt_cachefdlineer   r   Z	aplay_outZ	aplay_errrow r   3/usr/share/ubuntu-drivers-common/detect/sl-modem.pydetect   s<    








r!   )	r   rer   r   compiler	   r   r   r!   r   r   r   r    <module>   s   

