• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python comm_config.CommConfig类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mi.idk.comm_config.CommConfig的典型用法代码示例。如果您正苦于以下问题:Python CommConfig类的具体用法?Python CommConfig怎么用?Python CommConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了CommConfig类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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"
开发者ID:ccenter,项目名称:marine-integrations,代码行数:26,代码来源:run_instrument.py


示例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()
开发者ID:JeffRoy,项目名称:marine-integrations,代码行数:7,代码来源:start_driver.py


示例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)
开发者ID:newbrough,项目名称:marine-integrations,代码行数:29,代码来源:nose_test.py


示例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)
开发者ID:JeffRoy,项目名称:marine-integrations,代码行数:8,代码来源:start_driver.py


示例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())
开发者ID:aplmmilcic,项目名称:mi-instrument,代码行数:11,代码来源:test_comm_config.py


示例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())
开发者ID:ccenter,项目名称:marine-integrations,代码行数:14,代码来源:nose_test.py


示例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)
开发者ID:newbrough,项目名称:marine-integrations,代码行数:7,代码来源:test_comm_config.py


示例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))
开发者ID:newbrough,项目名称:marine-integrations,代码行数:7,代码来源:test_comm_config.py


示例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('  ')))
开发者ID:aplmmilcic,项目名称:mi-instrument,代码行数:25,代码来源:test_comm_config.py


示例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)
开发者ID:aplmmilcic,项目名称:mi-instrument,代码行数:7,代码来源:test_comm_config.py


示例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))
开发者ID:aplmmilcic,项目名称:mi-instrument,代码行数:7,代码来源:test_comm_config.py


示例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)
开发者ID:aplmmilcic,项目名称:mi-instrument,代码行数:11,代码来源:test_comm_config.py


示例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
开发者ID:JeffRoy,项目名称:marine-integrations,代码行数:21,代码来源:watch_data_log.py


示例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)
开发者ID:JeffRoy,项目名称:marine-integrations,代码行数:12,代码来源:da_server.py


示例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)
开发者ID:tgiguere,项目名称:marine-integrations,代码行数:12,代码来源:unit_test.py


示例16: comm_config_file

 def comm_config_file(cls):
     """
     @brief Return the path the the driver comm config yaml file.
     @return if comm_config.yml exists return the full path
     """
     repo_dir = Config().get('working_repo')
     driver_path = cls.test_config.driver_module
     p = re.compile('\.')
     driver_path = p.sub('/', driver_path)
     abs_path = "%s/%s/%s" % (repo_dir, os.path.dirname(driver_path), CommConfig.config_filename())
     
     log.debug(abs_path)
     return abs_path
开发者ID:tgiguere,项目名称:marine-integrations,代码行数:13,代码来源:unit_test.py


示例17: test_config_write_ethernet

 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())
开发者ID:swarbhanu,项目名称:marine-integrations,代码行数:19,代码来源:test_comm_config.py


示例18: test_config_write_ethernet

 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())
开发者ID:newbrough,项目名称:marine-integrations,代码行数:19,代码来源:test_comm_config.py


示例19: test_4_config_write_ethernet

    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('  ')))
开发者ID:aplmmilcic,项目名称:mi-instrument,代码行数:21,代码来源:test_comm_config.py


示例20: CommConfig

     except CommConfigReadFail, e:
         error = e
     self.assertFalse(error)
     
     error = None
     try:
         config = CommConfig()
         config.read_from_file("/tmp");
     except CommConfigReadFail, e:
         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):
开发者ID:newbrough,项目名称:marine-integrations,代码行数:31,代码来源:test_comm_config.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python unit_test.DataSetTestCase类代码示例发布时间:2022-05-27
下一篇:
Python test_parser.ParserUnitTestCase类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap