diff options
Diffstat (limited to 'rumba/storyboard.py')
-rw-r--r-- | rumba/storyboard.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/rumba/storyboard.py b/rumba/storyboard.py index c6da6cb..6d9739c 100644 --- a/rumba/storyboard.py +++ b/rumba/storyboard.py @@ -729,25 +729,30 @@ class StoryBoard(_SBEntity): action = functools.partial(self.run_command, node, command) self._script.add_event(Event(action, ev_time=t)) - def run_command(self, node, command): + def run_command(self, nodes, command): """ - Runs a command (or several) on a given node, immediately. + Runs a command (or several) on a given (set of) node(s), immediately. - :param node: the node on which the command should be run - :type node: `rumba.model.Node` or `str` + :param nodes: the nodes on which the command should be run + :type nodes: `rumba.model.Node` or `str` or a list of these :param command: the command(s) to be run :type command: `str` or `list` of `str` """ if self.experiment is None: raise ValueError("Experiment needed to run commands.") - if isinstance(node, str): - node = self.node_map[node] - if node not in self.experiment.nodes: - raise ValueError('Cannot run command on node %s, ' - 'not in experiment.' % (node.name,)) - if isinstance(command, str): - command = [command] - node.execute_commands(command) + if not isinstance(nodes, list): + _nodes = [nodes] + else: + _nodes = nodes + for _node in _nodes: + if isinstance(_node, str): + _node = self.node_map[_node] + if _node not in self.experiment.nodes: + raise ValueError('Cannot run command on node %s, ' + 'not in experiment.' % (_node.name,)) + if isinstance(command, str): + command = [command] + _node.execute_commands(command) def add_event(self, event): """ |