本文整理汇总了Python中mi.idk.comm_config.CommConfig.get_config_from_file方法的典型用法代码示例。如果您正苦于以下问题:Python CommConfig.get_config_from_file方法的具体用法?Python CommConfig.get_config_from_file怎么用?Python CommConfig.get_config_from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mi.idk.comm_config.CommConfig
的用法示例。
在下文中一共展示了CommConfig.get_config_from_file方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from mi.idk.comm_config import CommConfig [as 别名]
# 或者: from mi.idk.comm_config.CommConfig import get_config_from_file [as 别名]
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)
示例2: overwrite
# 需要导入模块: from mi.idk.comm_config import CommConfig [as 别名]
# 或者: from mi.idk.comm_config.CommConfig import get_config_from_file [as 别名]
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)
示例3: get_comm_config
# 需要导入模块: from mi.idk.comm_config import CommConfig [as 别名]
# 或者: from mi.idk.comm_config.CommConfig import get_config_from_file [as 别名]
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)
示例4: init_comm_config
# 需要导入模块: from mi.idk.comm_config import CommConfig [as 别名]
# 或者: from mi.idk.comm_config.CommConfig import get_config_from_file [as 别名]
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)
示例5: _init_test
# 需要导入模块: from mi.idk.comm_config import CommConfig [as 别名]
# 或者: from mi.idk.comm_config.CommConfig import get_config_from_file [as 别名]
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())
示例6: _get_file
# 需要导入模块: from mi.idk.comm_config import CommConfig [as 别名]
# 或者: from mi.idk.comm_config.CommConfig import get_config_from_file [as 别名]
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