3 Yd@sPddlmZddlTddlZddlmZddlZejj Z Gdddej Z dS))base)*N)commandsc@sjeZdZdZddZddZeddZdd Zd d Z d d Z e dddddZ e ddddZdS) 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*|jjdjddD]}|jj|jq,Wt |_ dS)NTusbZDEVTYPEZ usb_device) Z_devices_supportedsetZ _free_devicesZ_assigned_devices_hardware_inventoryZ get_devicesZmatch_propertyaddZsys_namer_cmd)selfdevicer /usr/lib/python3.6/plugin_usb.py _init_devicess zUSBPlugin._init_devicescsfdd|DS)Ncsg|]}jjd|qS)r)r Z get_device).0x)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_init1szUSBPlugin._instance_initcCsdS)Nr)r rrrr_instance_cleanup5szUSBPlugin._instance_cleanupcCsd|S)Nz)/sys/bus/usb/devices/%s/power/autosuspendr)r r rrr_autosuspend_sysfile8szUSBPlugin._autosuspend_sysfilerT)Z per_devicecCsB|j|}|dkrdS|rdnd}|s>|j|}|jj|||S)N10)Z _option_boolrr Z write_to_file)r valuer Zsimenablevalsys_filerrr_set_autosuspend;s   zUSBPlugin._set_autosuspendFcCs|j|}|jj||djS)N)Zno_error)rr Z read_filestrip)r r Zignore_missingr rrr_get_autosuspendGs zUSBPlugin._get_autosuspendN)F)__name__ __module__ __qualname____doc__rr classmethodrrrrZ command_setr!Z command_getr#rrrrr s   r) rZ decoratorsZ tuned.logsZtunedZtuned.utils.commandsrZglobZlogsgetlogZPluginrrrrrs