From: Tomas Babej Date: Sat, 7 Feb 2015 11:18:59 +0000 (+0100) Subject: TaskWarrior: Add keyword argument to supress failure in execute_command X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/commitdiff_plain/2ef4751c25fbbced996deed6e17bd5bae7a5fdd7?ds=sidebyside;hp=843561147d85899271c128015d1e098c8484c81e TaskWarrior: Add keyword argument to supress failure in execute_command --- diff --git a/tasklib/task.py b/tasklib/task.py index 73280b0..2a51b35 100644 --- a/tasklib/task.py +++ b/tasklib/task.py @@ -777,14 +777,14 @@ 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={}): + def execute_command(self, args, config_override={}, allow_failure=True): command_args = self._get_command_args( args, config_override=config_override) logger.debug(' '.join(command_args)) p = subprocess.Popen(command_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = [x.decode('utf-8') for x in p.communicate()] - if p.returncode: + if p.returncode and allow_failure: if stderr.strip(): error_msg = stderr.strip().splitlines()[-1] else: