def _loadConfig(self, fn, fileError=False): log.info(u"Loading config: {0}".format(fn)) profile = ConfigObj(fn, indent_type="\t", encoding="UTF-8", file_error=fileError) # Python converts \r\n to \n when reading files in Windows, so ConfigObj can't determine the true line ending. profile.newlines = "\r\n" profileCopy = deepcopy(profile) try: profileUpgrader.upgrade(profile, self.validator) except Exception as e: # Log at level info to ensure that the profile is logged. log.info(u"Config before schema update:\n%s" % profileCopy, exc_info=False) raise e # since profile settings are not yet imported we have to "peek" to see # if debug level logging is enabled. try: logLevelName = profile["general"]["loggingLevel"] except KeyError as e: logLevelName = None if log.isEnabledFor( log.DEBUG) or (logLevelName and DEBUG >= levelNames.get(logLevelName)): # Log at level info to ensure that the profile is logged. log.info( u"Config loaded (after upgrade, and in the state it will be used by NVDA):\n{0}" .format(profile)) return profile
def _loadConfig(self, fn, fileError=False): log.info(u"Loading config: {0}".format(fn)) profile = ConfigObj(fn, indent_type="\t", encoding="UTF-8", file_error=fileError) # Python converts \r\n to \n when reading files in Windows, so ConfigObj can't determine the true line ending. profile.newlines = "\r\n" profileCopy = deepcopy(profile) try: profileUpgrader.upgrade(profile, self.validator) except Exception as e: # Log at level info to ensure that the profile is logged. log.info(u"Config before schema update:\n%s" % profileCopy, exc_info=False) raise e # since profile settings are not yet imported we have to "peek" to see # if debug level logging is enabled. try: logLevelName = profile["general"]["loggingLevel"] except KeyError as e: logLevelName = None if log.isEnabledFor(log.DEBUG) or (logLevelName and DEBUG >= levelNames.get(logLevelName)): # Log at level info to ensure that the profile is logged. log.info(u"Config loaded (after upgrade, and in the state it will be used by NVDA):\n{0}".format(profile)) return profile