Sindbad~EG File Manager
3
�<�e��@sXddlmZddlTddlZddlmZddlZddlZej j
�ZGdd�dej�Z
dS)�)�base)�*�N)�commandsc@sjeZdZdZdd�Zdd�Zedd��Zdd �Zd
d�Z dd
�Z
eddd�dd��Ze
d�ddd��ZdS)� USBPlugina�
`usb`::
Sets autosuspend timeout of USB devices to the value specified by the
[option]`autosuspend` option in seconds. If the [option]`devices`
option is specified, the [option]`autosuspend` option applies to only
the USB devices specified, otherwise it applies to all USB devices.
+
The value `0` means that autosuspend is disabled.
+
.To turn off USB autosuspend for USB devices `1-1` and `1-2`
====
----
[usb]
devices=1-1,1-2
autosuspend=0
----
====
cCsNd|_t�|_t�|_x*|jjd�jdd�D]}|jj|j�q,Wt �|_
dS)NT�usbZDEVTYPEZ
usb_device)Z_devices_supported�setZ
_free_devicesZ_assigned_devices�_hardware_inventoryZget_devicesZmatch_property�addZsys_namer�_cmd)�self�device�r� /usr/lib/python3.6/plugin_usb.py�
_init_devicesszUSBPlugin._init_devicescs�fdd�|D�S)Ncsg|]}�jjd|��qS)r)r Z
get_device)�.0�x)rrr�
<listcomp>*sz1USBPlugin._get_device_objects.<locals>.<listcomp>r)rZdevicesr)rr�_get_device_objects)szUSBPlugin._get_device_objectscCsddiS)N�autosuspendr)rrrr�_get_config_options,szUSBPlugin._get_config_optionscCsd|_d|_dS)NTF)Z_has_static_tuningZ_has_dynamic_tuning)r�instancerrr�_instance_init2szUSBPlugin._instance_initcCsdS)Nr)rrrrr�_instance_cleanup6szUSBPlugin._instance_cleanupcCsd|S)Nz)/sys/bus/usb/devices/%s/power/autosuspendr)rr
rrr�_autosuspend_sysfile9szUSBPlugin._autosuspend_sysfilerT)Z
per_devicecCsR|j|�}|dkrdS|rdnd}|sN|j|�}|jj|||rFtjgndd�|S)N�1�0F)�no_error)Z_option_boolrrZ
write_to_file�errno�ENOENT)r�valuer
Zsim�remove�enable�val�sys_filerrr�_set_autosuspend<s
zUSBPlugin._set_autosuspendFcCs|j|�}|jj||d�j�S)N)r)rrZ read_file�strip)rr
Zignore_missingr$rrr�_get_autosuspendIs
zUSBPlugin._get_autosuspendN)F)�__name__�
__module__�__qualname__�__doc__rr�classmethodrrrrZcommand_setr%Zcommand_getr'rrrrr
s
r)�rZ
decoratorsZ
tuned.logsZtunedZtuned.utils.commandsrZglobrZlogs�get�logZPluginrrrrr�<module>s
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists