コード例 #1
0
ファイル: test_service_call.py プロジェクト: froj/simplerpc
    def test_service_call(self, create_connection):
        """
        Check that we correctly send the call.
        """
        create_connection.return_value = Mock()
        create_connection.return_value.recv = Mock(return_value=b'')

        adress = ('127.0.0.1', 20001)
        method_name = 'foo'
        method_params = [12]

        expected_data = service_call.encode_call(method_name, method_params)

        service_call.call(adress, method_name, method_params)

        create_connection.assert_any_call(adress)
        create_connection.return_value.sendall.assert_any_call(expected_data)
コード例 #2
0
    def test_service_call(self, create_connection):
        """
        Check that we correctly send the call.
        """
        create_connection.return_value = Mock()
        create_connection.return_value.recv = Mock(
            return_value=msgpack.packb(None))

        adress = ('127.0.0.1', 20001)
        method_name = 'foo'
        method_params = [12]

        expected_data = service_call.encode_call(method_name, method_params)

        service_call.call(adress, method_name, method_params)

        create_connection.assert_any_call(adress)
        create_connection.return_value.sendall.assert_any_call(expected_data)
コード例 #3
0
    def test_service_call_answer(self, create_connection):
        """
        Check that the service call is correctly answered.
        """
        create_connection.return_value = Mock()
        adress = ('127.0.0.1', 20001)
        return_data = msgpack.packb([1, 'bar'])

        create_connection.return_value.recv = Mock(return_value=return_data)

        result = service_call.call(adress, 'foo')
        self.assertEqual(result, [1, 'bar'])
コード例 #4
0
ファイル: test_service_call.py プロジェクト: froj/simplerpc
    def test_service_call_answer(self, create_connection):
        """
        Check that the service call is correctly answered.
        """
        create_connection.return_value = Mock()
        adress = ('127.0.0.1', 20001)
        return_data = msgpack.packb(1)+msgpack.packb('bar')

        create_connection.return_value.recv = Mock(return_value=return_data)

        result = service_call.call(adress, 'foo')
        self.assertEqual(result, (1, 'bar'))
コード例 #5
0
ファイル: leds.py プロジェクト: SyrianSpock/master-firmware
def set_led(host, led, state):
    """
    Sets the given LED on the given host.

    if led is an iterable but not a string (array for example), every LED in
    the iterable will be set to state.
    """
    if isinstance(led, str):
        res = service_call.call(host, 'led_set', [led, state])
        if res:
            raise RuntimeError("Error setting LED: {}".format(str(res)))
    else:
        for i in led:
            set_led(host, i, state)
コード例 #6
0
from cvra_rpc.service_call import call
import argparse

parser = argparse.ArgumentParser(
    description="Reboot all the nodes connected to the UAVCAN bus.")
parser.add_argument("master", help="IP of the master board.")
parser.add_argument("--port",
                    "-p",
                    type=int,
                    help="SimpleRPC port to use.",
                    default=20001)

parser.add_argument("ids",
                    metavar='DEVICEID',
                    nargs='*',
                    type=int,
                    help="Device IDs to reboot")
parser.add_argument('-a',
                    '--all',
                    help="Try to scan all network.",
                    action='store_true')

args = parser.parse_args()

if args.all:
    call((args.master, args.port), "reboot_node", [255])
else:
    call((args.master, args.port), "reboot_node", args.ids)
コード例 #7
0
from cvra_rpc.service_call import call
import argparse

parser = argparse.ArgumentParser(description="Reboot all the nodes connected to the UAVCAN bus.")
parser.add_argument("master", help="IP of the master board.")
parser.add_argument("--port", "-p", type=int,
                    help="SimpleRPC port to use.", default=20001)

parser.add_argument("ids", metavar='DEVICEID', nargs='*', type=int, help="Device IDs to reboot")
parser.add_argument('-a', '--all', help="Try to scan all network.", action='store_true')

args = parser.parse_args()

if args.all:
    call((args.master, args.port), "reboot_node", [255])
else:
    call((args.master, args.port), "reboot_node", args.ids)

コード例 #8
0
def create_actuator(name):
    return call((HOST, 20001), 'actuator_create_driver', [name])
コード例 #9
0
from cvra_rpc.service_call import call
import argparse

parser = argparse.ArgumentParser(description="Reboot all the nodes connected to the UAVCAN bus.")
parser.add_argument("master", help="IP of the master board.")
parser.add_argument("--port", "-p", type=int,
                    help="SimpleRPC port to use.", default=20001)

parser.add_argument("--node", "-n", type=int, help="ID of the node to reboot (default: all).", default=255)

args = parser.parse_args()

call((args.master, args.port), "reboot_node", [args.node])