3 À<×eßã@sXddlmZddlTddlZddlmZddlZddlZej j ƒZ Gdd„dej ƒZ dS)é)Úbase)Ú*éN)Úcommandsc@sjeZdZdZdd„Zdd„Zedd„ƒZdd „Zd d „Z d d „Z e ddd�dd„ƒZ e 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_inventoryZ get_devicesZmatch_propertyÚaddZsys_namerÚ_cmd)ÚselfÚdevice©rú /usr/lib/python3.6/plugin_usb.pyÚ _init_devicess zUSBPlugin._init_devicescs‡fdd„|DƒS)Ncsg|]}ˆjjd|ƒ‘qS)r)r Z get_device)Ú.0Úx)r rrú *sz1USBPlugin._get_device_objects..r)r Zdevicesr)r rÚ_get_device_objects)szUSBPlugin._get_device_objectscCsddiS)NÚ autosuspendr)r rrrÚ_get_config_options,szUSBPlugin._get_config_optionscCsd|_d|_dS)NTF)Z_has_static_tuningZ_has_dynamic_tuning)r ÚinstancerrrÚ_instance_init2szUSBPlugin._instance_initcCsdS)Nr)r rrrrÚ_instance_cleanup6szUSBPlugin._instance_cleanupcCsd|S)Nz)/sys/bus/usb/devices/%s/power/autosuspendr)r r rrrÚ_autosuspend_sysfile9szUSBPlugin._autosuspend_sysfilerT)Z per_devicecCsR|j|ƒ}|dkrdS|rdnd}|sN|j|ƒ}|jj|||rFtjgndd�|S)NÚ1Ú0F)Úno_error)Z _option_boolrr Z 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)rr Z read_fileÚstrip)r r Zignore_missingr$rrrÚ_get_autosuspendIs zUSBPlugin._get_autosuspendN)F)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrÚ classmethodrrrrZ command_setr%Z command_getr'rrrrr s   r)ÚrZ decoratorsZ tuned.logsZtunedZtuned.utils.commandsrZglobrZlogsÚgetÚlogZPluginrrrrrÚs