[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:
parent
d66087a768
commit
c1123fa083
1 changed files with 7 additions and 3 deletions
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue