o
    4"b                     @   sD   d dl Z d dlZd dlZd dlZedZe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   sR  z-t d}|D ]}t|rtg  W  d    W S qW d    n1 s'w   Y  W n tyE } ztd| W Y d }~nd }~ww z@tj	 }z|d= W n	 t
yZ   Y nw d|d< tjddg|tjtjdd	}| \}}|jd
krtd|j|f  W d S W n ty   td Y d S w | D ]}t|rtg  S qd S )Nz/proc/asound/cardsz%could not open /proc/asound/cards: %sLANGUAGECLC_ALLaplayz-lT)envstdoutstderrZuniversal_newlinesr   zaplay -l failed with %i: %sz4could not open aplay -l. Skipping sl-modem detection)openmodem_rematchpkgIOErrorloggingdebugosenvironcopyKeyError
subprocessPopenPIPEZcommunicate
returncodeerrorOSError
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   sV   








r"   )	r   rer   r   compiler
   r   r   r"   r    r    r    r!   <module>   s   

