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


Python Configuration.required方法代码示例

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


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

示例1: get_configs

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import required [as 别名]
    def get_configs(self, path):
        c = Configuration(path=path)
        c.required = {
            'hostname',
            'username',
            'password',
            'vhost',
            'exchange',
            'queue',
        }
        c.accepted = {
            'durable_queue',
            'auto_delete_queue',
            'exchange_type',
            'durable_exchange',
            'auto_delete_exchange',
            'timeout',
        }
        if not c.read():
            raise Exception('Configuration file not set properly.')
        configs = c.result

        if 'durable_queue' in configs:
            configs['durable_queue'] = bool(configs['durable_queue'])
        else:
            configs['durable_queue'] = True

        if 'auto_delete_queue' in configs:
            configs['auto_delete_queue'] = bool(configs['auto_delete_queue'])
        else:
            configs['auto_delete_queue'] = False

        if 'exchange_type' not in configs:
            configs['exchange_type'] = 'fanout'

        if 'durable_exchange' in configs:
            configs['durable_exchange'] = bool(configs['durable_exchange'])
        else:
            configs['durable_exchange'] = True

        if 'auto_delete_exchange' in configs:
            configs['auto_delete_exchange'] = bool(configs['auto_delete_exchange'])
        else:
            configs['auto_delete_exchange'] = False

        if 'timeout' in configs:
            configs['timeout'] = int(configs['timeout'])
        else:
            configs['timeout'] = None

        return configs
开发者ID:davidozhang,项目名称:hoppity,代码行数:53,代码来源:client.py

示例2: vars

# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import required [as 别名]
    parser = argparse.ArgumentParser(
        description=('Create a pool of RabbitMQ/Eventlet workers.'),
    )
    parser.add_argument(
        '-c',
        '--configuration',
        help='Specify the path to the worker.conf file.',
        required=True,
    )
    args = vars(parser.parse_args())

    c = Configuration(path=args['configuration'])
    c.required = {
        'hostname',
        'username',
        'password',
        'vhost',
        'queue',
    }
    c.accepted = {
        'num_threads',
        'timeout',
    }
    if not c.read():
        raise Exception('Configuration file not set properly.')
    configs = c.result

    if 'timeout' in configs:
        configs['timeout'] = int(configs['timeout'])
    else:
        configs['timeout'] = None
开发者ID:davidozhang,项目名称:hoppity,代码行数:33,代码来源:worker.py


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