o
    Û1jª  ã                   @   s2   d dl Z d dlmZmZmZ G dd„ deeƒZdS )é    N)ÚPluginÚRedHatPluginÚ	PluginOptc                   @   s6   e Zd ZdZdZdZdZeddedd�gZ	dd	„ Z
d
S )ÚOratabz.Oratab discovery for Oracle instances on LinuxÚoratab)Úservices)r   z/etc/oratabzlocation of the oratab file)ÚdefaultÚval_typeÚdescc              
      sø   ˆ  d¡}tj |¡ruzKtƒ ‰ t|ddd��%}| ¡  ¡ D ]}| d¡s(| 	¡ s)qˆ  
| d¡d ¡ qW d   ƒ n1 s>w   Y  dd	g}ˆ ‡ ‡fd
d„|D ƒ¡ W d S  tyt } zˆ d|› d|› �¡ W Y d }~d S d }~ww ˆ d¡ d S )Nr   ÚrzUTF-8)Úencodingú#ú:é   zdbs/init*.orazdbs/spfile*.orac                    s"   g | ]}ˆ D ]}ˆ  ||¡‘qqS © )Ú	path_join)Ú.0ÚdbfileÚpath©Ú	path_listÚselfr   ú;/usr/lib/python3/dist-packages/sos/report/plugins/oratab.pyÚ
<listcomp>.   s    þ
ÿÿz Oratab.setup.<locals>.<listcomp>zCould not open conf file z: z@Could not locate oratab file. Oracle data will not be collected.)Ú
get_optionÚosr   ÚisfileÚsetÚopenÚreadÚ
splitlinesÚ
startswithÚstripÚaddÚsplitÚadd_copy_specÚIOErrorÚ
_log_errorÚ	_log_warn)r   Úora_tabÚofileÚlineÚdbfilesÚexr   r   r   Úsetup   s.   
ýÿþÿ€þzOratab.setupN)Ú__name__Ú
__module__Ú__qualname__Ú
short_descÚplugin_nameÚprofilesÚpackagesr   ÚstrÚoption_listr.   r   r   r   r   r      s    ÿÿr   )r   Úsos.report.pluginsr   r   r   r   r   r   r   r   Ú<module>   s   