ó
æ”\c           @   s   d  d l  Z d  d l m Z m Z d  d l m Z d  d l m Z d  d l	 j
 Z
 d  d l m Z d g Z e j j ƒ  Z d d d „  ƒ  YZ d S(	   iÿÿÿÿN(   t	   ConfigObjt   ConfigObjError(   t	   Validator(   t   TunedException(   t   commandst   GlobalConfigc           B   s   e  Z d  e j d e j d e j d e j g Z e j d „ Z	 e j d „ Z
 d
 d „ Z d
 d „ Z d „  Z d
 d	 „ Z RS(   s$   dynamic_tuning = boolean(default=%s)s$   sleep_interval = integer(default=%s)s%   update_interval = integer(default=%s)s'   recommend_command = boolean(default=%s)c         C   s)   i  |  _  |  j d | ƒ t ƒ  |  _ d  S(   Nt	   file_name(   t   _cfgt   load_configR   t   _cmd(   t   selft   config_file(    (    s=   /usr/lib/python2.7/site-packages/tuned/utils/global_config.pyt   __init__   s    	c         C   sÅ   t  j d | ƒ y4 t | d |  j d t d t d t d t ƒ|  _ WnE t k
 rj } t d | ƒ ‚ n# t	 k
 rŒ } t d | ƒ ‚ n Xt
 ƒ  } |  j j | d	 t ƒsÁ t d
 | ƒ ‚ n  d S(   s&   
		Loads global configuration file.
		s2   reading and parsing global configuration file '%s't
   configspect   raise_errorst
   file_errort   list_valuest   interpolations/   Global tuned configuration file '%s' not found.s3   Error parsing global tuned configuration file '%s'.t   copys2   Global tuned configuration file '%s' is not valid.N(   t   logt   debugR    t   global_config_spect   Truet   FalseR   t   IOErrorR   R   R   t   validate(   R
   R   t   et   vdt(    (    s=   /usr/lib/python2.7/site-packages/tuned/utils/global_config.pyR      s    	c         C   s   |  j  j | | ƒ S(   N(   R   t   get(   R
   t   keyt   default(    (    s=   /usr/lib/python2.7/site-packages/tuned/utils/global_config.pyR   (   s    c         C   s,   |  j  j |  j | | ƒ ƒ d k r( t St S(   Nt   1(   R	   t   get_boolR   R   R   (   R
   R   R   (    (    s=   /usr/lib/python2.7/site-packages/tuned/utils/global_config.pyR    +   s    $c         C   s   | |  j  | <d  S(   N(   R   (   R
   R   t   value(    (    s=   /usr/lib/python2.7/site-packages/tuned/utils/global_config.pyt   set0   s    c         C   s`   |  j  | ƒ } | d  k r | S|  j j | ƒ } | d  k rX t j d | | f ƒ | S| Sd  S(   Ns%   Error parsing value '%s', using '%s'.(   R   t   NoneR	   t   get_sizeR   t   error(   R
   R   R   t   valt   ret(    (    s=   /usr/lib/python2.7/site-packages/tuned/utils/global_config.pyR$   3   s    N(   t   __name__t
   __module__t   constst   CFG_DEF_DYNAMIC_TUNINGt   CFG_DEF_SLEEP_INTERVALt   CFG_DEF_UPDATE_INTERVALt   CFG_DEF_RECOMMEND_COMMANDR   t   GLOBAL_CONFIG_FILER   R   R#   R   R    R"   R$   (    (    (    s=   /usr/lib/python2.7/site-packages/tuned/utils/global_config.pyR      s   


	(    (   t
   tuned.logst   tunedt	   configobjR    R   R   R   t   tuned.exceptionsR   t   tuned.constsR*   t   tuned.utils.commandsR   t   __all__t   logsR   R   R   (    (    (    s=   /usr/lib/python2.7/site-packages/tuned/utils/global_config.pyt   <module>   s   	