本文整理汇总了Python中mi.idk.comm_config.CommConfig类的典型用法代码示例。如果您正苦于以下问题:Python CommConfig类的具体用法?Python CommConfig怎么用?Python CommConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CommConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fetch_comm_config
def fetch_comm_config(self):
"""
@brief collect connection information for the logger from the user
"""
config_path = "%s/%s" % (self.metadata.driver_dir(), CommConfig.config_filename())
self.comm_config = CommConfig.get_config_from_console(config_path)
self.comm_config.display_config()
#self.comm_config.get_from_console()
self.ip_address = self.comm_config.device_addr
self.data_port = self.comm_config.data_port
self.command_port = self.comm_config.command_port
if not (self.ip_address):
self.ip_address = prompt.text( 'Instrument IP Address', self.ip_address )
if not (self.data_port):
continuing = True
while continuing:
sport = prompt.text( 'Instrument Port', self.data_port )
try:
self.data_port = int(sport)
continuing = False
except ValueError as e:
print "Error converting port to number: " + str(e)
print "Please enter a valid port number.\n"
示例2: fetch_comm_config
def fetch_comm_config(self):
"""
@brief collect connection information for the logger from the user
"""
config_path = "%s/%s" % (self.metadata.driver_dir(), CommConfig.config_filename())
self.comm_config = CommConfig.get_config_from_console(config_path)
self.comm_config.get_from_console()
示例3: __init__
def __init__(self, metadata, log_file = None, launch_data_moniotor = False):
"""
@brief Constructor
@param metadata IDK Metadata object
@param log_file File to store test results. If none specified log to STDOUT
"""
repo_dir = Config().get("working_repo")
if(not repo_dir):
raise IDKConfigMissing()
# Ion scripts need to be run from the base os the repo dir so it has access
# to resources using relative pathing. So we just do
os.chdir(repo_dir)
self.metadata = metadata
if(not self.metadata.driver_name):
raise DriverNotStarted()
if( log_file ):
self.log_fh = open(log_file, "w")
else:
self.log_fh = sys.stdout
config_path = "%s/%s" % (self.metadata.driver_dir(), CommConfig.config_filename())
self.comm_config = CommConfig.get_config_from_file(config_path)
if(not self.comm_config):
raise CommConfigReadFail(msg=config_path)
self.test_runner = nose.core.TextTestRunner(stream=self.log_fh)
示例4: overwrite
def overwrite(self):
"""
@brief Overwrite the current files with what is stored in the current metadata file.
"""
self.metadata = Metadata()
config_path = "%s/%s" % (self.metadata.driver_dir(), CommConfig.config_filename())
self.comm_config = CommConfig.get_config_from_file(config_path)
self.generate_code(force = True)
示例5: test_8_config_read_multi
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())
示例6: _init_test
def _init_test(self, metadata):
"""
initialize the test with driver metadata
"""
self.metadata = metadata
if(not self.metadata.driver_name):
raise DriverNotStarted()
config_path = "%s/%s" % (self.metadata.driver_dir(), CommConfig.config_filename())
self.comm_config = CommConfig.get_config_from_file(config_path)
if(not self.comm_config):
raise CommConfigReadFail(msg=config_path)
self._inspect_driver_module(self._driver_test_module())
示例7: test_config_read_ethernet
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)
示例8: test_comm_config_type_list
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))
示例9: test_6_config_write_serial
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(' ')))
示例10: test_5_config_read_ethernet
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)
示例11: test_3_comm_config_type_list
def test_3_comm_config_type_list(self):
types = CommConfig.valid_type_list()
log.debug( "types: %s" % types)
known_types = [ConfigTypes.ETHERNET, ConfigTypes.RSN, ConfigTypes.SERIAL, ConfigTypes.BOTPT, ConfigTypes.MULTI]
self.assertEqual(sorted(types), sorted(known_types))
示例12: test_7_config_read_serial
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)
示例13: _get_file
def _get_file():
"""
build the data file name. Then loop until the file can be open successfully
@return: file pointer to the data file
"""
metadata = Metadata()
config_path = "%s/%s" % (metadata.driver_dir(), CommConfig.config_filename())
comm_config = CommConfig.get_config_from_file(config_path)
date = time.strftime("%Y%m%d")
filename = "%s/port_agent_%d.%s.data" % (DATADIR, comm_config.command_port, date)
file = None
while(not file):
try:
file = open(filename)
except Exception as e:
sys.stderr.write("file open failed: %s\n" % e)
time.sleep(SLEEP)
return file
示例14: init_comm_config
def init_comm_config(self):
"""
@brief Create the comm config object by reading the comm_config.yml file.
"""
log.info("Initialize comm config")
config_file = self.comm_config_file()
log.debug( " -- reading comm config from: %s" % config_file )
if not os.path.exists(config_file):
raise TestNoCommConfig(msg="Missing comm config. Try running start_driver or switch_driver")
self.comm_config = CommConfig.get_config_from_file(config_file)
示例15: get_comm_config
def get_comm_config(cls):
"""
@brief Create the comm config object by reading the comm_config.yml file.
"""
log.info("get comm config")
config_file = cls.comm_config_file()
log.debug( " -- reading comm config from: %s" % config_file )
if not os.path.exists(config_file):
raise TestNoCommConfig(msg="Missing comm config. Try running start_driver or switch_driver")
return CommConfig.get_config_from_file(config_file)