(self, t_thresh)
return possible_sources
Uses configurations defined by user to configure sources for display.
        This should be the only place where sources are initiated

        This returns a list of sources after configurations are applied
Uses configurations defined by user to configure sources for display.
        This should be the only place where sources are initiated
Uses configurations defined by user to configure sources for display . This should be the only place where sources are initiated
def _load_config(self, t_thresh):
        """
        Uses configurations defined by user to configure sources for display.
        This should be the only place where sources are initiated

        This returns a list of sources after configurations are applied
        """
        # Load and configure user config dir when controller starts
        if not user_config_dir_exists():
            user_config_dir = make_user_config_dir()
        else:
            user_config_dir = get_user_config_dir()

        if user_config_dir is None:
            logging.warning("Failed to find or create scripts directory,\
                             proceeding without scripting support")
            self.script_hooks_enabled = False
        else:
            self.script_loader = ScriptHookLoader(user_config_dir)

        # Use user config file if one was saved before
        self.conf = None
        if user_config_file_exists():
            self.conf = configparser.ConfigParser()
            self.conf.read(get_user_config_file())
        else:
            logging.debug("Config file not found")

        # Load refresh refresh rate from config
        try:
            self.refresh_rate = str(self.conf.getfloat(
                'GraphControll', 'refresh'))
            logging.debug("User refresh rate: %s", self.refresh_rate)
        except (AttributeError, ValueError, configparser.NoOptionError,
                configparser.NoSectionError):
            logging.debug("No refresh rate configed")

        # Change UTF8 setting from config
        try:
            if self.conf.getboolean('GraphControll', 'UTF8'):
                self.smooth_graph_mode = True
            else:
                logging.debug("UTF8 selected as %s",
                              self.conf.get('GraphControll', 'UTF8'))
        except (AttributeError, ValueError, configparser.NoOptionError,
                configparser.NoSectionError):
            logging.debug("No user config for utf8")

        # Try to load high temperature threshold if configured
        if t_thresh is None:
            try:
                self.temp_thresh = self.conf.get('GraphControll', 'TTHRESH')
                logging.debug("Temperature threshold set to %s",
                              self.temp_thresh)
            except (AttributeError, ValueError, configparser.NoOptionError,
                    configparser.NoSectionError):
                logging.debug("No user config for temp threshold")
        else:
            self.temp_thresh = t_thresh

        # This should be the only place where sources are configured
        possible_sources = [TempSource(self.temp_thresh),
                            FreqSource(),
                            UtilSource(),
                            RaplPowerSource(),
                            FanSource()]

        # Load sensors config if available
        sources = [x.get_source_name() for x in possible_sources
                   if x.get_is_available()]
        for source in sources:
            try:
                options = list(self.conf.items(source + ",Graphs"))
                for option in options:
                    # Returns tuples of values in order
                    self.graphs_default_conf[source].append(
                        str_to_bool(option[1]))
                options = list(self.conf.items(source + ",Summaries"))
                for option in options:
                    # Returns tuples of values in order
                    self.summary_default_conf[source].append(
                        str_to_bool(option[1]))
            except (AttributeError, ValueError, configparser.NoOptionError,
                    configparser.NoSectionError):
                logging.debug("Error reading sensors config")

        return possible_sources
def _load_config ( self , t_thresh ) : # Load and configure user config dir when controller starts if not user_config_dir_exists ( ) : user_config_dir = make_user_config_dir ( ) else : user_config_dir = get_user_config_dir ( ) if user_config_dir is None : logging . warning ( "Failed to find or create scripts directory,\
                             proceeding without scripting support" ) self . script_hooks_enabled = False else : self . script_loader = ScriptHookLoader ( user_config_dir ) # Use user config file if one was saved before self . conf = None if user_config_file_exists ( ) : self . conf = configparser . ConfigParser ( ) self . conf . read ( get_user_config_file ( ) ) else : logging . debug ( "Config file not found" ) # Load refresh refresh rate from config try : self . refresh_rate = str ( self . conf . getfloat ( 'GraphControll' , 'refresh' ) ) logging . debug ( "User refresh rate: %s" , self . refresh_rate ) except ( AttributeError , ValueError , configparser . NoOptionError , configparser . NoSectionError ) : logging . debug ( "No refresh rate configed" ) # Change UTF8 setting from config try : if self . conf . getboolean ( 'GraphControll' , 'UTF8' ) : self . smooth_graph_mode = True else : logging . debug ( "UTF8 selected as %s" , self . conf . get ( 'GraphControll' , 'UTF8' ) ) except ( AttributeError , ValueError , configparser . NoOptionError , configparser . NoSectionError ) : logging . debug ( "No user config for utf8" ) # Try to load high temperature threshold if configured if t_thresh is None : try : self . temp_thresh = self . conf . get ( 'GraphControll' , 'TTHRESH' ) logging . debug ( "Temperature threshold set to %s" , self . temp_thresh ) except ( AttributeError , ValueError , configparser . NoOptionError , configparser . NoSectionError ) : logging . debug ( "No user config for temp threshold" ) else : self . temp_thresh = t_thresh # This should be the only place where sources are configured possible_sources = [ TempSource ( self . temp_thresh ) , FreqSource ( ) , UtilSource ( ) , RaplPowerSource ( ) , FanSource ( ) ] # Load sensors config if available sources = [ x . get_source_name ( ) for x in possible_sources if x . get_is_available ( ) ] for source in sources : try : options = list ( self . conf . items ( source + ",Graphs" ) ) for option in options : # Returns tuples of values in order self . graphs_default_conf [ source ] . append ( str_to_bool ( option [ 1 ] ) ) options = list ( self . conf . items ( source + ",Summaries" ) ) for option in options : # Returns tuples of values in order self . summary_default_conf [ source ] . append ( str_to_bool ( option [ 1 ] ) ) except ( AttributeError , ValueError , configparser . NoOptionError , configparser . NoSectionError ) : logging . debug ( "Error reading sensors config" ) return possible_sources