本文整理汇总了Python中mi.idk.comm_config.CommConfig.get_config_from_type方法的典型用法代码示例。如果您正苦于以下问题:Python CommConfig.get_config_from_type方法的具体用法?Python CommConfig.get_config_from_type怎么用?Python CommConfig.get_config_from_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mi.idk.comm_config.CommConfig
的用法示例。
在下文中一共展示了CommConfig.get_config_from_type方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_8_config_read_multi
# 需要导入模块: from mi.idk.comm_config import CommConfig [as 别名]
# 或者: from mi.idk.comm_config.CommConfig import get_config_from_type [as 别名]
def test_8_config_read_multi(self):
# create an ethernet config
self.test_4_config_write_ethernet()
ethernet_config = CommConfig.get_config_from_type(self.config_file(), ConfigTypes.ETHERNET)
# stuff it into a multi-comm config
config = { 'comm': {'method': 'multi', 'configs': {'test': {'comm': ethernet_config.dict()}}}}
# dump the new config to a file
open(self.config_file(), 'wb').write(yaml.dump(config))
# load the config from file, verify the embedded config matches the original ethernet config
multi_config = CommConfig.get_config_from_type(self.config_file(), ConfigTypes.MULTI)
self.assertEqual(multi_config.configs['test'].dict(), ethernet_config.dict())
示例2: test_config_read_ethernet
# 需要导入模块: from mi.idk.comm_config import CommConfig [as 别名]
# 或者: from mi.idk.comm_config.CommConfig import get_config_from_type [as 别名]
def test_config_read_ethernet(self):
config = CommConfig.get_config_from_type(self.config_file(), "ethernet")
self.assertEqual(config.device_addr, 'localhost')
self.assertEqual(config.device_port, 1000)
self.assertEqual(config.server_addr, 'localhost')
self.assertEqual(config.server_port, 2000)
示例3: test_6_config_write_serial
# 需要导入模块: from mi.idk.comm_config import CommConfig [as 别名]
# 或者: from mi.idk.comm_config.CommConfig import get_config_from_type [as 别名]
def test_6_config_write_serial(self):
log.debug("Config File: %s" % self.config_file())
if exists(self.config_file()):
log.debug(" -- remove %s" % self.config_file())
remove(self.config_file())
self.assertFalse(exists(self.config_file()))
config = CommConfig.get_config_from_type(self.config_file(), ConfigTypes.SERIAL)
config.device_os_port = DEVICE_OS_PORT
config.device_baud = DEVICE_BAUD
config.device_data_bits = DEVICE_DATA_BITS
config.device_parity = DEVICE_PARITY
config.device_stop_bits = DEVICE_STOP_BITS
config.device_flow_control = DEVICE_FLOW_CONTROL
config.data_port = DATA_PORT
config.command_port = COMMAND_PORT
log.debug("CONFIG: %s" % config.serialize())
config.store_to_file()
# order isnt the same, so lets turn it into an array of label: value's then sort and compare.
self.assertEqual(sorted(string.replace(self.config_serial_content(), "\n", '').split(' ')),
sorted(string.replace(self.read_config(), "\n", '').split(' ')))
示例4: test_5_config_read_ethernet
# 需要导入模块: from mi.idk.comm_config import CommConfig [as 别名]
# 或者: from mi.idk.comm_config.CommConfig import get_config_from_type [as 别名]
def test_5_config_read_ethernet(self):
config = CommConfig.get_config_from_type(self.config_file(), ConfigTypes.ETHERNET)
self.assertEqual(config.device_addr, INSTRUMENT_ADDR)
self.assertEqual(config.device_port, INSTRUMENT_PORT)
self.assertEqual(config.data_port, DATA_PORT)
self.assertEqual(config.command_port, COMMAND_PORT)
示例5: test_7_config_read_serial
# 需要导入模块: from mi.idk.comm_config import CommConfig [as 别名]
# 或者: from mi.idk.comm_config.CommConfig import get_config_from_type [as 别名]
def test_7_config_read_serial(self):
config = CommConfig.get_config_from_type(self.config_file(), ConfigTypes.SERIAL)
self.assertEqual(config.device_os_port, DEVICE_OS_PORT)
self.assertEqual(config.device_baud, DEVICE_BAUD)
self.assertEqual(config.device_data_bits, DEVICE_DATA_BITS)
self.assertEqual(config.device_parity, DEVICE_PARITY)
self.assertEqual(config.device_stop_bits, DEVICE_STOP_BITS)
self.assertEqual(config.device_flow_control, DEVICE_FLOW_CONTROL)
self.assertEqual(config.data_port, DATA_PORT)
self.assertEqual(config.command_port, COMMAND_PORT)
示例6: test_config_write_ethernet
# 需要导入模块: from mi.idk.comm_config import CommConfig [as 别名]
# 或者: from mi.idk.comm_config.CommConfig import get_config_from_type [as 别名]
def test_config_write_ethernet(self):
log.debug("Config File: %s" % self.config_file())
if exists(self.config_file()):
log.debug(" -- remove %s" % self.config_file())
remove(self.config_file())
self.assertFalse(exists(self.config_file()))
config = CommConfig.get_config_from_type(self.config_file(), "ethernet")
config.device_addr = 'localhost'
config.device_port = 1000
config.server_addr = 'localhost'
config.server_port = 2000
log.debug("CONFIG: %s" % config.serialize())
config.store_to_file()
self.assertEqual(self.config_content(), self.read_config())
示例7: test_config_write_ethernet
# 需要导入模块: from mi.idk.comm_config import CommConfig [as 别名]
# 或者: from mi.idk.comm_config.CommConfig import get_config_from_type [as 别名]
def test_config_write_ethernet(self):
log.debug("Config File: %s" % self.config_file())
if exists(self.config_file()):
log.debug(" -- remove %s" % self.config_file())
remove(self.config_file())
self.assertFalse(exists(self.config_file()))
config = CommConfig.get_config_from_type(self.config_file(), "ethernet")
config.device_addr = INSTRUMENT_ADDR
config.device_port = INSTRUMENT_PORT
config.data_port = DATA_PORT
config.command_port = COMMAND_PORT
log.debug("CONFIG: %s" % config.serialize())
config.store_to_file()
self.assertEqual(self.config_content(), self.read_config())
示例8: test_4_config_write_ethernet
# 需要导入模块: from mi.idk.comm_config import CommConfig [as 别名]
# 或者: from mi.idk.comm_config.CommConfig import get_config_from_type [as 别名]
def test_4_config_write_ethernet(self):
log.debug("Config File: %s" % self.config_file())
if exists(self.config_file()):
log.debug(" -- remove %s" % self.config_file())
remove(self.config_file())
self.assertFalse(exists(self.config_file()))
config = CommConfig.get_config_from_type(self.config_file(), ConfigTypes.ETHERNET)
config.device_addr = INSTRUMENT_ADDR
config.device_port = INSTRUMENT_PORT
config.data_port = DATA_PORT
config.command_port = COMMAND_PORT
log.debug("CONFIG: %s" % config.serialize())
config.store_to_file()
# order isnt the same, so lets turn it into an array of label: value's then sort and compare.
self.assertEqual(sorted(string.replace(self.config_ethernet_content(), "\n", '').split(' ')),
sorted(string.replace(self.read_config(), "\n", '').split(' ')))
示例9: CommConfig
# 需要导入模块: from mi.idk.comm_config import CommConfig [as 别名]
# 或者: from mi.idk.comm_config.CommConfig import get_config_from_type [as 别名]
log.debug("caught error %s" % e)
error = e
self.assertTrue(error)
error = None
try:
config = CommConfig()
config.store_to_file();
except NoConfigFileSpecified, e:
log.debug("caught error %s" % e)
error = e
self.assertTrue(error)
error = None
try:
config = CommConfig.get_config_from_type(self.config_file(), "foo")
except InvalidCommType, e:
log.debug("caught error %s" % e)
error = e
self.assertTrue(error)
def test_comm_config_type_list(self):
types = CommConfig.valid_type_list()
log.debug( "types: %s" % types)
known_types = ['ethernet']
self.assertEqual(sorted(types), sorted(known_types))
def test_config_write_ethernet(self):
log.debug("Config File: %s" % self.config_file())