Exemple #1
0
 def init(self):
     if os.path.exists(self.defaults_path):
         if not os.path.exists(self.path):
             # New settings, just copy value
             copyfile(self.defaults_path, self.path)
             log.debug('copied default settings from {} to {}'.format(
                 self.defaults_path, self.path))
         else:
             # Settings already exists
             # Attempt to merge any new default values
             _contents, default_settings = read_contents(self.defaults_path,
                                                         blank=True)
             updated = False
             for section in default_settings.sections():
                 for option in default_settings.options(section):
                     if not self.settings.has_option(section, option):
                         value = default_settings.get(section, option)
                         self.settings.set(section, option, value)
                         log.debug(
                             'added new default to {} {}/{}="{}"'.format(
                                 self, section, option, value))
                         updated = True
             if updated:
                 self.export()
     self.load()
 def load(self):
     """"Load the live settings"""
     try:
         timestamp = self.get_timestamp()
         self._contents, self._settings = read_contents(self.path, blank=True)
         self.timestamp = timestamp
     except Exception:
         log.exception('Error reading live settings from "{}"'.format(self.path))
         return False
     return True
Exemple #3
0
 def load(self):
     """"Load the live settings"""
     try:
         timestamp = self.get_timestamp()
         self._contents, self._settings = read_contents(self.path,
                                                        blank=True)
         self.timestamp = timestamp
     except Exception:
         log.exception('Error reading live settings from "{}"'.format(
             self.path))
         return False
     return True
 def init(self):
     if os.path.exists(self.defaults_path):
         if not os.path.exists(self.path):
             # New settings, just copy value
             copyfile(self.defaults_path, self.path)
             log.debug('copied default settings from {} to {}'.format(self.defaults_path, self.path))
         else:
             # Settings already exists
             # Attempt to merge any new default values
             _contents, default_settings = read_contents(self.defaults_path, blank=True)
             updated = False
             for section in default_settings.sections():
                 for option in default_settings.options(section):
                     if not self.settings.has_option(section, option):
                         value = default_settings.get(section, option)
                         self.settings.set(section, option, value)
                         log.debug('added new default to {} {}/{}="{}"'.format(self, section, option, value))
                         updated = True
             if updated:
                 self.export()
     self.load()