fix error handling in signaled commands, error gets info about different scoup instead of true error
more detaild error print including python trace when more complex unknown error
reinplement drillcncjob
fix camlib problem with all drills("all" was already there) but it crashes on tools without points, when no tools "all" is as default
add timeout to all helps if command is signaled
This commit is contained in:
@@ -125,6 +125,10 @@ class TclCommand(object):
|
||||
for key, value in self.help['args'].items():
|
||||
help_string.append(get_decorated_argument(key, value))
|
||||
|
||||
# timeout is unique for signaled commands (this is not best oop practice, but much easier for now)
|
||||
if isinstance(self, TclCommandSignaled):
|
||||
help_string.append("\t[-timeout <int>: Max wait for job timeout before error.]")
|
||||
|
||||
for example in self.help['examples']:
|
||||
help_string.append(get_decorated_example(example))
|
||||
|
||||
@@ -192,10 +196,13 @@ class TclCommand(object):
|
||||
|
||||
# check options
|
||||
for key in options:
|
||||
if key not in self.option_types and key is not 'timeout':
|
||||
if key not in self.option_types and key != 'timeout':
|
||||
self.raise_tcl_error('Unknown parameter: %s' % key)
|
||||
try:
|
||||
named_args[key] = self.option_types[key](options[key])
|
||||
if key != 'timeout':
|
||||
named_args[key] = self.option_types[key](options[key])
|
||||
else:
|
||||
named_args[key] = int(options[key])
|
||||
except Exception, e:
|
||||
self.raise_tcl_error("Cannot cast argument '-%s' to type '%s' with exception '%s'."
|
||||
% (key, self.option_types[key], str(e)))
|
||||
@@ -207,6 +214,31 @@ class TclCommand(object):
|
||||
|
||||
return named_args, unnamed_args
|
||||
|
||||
|
||||
def raise_tcl_unknown_error(self, unknownException):
|
||||
"""
|
||||
raise Exception if is different type than TclErrorException
|
||||
this is here mainly to show unknown errors inside TCL shell console
|
||||
:param unknownException:
|
||||
:return:
|
||||
"""
|
||||
|
||||
#if not isinstance(unknownException, self.TclErrorException):
|
||||
# self.raise_tcl_error("Unknown error: %s" % str(unknownException))
|
||||
#else:
|
||||
raise unknownException
|
||||
|
||||
def raise_tcl_error(self, text):
|
||||
"""
|
||||
this method pass exception from python into TCL as error, so we get stacktrace and reason
|
||||
:param text: text of error
|
||||
:return: raise exception
|
||||
"""
|
||||
|
||||
# becouse of signaling we cannot call error to TCL from here but when task is finished
|
||||
# also nonsiglaned arwe handled here to better exception handling and diplay after command is finished
|
||||
raise self.app.TclErrorException(text)
|
||||
|
||||
def execute_wrapper(self, *args):
|
||||
"""
|
||||
Command which is called by tcl console when current commands aliases are hit.
|
||||
@@ -225,8 +257,10 @@ class TclCommand(object):
|
||||
args, unnamed_args = self.check_args(args)
|
||||
return self.execute(args, unnamed_args)
|
||||
except Exception as unknown:
|
||||
error_info=sys.exc_info()
|
||||
self.log.error("TCL command '%s' failed." % str(self))
|
||||
self.app.raise_tcl_unknown_error(unknown)
|
||||
self.app.display_tcl_error(unknown, error_info)
|
||||
self.raise_tcl_unknown_error(unknown)
|
||||
|
||||
@abc.abstractmethod
|
||||
def execute(self, args, unnamed_args):
|
||||
@@ -242,7 +276,6 @@ class TclCommand(object):
|
||||
|
||||
raise NotImplementedError("Please Implement this method")
|
||||
|
||||
|
||||
class TclCommandSignaled(TclCommand):
|
||||
"""
|
||||
!!! I left it here only for demonstration !!!
|
||||
@@ -266,7 +299,13 @@ class TclCommandSignaled(TclCommand):
|
||||
def execute_call(self, args, unnamed_args):
|
||||
|
||||
try:
|
||||
self.output = None
|
||||
self.error=None
|
||||
self.error_info=None
|
||||
self.output = self.execute(args, unnamed_args)
|
||||
except Exception as unknown:
|
||||
self.error_info = sys.exc_info()
|
||||
self.error=unknown
|
||||
finally:
|
||||
self.app.shell_command_finished.emit(self)
|
||||
|
||||
@@ -336,12 +375,12 @@ class TclCommandSignaled(TclCommand):
|
||||
# set detail for processing, it will be there until next open or close
|
||||
self.app.shell.open_proccessing(self.get_current_command())
|
||||
|
||||
self.output = None
|
||||
|
||||
def handle_finished(obj):
|
||||
self.app.shell_command_finished.disconnect(handle_finished)
|
||||
# TODO: handle output
|
||||
pass
|
||||
if self.error is not None:
|
||||
self.log.error("TCL command '%s' failed." % str(self))
|
||||
self.app.display_tcl_error(self.error, self.error_info)
|
||||
self.raise_tcl_unknown_error(self.error)
|
||||
|
||||
self.app.shell_command_finished.connect(handle_finished)
|
||||
|
||||
@@ -355,4 +394,4 @@ class TclCommandSignaled(TclCommand):
|
||||
|
||||
except Exception as unknown:
|
||||
self.log.error("TCL command '%s' failed." % str(self))
|
||||
self.app.raise_tcl_unknown_error(unknown)
|
||||
self.raise_tcl_unknown_error(unknown)
|
||||
Reference in New Issue
Block a user