diff --git a/pyros_interfaces_common/basenode.py b/pyros_interfaces_common/basenode.py index 5d1a955..baddbf1 100644 --- a/pyros_interfaces_common/basenode.py +++ b/pyros_interfaces_common/basenode.py @@ -20,8 +20,9 @@ class PyrosBase(pyzmp.Node): def __init__(self, name=None, - interface_class=None, + socket_bind=None, context_manager=None, + interface_class=None, args=None, kwargs=None, instance_path=None, @@ -30,6 +31,8 @@ def __init__(self, default_config=None): """ :param name: name of the node + :param socket_bind: the url string to be passed to underlying network system so that the node is binding to this socket. + It will allow a client starting later to communicate with that node. :param interface_class: the class of the interface to instantiate (in child process) OR a tuple (module_name, class_name), useful if the module should be imported only in child process OR a tuple (package_name, module_name, class_name), usseful if the module name is relative @@ -46,11 +49,6 @@ def __init__(self, :param default_config: a dict containing the values to use as default configuration values :return: """ - super(PyrosBase, self).__init__(name or 'pyros', context_manager=context_manager, args=args or (), kwargs=kwargs or {}) - - self.last_update = 0 - self.update_interval = 1 # seconds to wait between each update - # we delegate config related behavior (including defaults) self.config_handler = ConfigHandler( name or 'pyros', @@ -60,6 +58,19 @@ def __init__(self, default_config=default_config, ) + # TODO : get socket_bind address from config file + + super(PyrosBase, self).__init__( + name or 'pyros', + socket_bind=socket_bind or "ipc:///tmp/pyros/zmp-services.pipe", # for now defaults to IPC for ZMQ (only works locally) + context_manager=context_manager, + args=args or (), + kwargs=kwargs or {} + ) + + self.last_update = 0 + self.update_interval = 1 # seconds to wait between each update + self.provides(self.msg_build) # BWCOMPAT self.provides(self.topic) @@ -75,7 +86,6 @@ def __init__(self, self.provides(self.params) self.provides(self.setup) - if not isinstance(interface_class, tuple) and not ( # TODO : we should pre check all the used members are present... hasattr(interface_class, 'services') @@ -175,9 +185,7 @@ def start(self, timeout=None): :return: None """ - super(PyrosBase, self).start(timeout=timeout) - # Because we currently use this to setup connection - return self.name + return super(PyrosBase, self).start(timeout=timeout) @abc.abstractmethod def setup(self, *args, **kwargs): diff --git a/pyros_interfaces_mock/tests/test_pyros_mock.py b/pyros_interfaces_mock/tests/test_pyros_mock.py index a3afa42..1f66c7c 100644 --- a/pyros_interfaces_mock/tests/test_pyros_mock.py +++ b/pyros_interfaces_mock/tests/test_pyros_mock.py @@ -395,11 +395,11 @@ def test_echo_service(): class TestPyrosMockProcess(object): - def setUp(self): + def setup_class(self): self.mockInstance = PyrosMock() self.mockInstance.start() - def tearDown(self): + def teardown_class(self): self.mockInstance.shutdown() def test_msg_build(self): diff --git a/setup.py b/setup.py index eeb1d3e..600c7c8 100644 --- a/setup.py +++ b/setup.py @@ -207,7 +207,7 @@ def run(self): 'tblib', # this might not always install six (latest version does not) 'six', 'pyzmq', - 'pyzmp>=0.0.14', # lets match the requirement in package.xml (greater than) + 'pyzmp>0.0.15', # lets match the requirement in package.xml (greater than) 'pyros_setup>=0.1.5', # Careful : pyros-setup < 0.0.8 might already be installed as a deb in /opt/ros/indigo/lib/python2.7/dist-packages/ => we still need to force hte install in the venv to have permissions to create hte configuration file... 'pyros_config>=0.1.4', 'nose>=1.3.7',