当前位置: 首页>>代码示例>>Python>>正文


Python port_agent_process.PortAgentProcess类代码示例

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


在下文中一共展示了PortAgentProcess类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_missing_config

    def test_missing_config(self):
        """
        Test if a required config parameter is missing
        """
        config = {'device_addr': 'localhost'}

        with self.assertRaises(PortAgentMissingConfig):
            process = PortAgentProcess.get_process(config, timeout = TEST_TIMEOUT, test_mode=True)

        config = {'device_port': '921'}

        with self.assertRaises(PortAgentMissingConfig):
            process = PortAgentProcess.get_process(config, timeout = TEST_TIMEOUT, test_mode=True)
开发者ID:ednad,项目名称:coi-services,代码行数:13,代码来源:test_port_agent_process.py

示例2: start_pagent

    def start_pagent(self):
        """
        Construct and start the port agent.
        @retval port Port that was used for connection to agent
        """
        # Create port agent object.
        comm_config = self.comm_config

        config = {
            'device_addr' : comm_config.device_addr,
            'device_port' : comm_config.device_port,

            'command_port': comm_config.command_port,
            'data_port': comm_config.data_port,

            'process_type': PortAgentProcessType.UNIX,
            'log_level': 5,
        }

        self._pagent = PortAgentProcess.launch_process(config, timeout = 60, test_mode = True)
        pid = self._pagent.get_pid()
        port = self._pagent.get_data_port()

        log.info('Started port agent pid %d listening at port %d', pid, port)

        # Configure driver to use port agent port number.
        DVR_CONFIG['comms_config'] = {
            'addr' : 'localhost',
            'port' : port
        }

        return port
开发者ID:ccenter,项目名称:marine-integrations,代码行数:32,代码来源:run_instrument.py

示例3: test_driver_process

    def test_driver_process(self):
        """
        Test port agent process launch with default values and a good host and port
        """
        process = PortAgentProcess.get_process(self._port_config, test_mode=True)
        self.assertTrue(process)
        self.assertTrue(isinstance(process, PythonPortAgentProcess))

        # Verify config
        self.assertEqual(process._device_addr, self._port_config.get("device_addr"))
        self.assertEqual(process._device_port, self._port_config.get("device_port"))
        self.assertEqual(process._working_dir, '/tmp/')
        self.assertEqual(process._delimiter, ['<<','>>'])

        # Try start
        process.launch()

        # Check that it launched properly
        self.assertTrue(process.get_pid() > 0)
        self.assertTrue(process.get_data_port())
        # Python logger has no command port
        self.assertEqual(process.get_command_port(), None)

        process.stop()
        self.assertFalse(process.get_pid())
开发者ID:ednad,项目名称:coi-services,代码行数:25,代码来源:test_port_agent_process.py

示例4: test_nolaunch_process

    def test_nolaunch_process(self):
        """
        Test the port agent doesn't launch when the port agent address is not localhost
        """
        self._port_config['port_agent_addr'] = 'somewhere.else'

        process = PortAgentProcess.get_process(self._port_config, test_mode=True)
        self.assertTrue(process)
        self.assertTrue(isinstance(process, UnixPortAgentProcess))

        # Verify config
        self.assertEqual(process._device_addr, self._port_config.get("device_addr"))
        self.assertEqual(process._device_port, self._port_config.get("device_port"))
        self.assertEqual(process._binary_path, self._port_config.get("binary_path"))
        self.assertEqual(process._command_port, self._port_config.get("command_port"))
        self.assertEqual(process._data_port, self._port_config.get("data_port"))
        self.assertEqual(process._log_level, self._port_config.get("log_level"))
        self.assertEqual(process._pa_addr, self._port_config.get("port_agent_addr"))

        process.stop()
        
        # Try start
        process.launch()

        # Check that it launched properly
        self.assertFalse(process.get_pid())
        self.assertTrue(process.get_data_port(), PORT_AGENT_DATA_PORT)
        self.assertEqual(process.get_command_port(), PORT_AGENT_COMMAND_PORT)

        process.stop()
开发者ID:ednad,项目名称:coi-services,代码行数:30,代码来源:test_port_agent_process.py

示例5: test_launch_process

    def test_launch_process(self):
        """
        Test port agent process launch with default values and a good host and port
        """
        process = PortAgentProcess.get_process(self._port_config, test_mode=True)
        self.assertTrue(process)
        self.assertTrue(isinstance(process, UnixPortAgentProcess))

        # Verify config
        self.assertEqual(process._device_addr, self._port_config.get("device_addr"))
        self.assertEqual(process._device_port, self._port_config.get("device_port"))
        self.assertEqual(process._binary_path, self._port_config.get("binary_path"))
        self.assertEqual(process._command_port, self._port_config.get("command_port"))
        self.assertEqual(process._data_port, self._port_config.get("data_port"))
        self.assertEqual(process._log_level, self._port_config.get("log_level"))

        process.stop()

        # Try start
        process.launch()

        # Check that it launched properly
        self.assertTrue(process.get_pid() > 0)
        self.assertTrue(process.get_data_port(), PORT_AGENT_DATA_PORT)
        self.assertEqual(process.get_command_port(), PORT_AGENT_COMMAND_PORT)

        process.stop()
开发者ID:ednad,项目名称:coi-services,代码行数:27,代码来源:test_port_agent_process.py

示例6: test_bad_host

    def test_bad_host(self):
        """
        Test the port agent startup with a bad hostname.  This should eventually timeout and raise an
        exception.
        """
        host = '127.0.0.0'
        config = self._port_config
        config['device_addr'] = host

        process = PortAgentProcess.get_process(self._port_config, timeout = TEST_TIMEOUT, test_mode=True)
        self.assertTrue(process)
        self.assertTrue(isinstance(process, PythonPortAgentProcess))

        # Verify config
        self.assertEqual(process._device_addr, host)
        self.assertEqual(process._device_port, self._port_config.get("device_port"))
        self.assertEqual(process._working_dir, '/tmp/')
        self.assertEqual(process._delimiter, ['<<','>>'])

        # Try start
        with self.assertRaises(PortAgentTimeout):
            process.launch()

        # Verify we don't have a process lingering
        self.assertFalse(process.poll())
开发者ID:ednad,项目名称:coi-services,代码行数:25,代码来源:test_port_agent_process.py

示例7: init_port_agent

    def init_port_agent(cls):
        """
        @brief Launch the driver process and driver client.  This is used in the
        integration and qualification tests.  The port agent abstracts the physical
        interface with the instrument.
        @retval return the pid to the logger process
        """
        log.info("Startup Port Agent")

        comm_config = cls.get_comm_config()

        config = {
            'device_addr' : comm_config.device_addr,
            'device_port' : comm_config.device_port
        }

        port_agent = PortAgentProcess.launch_process(config, timeout = 60,
            test_mode = True)

        port = port_agent.get_data_port()
        pid  = port_agent.get_pid()

        log.info('Started port agent pid %s listening at port %s' % (pid, port))

        cls.test_config.port_agent = port_agent
        return port
开发者ID:tgiguere,项目名称:marine-integrations,代码行数:26,代码来源:unit_test.py

示例8: _start_port_agent

    def _start_port_agent(self, instrument_agent_instance_obj=None):
        """
        Construct and start the port agent, ONLY NEEDED FOR INSTRUMENT AGENTS.
        """

        _port_agent_config = instrument_agent_instance_obj.port_agent_config

        # It blocks until the port agent starts up or a timeout
        _pagent = PortAgentProcess.launch_process(_port_agent_config,  test_mode = True)
        pid = _pagent.get_pid()
        port = _pagent.get_data_port()
        cmd_port = _pagent.get_command_port()
        log.info("IMS:_start_pagent returned from PortAgentProcess.launch_process pid: %s ", pid)

        # Hack to get ready for DEMO.  Further though needs to be put int
        # how we pass this config info around.
        host = 'localhost'

        driver_config = instrument_agent_instance_obj.driver_config
        comms_config = driver_config.get('comms_config')
        if comms_config:
            host = comms_config.get('addr')
        else:
            log.warn("No comms_config specified, using '%s'" % host)

        # Configure driver to use port agent port number.
        instrument_agent_instance_obj.driver_config['comms_config'] = {
            'addr' : host,
            'cmd_port' : cmd_port,
            'port' : port
        }
        instrument_agent_instance_obj.driver_config['pagent_pid'] = pid
        self.imsclient.update_instrument_agent_instance(instrument_agent_instance_obj)
        return self.imsclient.read_instrument_agent_instance(instrument_agent_instance_obj._id)
开发者ID:Bobfrat,项目名称:coi-services,代码行数:34,代码来源:test_rsn_platform_instrument.py

示例9: init_port_agent

    def init_port_agent(self):
        """
        @brief Launch the driver process and driver client.  This is used in the
        integration and qualification tests.  The port agent abstracts the physical
        interface with the instrument.
        @retval return the pid to the logger process
        """
        if (self.port_agent):
            log.error("Port agent already initialized")
            return

        log.debug("Startup Port Agent")

        #comm_config = self.get_comm_config()

        config = self.port_agent_config()
        log.debug("port agent config: %s" % config)

        port_agent = PortAgentProcess.launch_process(config, timeout = 60, test_mode = True)

        port = port_agent.get_data_port()
        pid  = port_agent.get_pid()

        log.info('Started port agent pid %s listening at port %s' % (pid, port))

        self.addCleanup(self.stop_port_agent)
        self.port_agent = port_agent
        return port
开发者ID:deverett,项目名称:marine-integrations,代码行数:28,代码来源:test_port_agent_client.py

示例10: init_port_agent

    def init_port_agent(self):
        """
        @brief Launch the driver process and driver client.  This is used in the
        integration and qualification tests.  The port agent abstracts the physical
        interface with the instrument.
        @retval return the pid to the logger process
        """
        log.info("Startup Port Agent")

        config = {
            'device_addr' : self.comm_config.device_addr,
            'device_port' : self.comm_config.device_port,

            'command_port': self.comm_config.command_port,
            'data_port': self.comm_config.data_port,

            'process_type': PortAgentProcessType.UNIX,
            'log_level': 5,
        }

        self.port_agent = PortAgentProcess.launch_process(config, timeout = 60,
            test_mode = True)

        port = self.port_agent.get_data_port()
        pid  = self.port_agent.get_pid()

        log.info('Started port agent pid %s listening at port %s' % (pid, port))

        if self.launch_monitor:
            self.logfile = self.port_agent.port_agent.logfname
            log.info('Started port agent pid %s listening at port %s' % (pid, port))
            log.info("data log: %s" % self.logfile)
            self.monitor_process = launch_data_monitor(self.logfile)
开发者ID:JeffRoy,项目名称:marine-integrations,代码行数:33,代码来源:da_server.py

示例11: start_pagent

    def start_pagent(self):
        """
        Construct and start the port agent.
        @retval port Port that was used for connection to agent
        """
        # Create port agent object.
        config = { 'device_addr' : self.device_addr,
                   'device_port' : self.device_port,

                   'command_port': self.command_port,
                   'data_port': self.data_port,

                   'process_type': PortAgentProcessType.UNIX,
                   'log_level': 5,
                  }

        self._pagent = PortAgentProcess.launch_process(config, timeout = 60, test_mode = True)
        pid = self._pagent.get_pid()
        port = self._pagent.get_data_port()

        if(pid and port):
            mi_logger.info('Started port agent pid %d listening at port %d', pid, port)
        else:
            raise PortAgentLaunchException();
            
        return port
开发者ID:ednad,项目名称:coi-services,代码行数:26,代码来源:driver_int_test_support.py

示例12: test_invalid_type

 def test_invalid_type(self):
     """
     Test with a bogus port agent type. Should raise an exception
     """
     process = None
     config = self._port_config
     config['type'] = 'foo'
     with self.assertRaises(PortAgentLaunchException) as exp:
         process = PortAgentProcess.get_process(config, timeout = TEST_TIMEOUT, test_mode=True)
     self.assertRegexpMatches(str(exp.exception), 'unknown port agent type:')
开发者ID:ednad,项目名称:coi-services,代码行数:10,代码来源:test_port_agent_process.py

示例13: test_driver_launch

    def test_driver_launch(self):
        """
        Test the alternate method for launching a port agent
        """
        process = PortAgentProcess.launch_process(self._port_config, test_mode=True)

        # Check that it launched properly
        self.assertTrue(process.get_pid() > 0)
        self.assertTrue(process.get_data_port())
        # Python logger has no command port
        self.assertEqual(process.get_command_port(), None)

        process.stop()
        self.assertFalse(process.get_pid())
开发者ID:ednad,项目名称:coi-services,代码行数:14,代码来源:test_port_agent_process.py

示例14: test_invalid_process_type

 def test_invalid_process_type(self):
     """
     Test with a bogus process type. Should raise an exception
     """
     process = None
     config = self._port_config
     config["process_type"] = "foo"
     with self.assertRaises(PortAgentLaunchException) as exp:
         process = PortAgentProcess.get_process(config, timeout=TEST_TIMEOUT, test_mode=True)
     self.assertRegexpMatches(
         str(exp.exception),
         ".*unknown port agent process type:.*",
         msg="exception message was " + str(exp.exception),
     )
开发者ID:pombredanne,项目名称:coi-services,代码行数:14,代码来源:test_port_agent_process.py

示例15: start_pagent

    def start_pagent(self):
        """
        Construct and start the port agent.
        @retval port Port that was used for connection to agent
        """
        # Create port agent object.
        config = {
            "device_addr": self.device_addr,
            "device_port": self.device_port,
            "working_dir": self.work_dir,
            "delimiter": self.delim,
        }
        self._pagent = PortAgentProcess.launch_process(config, timeout=60, test_mode=True)
        pid = self._pagent.get_pid()
        port = self._pagent.get_data_port()

        mi_logger.info("Started port agent pid %d listening at port %d", pid, port)
        return port
开发者ID:pombredanne,项目名称:coi-services,代码行数:18,代码来源:driver_int_test_support.py


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