我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用oslo_config.cfg.Opt()。
def module_hcsr04(): OPTS = [ cfg.Opt('trigger_pin', short='t', help='Trigger pin'), cfg.Opt('echo_pin', short='e', help='Echo pin'), ] config = _config(HCSR04_MODULE, OPTS) if config['config']['module']['module']['trigger_pin'] is None: raise ValueError("Trigger pin must be set.") if config['config']['module']['module']['echo_pin'] is None: raise ValueError("Echo pin must be set.") manager = ModuleManager(**config) manager.run()
def module_l293d(): OPTS = [ cfg.Opt('power_pin', short='a', help='L293D pin 1 or pin 9: On or off'), cfg.Opt('forward_pin', short='b', help='L293D pin 2 or pin 10: Anticlockwise positive'), cfg.Opt('backward_pin', short='c', help='L293D pin 7 or pin 15: Clockwise positive'), ] config = _config(L293D_MODULE, OPTS) if config['config']['module']['module']['power_pin'] is None: raise ValueError("Power pin must be set.") if config['config']['module']['module']['forward_pin'] is None: raise ValueError("Forward pin must be set.") if config['config']['module']['module']['backward_pin'] is None: raise ValueError("Backward pin must be set.") manager = ModuleManager(**config) manager.run()
def module_servo(): OPTS = [ cfg.Opt('data_pin', short='p', default=None, help='Module GPIO pin'), cfg.Opt('angle', short='a', default=90) ] config = _config(SERVO_MODULE, OPTS) manager = ModuleManager(**config) manager.run() # BLE modules
def test_list_opts(self): for group, opt_list in opts.list_opts(): if isinstance(group, six.string_types): self.assertEqual(group, 'DEFAULT') else: self.assertIsInstance(group, cfg.OptGroup) for opt in opt_list: self.assertIsInstance(opt, cfg.Opt)
def test_list_opts(self): for group, opt_list in opts.list_opts(): if isinstance(group, six.string_types): self.assertEqual('DEFAULT', group) else: self.assertIsInstance(group, cfg.OptGroup) for opt in opt_list: self.assertIsInstance(opt, cfg.Opt)
def module_ds18(): OPTS = [ cfg.Opt('type', short='t', default="ds18b20", help='Specific type of Dallas DS18 family midule.'), cfg.Opt('addr', short='a', default='0', help='Specific module address at 1-wire bus.') ] config = _config(DS18_MODULE, OPTS) manager = ModuleManager(**config) manager.run()