From e111a723be6f1ba127e7840e6e5417e693167aba Mon Sep 17 00:00:00 2001 From: Tomas Babej Date: Sun, 22 Mar 2015 22:51:47 +0100 Subject: [PATCH] TaskWarrior: Add a way to obtain stdout, stderr and returncode from executed command --- tasklib/task.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tasklib/task.py b/tasklib/task.py index aa26729..bb53517 100644 --- a/tasklib/task.py +++ b/tasklib/task.py @@ -910,7 +910,8 @@ class TaskWarrior(object): stdout, stderr = [x.decode('utf-8') for x in p.communicate()] return stdout.strip('\n') - def execute_command(self, args, config_override={}, allow_failure=True): + def execute_command(self, args, config_override={}, allow_failure=True, + return_all=False): command_args = self._get_command_args( args, config_override=config_override) logger.debug(' '.join(command_args)) @@ -923,7 +924,14 @@ class TaskWarrior(object): else: error_msg = stdout.strip() raise TaskWarriorException(error_msg) - return stdout.rstrip().split('\n') + + # Return all whole triplet only if explicitly asked for + if not return_all: + return stdout.rstrip().split('\n') + else: + return (stdout.rstrip().split('\n'), + stderr.rstrip().split('\n'), + p.returncode) def enforce_recurrence(self): # Run arbitrary report command which will trigger generation -- 2.39.5