AlkantarClanX12

Your IP : 3.143.235.104


Current Path : /usr/lib/python3.6/site-packages/tuned/hardware/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/tuned/hardware/__pycache__/inventory.cpython-36.pyc

3

�<�e3�@sPddlZddlZddlmZdgZejj�ZGdd�de�Z	Gdd�de�Z
dS)�N)�consts�	Inventoryc@s\eZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zddd�ZdS)rz�
	Inventory object can handle information about available hardware devices. It also informs the plugins
	about related hardware events.
	NTcCs�|dk	r||_n
tj�|_|dkr(tj}|j|j�|_|dkrDtj}|rxy|jj|�Wnt	k
rvt
jd�YnX|dkr�t�}||_
d|_i|_dS)NzLcannot set udev monitor receive buffer size, we are probably running inside zIcontainer or with limited capabilites, TuneD functionality may be limitedz�cannot set udev monitor receive buffer size, we are probably running inside container or with limited capabilites, TuneD functionality may be limited)�
_udev_context�pyudevZContextZMonitorZfrom_netlink�
_udev_monitorrZCFG_DEF_UDEV_BUFFER_SIZE�set_receive_buffer_size�EnvironmentError�log�warn�_MonitorObserverFactory�_monitor_observer_factory�_monitor_observer�_subscriptions)�selfZudev_contextZudev_monitor_clsZmonitor_observer_factory�buffer_sizer�r�/usr/lib/python3.6/inventory.py�__init__s&
zInventory.__init__cCs:ytjj|j||�Stk
r4tjj|j||�SXdS)z9Get a pyudev.Device object for the sys_name (e.g. 'sda').N)rZDevices�	from_namer�AttributeErrorZDevice)r�	subsystemZsys_namerrr�
get_device)szInventory.get_devicecCs|jj|d�S)z)Get list of devices on a given subsystem.)r)rZlist_devices)rrrrr�get_devices1szInventory.get_devicescCsx|j|jkrdSxb|j|jD]R\}}y|||�Wqtk
rn}ztjd|�tj|�WYdd}~XqXqWdS)Nz+Exception occured in event handler of '%s'.)rr�	Exceptionr	�errorZ	exception)rZeventZdevice�plugin�callback�errr�_handle_udev_event5szInventory._handle_udev_eventcCs\tjd||f�||f}||jkr6|j|j|�n"|g|j|<|jj|�|jj�dS)z7Register handler of device events on a given subsystem.zadding handler: %s (%s)N)r	�debugr�appendrZ	filter_by�start)rrrr�
callback_datarrr�	subscribe@s
zInventory.subscribecCs6|jdkr2tjd�|jj|j|j�|_|jj�dS)Nzstarting monitor observer)r
r	rr�createrrr!)rrrr�start_processing_eventsLs

z!Inventory.start_processing_eventscCs(|jdk	r$tjd�|jj�d|_dS)Nzstopping monitor observer)r
r	r�stop)rrrr�stop_processing_eventsRs


z Inventory.stop_processing_eventscCsJxD|j|D]6}|\}}||krtjd||f�|j|j|�qWdS)Nzremoving handler: %s (%s))rr	r�remove)rrrr"Z_pluginrrrr�_unsubscribe_subsystemXs
z Inventory._unsubscribe_subsystemcCsfg}xF|jD]<}|dks ||kr|j||�t|j|�dkr|j|�qWx|D]}|j|=qRWdS)z4Unregister handler registered with subscribe method.Nr)rr)�lenr )rrrZempty_subsystemsZ
_subsystemrrr�unsubscribe_s
zInventory.unsubscribe)NNNNT)N)
�__name__�
__module__�__qualname__�__doc__rrrrr#r%r'r)r+rrrrr	s
c@seZdZdd�ZdS)rcOstj||�S)N)rZMonitorObserver)r�args�kwargsrrrr$lsz_MonitorObserverFactory.createN)r,r-r.r$rrrrrksr)rZ
tuned.logsZtunedr�__all__Zlogs�getr	�objectrrrrrr�<module>s
b