<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
<eX                 @   s>   d dl mZ ddljZddlZejj ZG dd dej	Z	dS )   )base    Nc                   s   e Zd ZdZ fddZ fddZdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Z  ZS )Pluginz:
	Base class for plugins with device hotpluging support.
	c                s   t t| j|| d S )N)superr   __init__)selfargskwargs)	__class__ /usr/lib/python3.6/hotplug.pyr      s    zPlugin.__init__c                s   t t| j  | j  d S )N)r   r   cleanup_hardware_events_cleanup)r   )r
   r   r   r      s    zPlugin.cleanupc             C   s   d S )Nr   )r   r   r   r   _hardware_events_init   s    zPlugin._hardware_events_initc             C   s   d S )Nr   )r   r   r   r   r      s    zPlugin._hardware_events_cleanupc             C   s   | j   d S )N)r   )r   r   r   r   _init_devices   s    zPlugin._init_devicesc             C   sN   |dkr&t jd|j  | j|j n$|dkrJt jd|j  | j|j d S )Naddzdevice '%s' addedremovezdevice '%s' removed)loginfoZsys_name_add_device_remove_device)r   ZeventZdevicer   r   r   _hardware_events_callback   s    z Plugin._hardware_events_callbackc             C   sd   t jd|j|f  | jj| | j||jd|g | j|| | j||jd|g |j	j| d S )Nz!instance %s: adding new device %sZapply)
r   r   name_assigned_devicesr   _call_device_script
script_pre_added_device_apply_tuningscript_postprocessed_devices)r   instancedevice_namer   r   r   _add_device_process$   s    zPlugin._add_device_processc             C   sr   || j | jB krd S xXt| jj D ],\}}t| j||gdkr$| j|| P q$W tj	d|  | jj
| d S )Nr   zno instance wants %s)r   _free_deviceslist
_instancesitemslenZ_get_matching_devicesr!   r   debugr   )r   r    Zinstance_namer   r   r   r   r   ,   s    zPlugin._add_devicec             C   s8   x|D ]}| j || qW t|jt|j dk|_dS )zN
		Add devices specified by the set to the instance, no check is performed.
		r   N)r!   r&   r   assigned_devicesactive)r   r   device_namesdevr   r   r   _add_devices_nocheck8   s    
zPlugin._add_devices_nocheckc             C   sx   ||j krt| j||jd|g | j|| | j||jd|g |j j| t|j t|j dk|_| j	j| dS dS )NZunapplyr   TF)
r   r   r   _removed_device_unapply_tuningr   r   r&   r(   r)   r   )r   r   r    r   r   r   _remove_device_processC   s    
zPlugin._remove_device_processc             C   sJ   || j | jB krdS x0t| jj D ]}| j||r$P q$W | jj| dS )zVRemove device from the instance

		Parameters:
		device_name -- name of the device

		N)r   r"   r#   r$   valuesr.   r   )r   r    r   r   r   r   r   Q   s    zPlugin._remove_devicec             C   s   x|D ]}| j || qW dS )zS
		Remove devices specified by the set from the instance, no check is performed.
		N)r.   )r   r   r*   r+   r   r   r   _remove_devices_nochecka   s    
zPlugin._remove_devices_nocheckc             C   s6   | j ||g |jr2| jjtjtjr2| j|| d S )N)Z_execute_all_device_commandshas_dynamic_tuning_global_cfggetconstsCFG_DYNAMIC_TUNINGCFG_DEF_DYNAMIC_TUNINGZ_instance_apply_dynamic)r   r   r    r   r   r   r   h   s    z!Plugin._added_device_apply_tuningc             C   s:   |j r$| jjtjtjr$| j|| | j||gdd d S )NT)r   )r1   r2   r3   r4   r5   r6   Z_instance_unapply_dynamicZ_cleanup_all_device_commands)r   r   r    r   r   r   r-   m   s    z%Plugin._removed_device_unapply_tuning)__name__
__module____qualname____doc__r   r   r   r   r   r   r!   r   r,   r.   r   r0   r   r-   __classcell__r   r   )r
   r   r      s   r   )
 r   Ztuned.constsr4   Z
tuned.logsZtunedZlogsr3   r   r   r   r   r   r   <module>   s   

