当前位置: 首页>>代码示例>>Python>>正文


Python RawConfigParser.getboolean方法代码示例

本文整理汇总了Python中six.moves.configparser.RawConfigParser.getboolean方法的典型用法代码示例。如果您正苦于以下问题:Python RawConfigParser.getboolean方法的具体用法?Python RawConfigParser.getboolean怎么用?Python RawConfigParser.getboolean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在six.moves.configparser.RawConfigParser的用法示例。


在下文中一共展示了RawConfigParser.getboolean方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from six.moves.configparser import RawConfigParser [as 别名]
# 或者: from six.moves.configparser.RawConfigParser import getboolean [as 别名]
def main():
    parser = build_cli_parser("VirusTotal Connector")
    parser.add_argument("--config", "-c", help="Path to configuration file", default="virustotal.ini")
    args = parser.parse_args()

    inifile = RawConfigParser({
        "vt_api_key": None,
        "retrieve_files": "true",
        "upload_binaries_to_vt": "false",
        "connector_name": "VirusTotal",
        "log_file": None,
    })
    inifile.read(args.config)

    config = {}
    config["vt_api_key"] = inifile.get("bridge", "vt_api_key")
    config["retrieve_files"] = inifile.getboolean("bridge", "retrieve_files")
    config["connector_name"] = inifile.get("bridge", "connector_name")
    config["upload_binaries_to_vt"] = inifile.getboolean("bridge", "upload_binaries_to_vt")

    log_file = inifile.get("bridge", "log_file")
    if log_file:
        file_handler = logging.FileHandler(log_file)
        formatter = logging.Formatter('%(asctime)s %(levelname)s:%(message)s')
        file_handler.setFormatter(formatter)
        file_handler.setLevel(logging.DEBUG)
        logging.getLogger().addHandler(file_handler)

    if not config["vt_api_key"]:
        log.fatal("Cannot start without a valid VirusTotal API key, exiting")
        return 1

    log.info("Configuration:")
    for k, v in iteritems(config):
        log.info("    %-20s: %s" % (k,v))

    api = get_cb_protection_object(args)

    vt = VirusTotalConnector(
        api,
        vt_token=config["vt_api_key"],
        allow_uploads=config["upload_binaries_to_vt"],  # Allow VT connector to upload binary files to VirusTotal
        connector_name=config["connector_name"],
    )

    log.info("Starting VirusTotal processing loop")
    vt.run()
开发者ID:Mr19,项目名称:cbapi-python,代码行数:49,代码来源:virus_total_connector.py

示例2: load_config

# 需要导入模块: from six.moves.configparser import RawConfigParser [as 别名]
# 或者: from six.moves.configparser.RawConfigParser import getboolean [as 别名]
    def load_config(self, environ):
        """Load configuration options

        Options are read from a config file.

        Backwards compatibility:
            - if ConfigFile is not set, opts are loaded from http config
            - if ConfigFile is set, then the http config must not provide Koji options
            - In a future version we will load the default hub config regardless
            - all PythonOptions (except koji.web.ConfigFile) are now deprecated and
              support for them will disappear in a future version of Koji
        """
        cf = environ.get('koji.web.ConfigFile', '/etc/kojiweb/web.conf')
        cfdir = environ.get('koji.web.ConfigDir', '/etc/kojiweb/web.conf.d')
        if cfdir:
            configs = koji.config_directory_contents(cfdir)
        else:
            configs = []
        if cf and os.path.isfile(cf):
            configs.append(cf)
        if configs:
            config = RawConfigParser()
            config.read(configs)
        else:
            raise koji.GenericError("Configuration missing")

        opts = {}
        for name, dtype, default in self.cfgmap:
            key = ('web', name)
            if config and config.has_option(*key):
                if dtype == 'integer':
                    opts[name] = config.getint(*key)
                elif dtype == 'boolean':
                    opts[name] = config.getboolean(*key)
                elif dtype == 'list':
                    opts[name] = [x.strip() for x in config.get(*key).split(',')]
                else:
                    opts[name] = config.get(*key)
            else:
                opts[name] = default
        opts['Secret'] = koji.util.HiddenValue(opts['Secret'])
        self.options = opts
        return opts
开发者ID:mikem23,项目名称:koji-playground,代码行数:45,代码来源:wsgi_publisher.py

示例3: getboolean

# 需要导入模块: from six.moves.configparser import RawConfigParser [as 别名]
# 或者: from six.moves.configparser.RawConfigParser import getboolean [as 别名]
 def getboolean(self, section, option):
     if not self.has_option(section, option):
         return self.DEF_BOOLEAN
     return RawConfigParser.getboolean(self, section, option)
开发者ID:larsks,项目名称:cloud-init,代码行数:6,代码来源:helpers.py

示例4: load_config

# 需要导入模块: from six.moves.configparser import RawConfigParser [as 别名]
# 或者: from six.moves.configparser.RawConfigParser import getboolean [as 别名]
def load_config(environ):
    """Load configuration options

    Options are read from a config file. The config file location is
    controlled by the PythonOption ConfigFile in the httpd config.

    Backwards compatibility:
        - if ConfigFile is not set, opts are loaded from http config
        - if ConfigFile is set, then the http config must not provide Koji options
        - In a future version we will load the default hub config regardless
        - all PythonOptions (except ConfigFile) are now deprecated and support for them
          will disappear in a future version of Koji
    """
    logger = logging.getLogger("koji")
    #get our config file(s)
    cf = environ.get('koji.hub.ConfigFile', '/etc/koji-hub/hub.conf')
    cfdir = environ.get('koji.hub.ConfigDir', '/etc/koji-hub/hub.conf.d')
    if cfdir:
        configs = koji.config_directory_contents(cfdir)
    else:
        configs = []
    if cf and os.path.isfile(cf):
        configs.append(cf)
    if configs:
        config = RawConfigParser()
        config.read(configs)
    else:
        config = None
    cfgmap = [
        #option, type, default
        ['DBName', 'string', None],
        ['DBUser', 'string', None],
        ['DBHost', 'string', None],
        ['DBhost', 'string', None],   # alias for backwards compatibility
        ['DBPort', 'integer', None],
        ['DBPass', 'string', None],
        ['KojiDir', 'string', None],

        ['AuthPrincipal', 'string', None],
        ['AuthKeytab', 'string', None],
        ['ProxyPrincipals', 'string', ''],
        ['HostPrincipalFormat', 'string', None],

        ['DNUsernameComponent', 'string', 'CN'],
        ['ProxyDNs', 'string', ''],

        ['CheckClientIP', 'boolean', True],

        ['LoginCreatesUser', 'boolean', True],
        ['KojiWebURL', 'string', 'http://localhost.localdomain/koji'],
        ['EmailDomain', 'string', None],
        ['NotifyOnSuccess', 'boolean', True],
        ['DisableNotifications', 'boolean', False],

        ['Plugins', 'string', ''],
        ['PluginPath', 'string', '/usr/lib/koji-hub-plugins'],

        ['KojiDebug', 'boolean', False],
        ['KojiTraceback', 'string', None],
        ['VerbosePolicy', 'boolean', False],
        ['EnableFunctionDebug', 'boolean', False],

        ['LogLevel', 'string', 'WARNING'],
        ['LogFormat', 'string', '%(asctime)s [%(levelname)s] m=%(method)s u=%(user_name)s p=%(process)s r=%(remoteaddr)s %(name)s: %(message)s'],

        ['MissingPolicyOk', 'boolean', True],
        ['EnableMaven', 'boolean', False],
        ['EnableWin', 'boolean', False],

        ['RLIMIT_AS', 'string', None],
        ['RLIMIT_CORE', 'string', None],
        ['RLIMIT_CPU', 'string', None],
        ['RLIMIT_DATA', 'string', None],
        ['RLIMIT_FSIZE', 'string', None],
        ['RLIMIT_MEMLOCK', 'string', None],
        ['RLIMIT_NOFILE', 'string', None],
        ['RLIMIT_NPROC', 'string', None],
        ['RLIMIT_OFILE', 'string', None],
        ['RLIMIT_RSS', 'string', None],
        ['RLIMIT_STACK', 'string', None],

        ['MemoryWarnThreshold', 'integer', 5000],
        ['MaxRequestLength', 'integer', 4194304],

        ['LockOut', 'boolean', False],
        ['ServerOffline', 'boolean', False],
        ['OfflineMessage', 'string', None],
    ]
    opts = {}
    for name, dtype, default in cfgmap:
        key = ('hub', name)
        if config and config.has_option(*key):
            if dtype == 'integer':
                opts[name] = config.getint(*key)
            elif dtype == 'boolean':
                opts[name] = config.getboolean(*key)
            else:
                opts[name] = config.get(*key)
            continue
        opts[name] = default
#.........这里部分代码省略.........
开发者ID:mikem23,项目名称:koji-playground,代码行数:103,代码来源:kojixmlrpc.py

示例5: GOAProvidersLoader

# 需要导入模块: from six.moves.configparser import RawConfigParser [as 别名]
# 或者: from six.moves.configparser.RawConfigParser import getboolean [as 别名]
class GOAProvidersLoader(object):
    """
    GOA providers reader
    """
    def __init__(self, providers_file):
        """
        Class initialization
        """
        self.path = providers_file
        self._providers = {}
        self._configparser = RawConfigParser()
        try:
            self._configparser.read(providers_file)
        except IOError as e:
            logging.error(
                'Could not find GOA providers file %s' % providers_file)
            raise e
        except ParsingError as e:
            logging.error(
                'There was an error parsing %s' % providers_file)
            raise e
        except Exception as e:
            logging.error(
                'There was an unknown error parsing %s' % providers_file)
            raise e
        self.read_data()

    def read_data(self):
        for section in self._configparser.sections():
            if section.startswith('Provider '):
                provider = section.split()[1]
                self._providers[provider] = {
                    'name': self.generate_readable_name(provider),
                    'services': {}
                }
                for option in self._configparser.options(section):
                    if option == 'providername':
                        name = self._configparser.get(
                            section, option)
                        self._providers[provider]['name'] = name
                    elif option.endswith('enabled'):
                        service = option[:-7].title() + 'Enabled'
                        name = self.generate_readable_name(service[:-7])
                        enabled = self._configparser.getboolean(
                            section, option)
                        # Generate readable name
                        self._providers[provider]['services'][service] = {
                            'name': name,
                            'enabled': enabled
                        }

    def generate_readable_name(self, identifier):
        """
        Generates readable names for providers and services
        """
        stripped = identifier.strip()
        if stripped:
            return stripped.title().replace('_', ' ')
        else:
            return 'Enabled'

    def get_providers(self):
        return self._providers
开发者ID:fleet-commander,项目名称:fc-admin,代码行数:65,代码来源:goa.py


注:本文中的six.moves.configparser.RawConfigParser.getboolean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。