我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用logging.config.sections()。
def processConfigFile(self, configFile=None): if configFile is not None: self.__serverConfig = ConfigParser.ConfigParser() self.__serverConfig.read(configFile) sections = self.__serverConfig.sections() # Let's check the log file self.__logFile = self.__serverConfig.get('global','log_file') if self.__logFile != 'None': logging.basicConfig(filename = self.__logFile, level = logging.DEBUG, format="%(asctime)s: %(levelname)s: %(message)s", datefmt = '%m/%d/%Y %I:%M:%S %p') # Remove the global one del(sections[sections.index('global')]) self._shares = {} for i in sections: self._shares[i] = dict(self.__serverConfig.items(i))
def getShares(connId, smbServer): config = smbServer.getServerConfig() sections = config.sections() # Remove the global one del(sections[sections.index('global')]) shares = {} for i in sections: shares[i] = dict(config.items(i)) return shares
def read_config(self): # if self.config: # return config = ConfigParser.RawConfigParser() config.read(self.config_file) for s in config.sections(): if s == 'global': if config.has_option(s, 'poll_interval'): self.poll_interval = int(config.get(s, 'poll_interval')) if config.has_option(s, 'newrelic_license_key'): self.license_key = config.get(s, 'newrelic_license_key') continue if not config.has_option(s, 'name') or not config.has_option(s, 'url'): continue ns = NginxStatusCollector(s, config.get(s, 'name'), config.get(s, 'url'), self.poll_interval) if config.has_option(s, 'http_user') and config.has_option(s, 'http_pass'): ns.basic_auth = base64.b64encode(config.get(s, 'http_user') + b':' + config.get(s, 'http_pass')) self.sources.append(ns) self.config = config