This prevents the user from seeing Python tracebacks, and in MI
mode, it makes sure that only the error object is printed if there is
an error, wherever this error happens.
Eventually, log statements should be added at strategic locations to
optionally provide more information about a failure to the user (and
to bug reports).
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
self._traces = None
self._ticks = 0
self._mi_mode = mi_mode
self._traces = None
self._ticks = 0
self._mi_mode = mi_mode
- self._create_automaton()
- self._mi_setup()
+ self._run_step('create automaton', self._create_automaton)
+ self._run_step('setup MI', self._mi_setup)
@property
def mi_mode(self):
return self._mi_mode
@property
def mi_mode(self):
return self._mi_mode
+ def _run_step(self, action_title, fn):
- self._parse_args()
- self._open_trace()
- self._create_analysis()
-
- if self._mi_mode and not self._args.test_compatibility:
- self._run_analysis()
-
- self._close_trace()
except KeyboardInterrupt:
except KeyboardInterrupt:
+ self._print('Cancelled by user')
+ except Exception as e:
+ self._gen_error('Cannot {}: {}'.format(action_title, e))
+
+ def run(self):
+ self._run_step('parse arguments', self._parse_args)
+ self._run_step('open trace', self._open_trace)
+ self._run_step('create analysis', self._create_analysis)
+
+ if self._mi_mode and not self._args.test_compatibility:
+ self._run_step('run analysis', self._run_analysis)
+
+ self._run_step('close trace', self._close_trace)
def _mi_error(self, msg, code=None):
print(json.dumps(mi.get_error(msg, code)))
def _mi_error(self, msg, code=None):
print(json.dumps(mi.get_error(msg, code)))