[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.
This commit is contained in:
Tobi-wan Kenobi 2016-11-23 18:24:02 +01:00
parent d66087a768
commit c1123fa083

View file

@ -44,9 +44,13 @@ class Command(object):
self._command = command
def __call__(self, *args, **kwargs):
cmd = self._command.format(*args, **kwargs)
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(cmd), stdout=DEVNULL, stderr=DEVNULL)
subprocess.Popen(shlex.split(c), stdout=DEVNULL, stderr=DEVNULL).communicate()
class Output(object):
def __init__(self, config):