ó
æ”\c           @   sn   d  d l  m Z d  d l Td d l Z d d l m Z d d l Z e j j	 ƒ  Z
 d e j f d „  ƒ  YZ d S(   i   (   t   base(   t   *iÿÿÿÿN(   t   commandst	   USBPluginc           B   s}   e  Z d  Z d „  Z d „  Z e d „  ƒ Z d „  Z d „  Z d „  Z	 e
 d d e ƒd	 „  ƒ Z e d ƒ e d
 „ ƒ Z RS(   s7   
	Plugin for tuning various options of USB subsystem.
	c         C   sm   t  |  _ t ƒ  |  _ t ƒ  |  _ x9 |  j j d ƒ j d d ƒ D] } |  j j | j	 ƒ q@ Wt
 ƒ  |  _ d  S(   Nt   usbt   DEVTYPEt
   usb_device(   t   Truet   _devices_supportedt   sett   _free_devicest   _assigned_devicest   _hardware_inventoryt   get_devicest   match_propertyt   addt   sys_nameR   t   _cmd(   t   selft   device(    (    s<   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_usb.pyt   _init_devices   s    	%c         C   s&   g  | D] } |  j  j d | ƒ ^ q S(   NR   (   R   t
   get_device(   R   t   devicest   x(    (    s<   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_usb.pyt   _get_device_objects   s    c         C   s   i d  d 6S(   Nt   autosuspend(   t   None(   R   (    (    s<   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_usb.pyt   _get_config_options   s    c         C   s   t  | _ t | _ d  S(   N(   R   t   _has_static_tuningt   Falset   _has_dynamic_tuning(   R   t   instance(    (    s<   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_usb.pyt   _instance_init!   s    	c         C   s   d  S(   N(    (   R   R   (    (    s<   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_usb.pyt   _instance_cleanup%   s    c         C   s   d | S(   Ns)   /sys/bus/usb/devices/%s/power/autosuspend(    (   R   R   (    (    s<   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_usb.pyt   _autosuspend_sysfile(   s    R   t
   per_devicec         C   s`   |  j  | ƒ } | d  k r d  S| r+ d n d } | s\ |  j | ƒ } |  j j | | ƒ n  | S(   Nt   1t   0(   t   _option_boolR   R"   R   t   write_to_file(   R   t   valueR   t   simt   enablet   valt   sys_file(    (    s<   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_usb.pyt   _set_autosuspend+   s    c         C   s+   |  j  | ƒ } |  j j | d | ƒj ƒ  S(   Nt   no_error(   R"   R   t	   read_filet   strip(   R   R   t   ignore_missingR,   (    (    s<   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_usb.pyt   _get_autosuspend7   s    (   t   __name__t
   __module__t   __doc__R   R   t   classmethodR   R    R!   R"   t   command_setR   R-   t   command_getR   R2   (    (    (    s<   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_usb.pyR   	   s   	
					(   t    R    t
   decoratorst
   tuned.logst   tunedt   tuned.utils.commandsR   t   globt   logst   gett   logt   PluginR   (    (    (    s<   /usr/lib/python2.7/site-packages/tuned/plugins/plugin_usb.pyt   <module>   s   
