def read_config(self, *args, **kwargs): try: serialized = self.core.config_manager.get(self.NAME) except (ConfigError, KeyError): self.config = SnmpdConf() else: self.config = SnmpdConf.deserialize(serialized) try: serialized = self.core.config_manager.get("contact") except (ConfigError, KeyError): self.contact_config = ContactConf.defaultConf() else: self.contact_config = ContactConf.deserialize(serialized)
def _setconfig(self, serialized): # TODO: factorize with exim component _setconfig (and maybe other modules) config = ContactConf.deserialize(serialized) valid, error = config.isValidWithMsg() if valid: self.config = config else: self.error( "Component %s read incorrect values. Message was: %s" % (self.NAME, error) ) return valid, error
def read_config(self, *args, **kwargs): self.config = ContactConf.defaultConf() try: serialized = self.core.config_manager.get(self.NAME) except ConfigError: self.debug("Not configured, defaults loaded.") return valid, message = self._setconfig(serialized) if not valid: self.error( "This means that the configuration is incorrect or that there is a bug" )
def resetConf(self): self._modified = False serialized = self.mainwindow.init_call("contact", u'getContactConfig') self.config = ContactConf.deserialize(serialized) self.admin_mail.setText(self.config.admin_mail) self.sender_mail.setText(self.config.sender_mail) if self.config.language in ContactConf.CODE_TO_NAME: lang_id = self.language.findText(ContactConf.CODE_TO_NAME[self.config.language]) self.language.setCurrentIndex(lang_id) smarthost = QMailObject.getInitializedInstance(self.client).mailcfg.smarthost self.use_smarthost.setChecked(bool(smarthost)) self.mail_relay.setEnabled(self.use_smarthost.isChecked()) self.mail_relay.setText(smarthost) self.smarthost_group.setVisible(True)