コード例 #1
0
def test_enforce_no_daemon(enforce_daemon_is_running):
    if not is_daemon_running(args=[]):
        assert spawn_daemon(args=[], wait_until_spawned=5.0)
    args = argparse.Namespace(no_daemon=True)
    with NodeStrategy(args=args) as node:
        assert node._daemon_node is None
        assert node._direct_node is not None
コード例 #2
0
ファイル: test_daemon.py プロジェクト: sharp-rmf/ros2cli
def daemon_node():
    if is_daemon_running(args=[]):
        with DaemonNode(args=[]) as node:
            node.system.shutdown()
    assert spawn_daemon(args=[], wait_until_spawned=5.0)
    with DaemonNode(args=[]) as node:
        yield node
コード例 #3
0
ファイル: strategy.py プロジェクト: sharp-rmf/ros2cli
 def __init__(self, args):
     use_daemon = not getattr(args, 'no_daemon', False)
     if use_daemon and is_daemon_running(args):
         self.node = DaemonNode(args)
     else:
         if use_daemon:
             spawn_daemon(args)
         self.node = DirectNode(args)
コード例 #4
0
 def __init__(self, args):
     use_daemon = not getattr(args, 'no_daemon', False)
     if use_daemon and is_daemon_running(args):
         self._daemon_node = DaemonNode(args)
         self._direct_node = None
     else:
         if use_daemon:
             spawn_daemon(args)
         self._direct_node = DirectNode(args)
         self._daemon_node = None
     self._args = args
     self._in_scope = False
コード例 #5
0
ファイル: start.py プロジェクト: yechun1/ros2cli
    def main(self, *, args):
        running = is_daemon_running(args)
        if running:
            print('The daemon is already running')
            return

        spawned = spawn_daemon(args, wait_until_spawned=10.0)
        if spawned:
            print('The daemon has been started')
        else:
            print('Failed to confirm that the daemon started successfully',
                  file=sys.stderr)
            return 1
コード例 #6
0
ファイル: stop.py プロジェクト: yechun1/ros2cli
    def main(self, *, args):
        running = is_daemon_running(args)
        if not running:
            print('The daemon is not running')
            return

        with DaemonNode(args) as daemon:
            try:
                shutdown = daemon.system.shutdown
            except AttributeError:
                return 'Failed to shutdown daemon, ' \
                    'it might be using a different rmw implementation'
            shutdown()
        print('The daemon has been stopped')
コード例 #7
0
ファイル: test_daemon.py プロジェクト: seanyen/ros2cli
def daemon_node():
    if is_daemon_running(args=[]):
        assert shutdown_daemon(args=[], timeout=5.0)
    assert spawn_daemon(args=[], timeout=5.0)
    with DaemonNode(args=[]) as node:
        attempts = 3
        delay_between_attempts = 2  # seconds
        for _ in range(attempts):
            node_names_and_namespaces = node.get_node_names_and_namespaces()
            if [TEST_NODE_NAME,
                    TEST_NODE_NAMESPACE] in node_names_and_namespaces:
                break
            time.sleep(delay_between_attempts)
        else:
            pytest.fail(
                f'daemon failed to discover {TEST_NODE_NAMESPACE}/{TEST_NODE_NAME}'
            )
        yield node
        node.system.shutdown()
コード例 #8
0
def enforce_daemon_is_running():
    if not is_daemon_running(args=[]):
        assert spawn_daemon(args=[], wait_until_spawned=5.0)
    yield
コード例 #9
0
def enforce_no_daemon_is_running():
    if is_daemon_running(args=[]):
        with DaemonNode(args=[]) as node:
            node.system.shutdown()
    yield
コード例 #10
0
ファイル: status.py プロジェクト: seanyen/ros2cli
 def main(self, *, args):
     if is_daemon_running(args):
         print('The daemon is running')
     else:
         print('The daemon is not running')
コード例 #11
0
ファイル: test_strategy.py プロジェクト: seanyen/ros2cli
def enforce_daemon_is_running():
    if not is_daemon_running(args=[]):
        assert spawn_daemon(args=[], timeout=5.0)
    yield
コード例 #12
0
ファイル: test_strategy.py プロジェクト: seanyen/ros2cli
def enforce_no_daemon_is_running():
    if is_daemon_running(args=[]):
        assert shutdown_daemon(args=[], timeout=5.0)
    yield
コード例 #13
0
ファイル: strategy.py プロジェクト: yechun1/ros2cli
 def __init__(self, args):
     if is_daemon_running(args):
         self.node = DaemonNode(args)
     else:
         spawn_daemon(args)
         self.node = DirectNode(args)
コード例 #14
0
ファイル: test_strategy.py プロジェクト: tim-fan/ros2cli
def enforce_no_daemon_is_running():
    if is_daemon_running(args=[]):
        assert shutdown_daemon(args=[], wait_duration=5.0)
    yield