From: Tomas Babej Date: Sun, 22 Mar 2015 21:51:47 +0000 (+0100) Subject: TaskWarrior: Add a way to obtain stdout, stderr and returncode from executed command X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/commitdiff_plain/e111a723be6f1ba127e7840e6e5417e693167aba?ds=sidebyside TaskWarrior: Add a way to obtain stdout, stderr and returncode from executed command --- 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