From c1123fa0839257e8d33f0a1d28a5ddb8709e5c0f Mon Sep 17 00:00:00 2001 From: Tobi-wan Kenobi Date: Wed, 23 Nov 2016 18:24:02 +0100 Subject: [PATCH] [output] Accept lists of commands in add_callback Add the possibility to specify a list of commands to be added as callbacks. Commands will be executed one after the other, waiting for the previous command to finish execution. --- bumblebee/output.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bumblebee/output.py b/bumblebee/output.py index 6d29231..952a284 100644 --- a/bumblebee/output.py +++ b/bumblebee/output.py @@ -44,9 +44,13 @@ class Command(object): self._command = command def __call__(self, *args, **kwargs): - cmd = self._command.format(*args, **kwargs) - DEVNULL = open(os.devnull, 'wb') - subprocess.Popen(shlex.split(cmd), stdout=DEVNULL, stderr=DEVNULL) + if not isinstance(self._command, list): + self._command = [ self._command ] + + for cmd in self._command: + c = cmd.format(*args, **kwargs) + DEVNULL = open(os.devnull, 'wb') + subprocess.Popen(shlex.split(c), stdout=DEVNULL, stderr=DEVNULL).communicate() class Output(object): def __init__(self, config):