Fix output in case of failed command
This commit is contained in:
parent
9846425b29
commit
44dd1bc6a6
@ -60,9 +60,13 @@ class Command(cli2.Command):
|
|||||||
except ProcFailure:
|
except ProcFailure:
|
||||||
# just output the failure without TB, as command was already
|
# just output the failure without TB, as command was already
|
||||||
# printed anyway
|
# printed anyway
|
||||||
pass
|
self.exit_code = 1
|
||||||
self['target'].value.output.results(self['target'].value)
|
self['target'].value.output.results(self['target'].value)
|
||||||
return result
|
|
||||||
|
if result and result.status == 'success':
|
||||||
|
self.exit_code = 0
|
||||||
|
else:
|
||||||
|
self.exit_code = 1
|
||||||
|
|
||||||
|
|
||||||
class ActionCommand(cli2.Command):
|
class ActionCommand(cli2.Command):
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from ..output import Output
|
from ..output import Output
|
||||||
from ..proc import Proc
|
from ..proc import Proc, ProcFailure
|
||||||
from ..result import Result, Results
|
from ..result import Result, Results
|
||||||
|
|
||||||
|
|
||||||
@ -68,13 +68,19 @@ class Target:
|
|||||||
self.output.fail(action, e)
|
self.output.fail(action, e)
|
||||||
result.status = 'failure'
|
result.status = 'failure'
|
||||||
result.exception = e
|
result.exception = e
|
||||||
|
|
||||||
|
if not isinstance(e, ProcFailure):
|
||||||
|
# no need to reraise in case of command error
|
||||||
|
# because the command has been printed
|
||||||
|
|
||||||
if reraise:
|
if reraise:
|
||||||
# nested call, re-raise
|
# nested call, re-raise
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exception(type(e), e, sys.exc_info()[2])
|
traceback.print_exception(type(e), e, sys.exc_info()[2])
|
||||||
return True
|
|
||||||
|
return True # because it failed
|
||||||
else:
|
else:
|
||||||
if getattr(action, 'skipped', False):
|
if getattr(action, 'skipped', False):
|
||||||
self.output.skip(action)
|
self.output.skip(action)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user