mirror of
https://github.com/tbabej/taskwiki.git
synced 2025-08-19 15:53:07 +02:00
SelectedTasks: Add _execute_safely method
This commit is contained in:
parent
108f461bf3
commit
b170509c53
1 changed files with 22 additions and 2 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import print_function
|
||||||
|
import itertools
|
||||||
import sys
|
import sys
|
||||||
import vim # pylint: disable=F0401
|
import vim # pylint: disable=F0401
|
||||||
|
|
||||||
|
@ -69,10 +71,28 @@ class SelectedTasks(object):
|
||||||
if not self.tasks:
|
if not self.tasks:
|
||||||
print("No tasks selected.")
|
print("No tasks selected.")
|
||||||
|
|
||||||
|
def _execute_safely(self, *args, **kwargs):
|
||||||
|
kwargs['allow_failure'] = False
|
||||||
|
kwargs['return_all'] = True
|
||||||
|
|
||||||
|
out, err, rc = self.tw.execute_command(*args, **kwargs)
|
||||||
|
|
||||||
|
if rc == 0:
|
||||||
|
return out
|
||||||
|
else:
|
||||||
|
# In case of failure, print everything as os output
|
||||||
|
# Left for debug mode
|
||||||
|
# for line in itertools.chain(out, err[:-1]):
|
||||||
|
# print(line)
|
||||||
|
# Display the last line as failure
|
||||||
|
if err:
|
||||||
|
print(err[-1], file=sys.stderr)
|
||||||
|
|
||||||
def info(self):
|
def info(self):
|
||||||
for vimwikitask in self.tasks:
|
for vimwikitask in self.tasks:
|
||||||
info = self.tw.execute_command([vimwikitask['uuid'], 'info'])
|
out = self._execute_safely([vimwikitask['uuid'], 'info'])
|
||||||
util.show_in_split(info)
|
if out:
|
||||||
|
util.show_in_split(out)
|
||||||
break # Show only one task
|
break # Show only one task
|
||||||
|
|
||||||
def link(self):
|
def link(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue