Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
Set test result in internal dictionary. Updates UI.
Args:
test_id: An unique string test identifier.
"""
update_listbox = False
if not test_id in self.test_data:
self.test_data[test_id] = {
'id': test_id
}
update_listbox = True
if extracted_traceback:
py_traceback = Traceback.from_dict(extracted_traceback).as_traceback()
extracted_traceback = traceback.extract_tb(py_traceback)
output += ''.join(
traceback.format_list(extracted_traceback) +
[exc_value]
)
test_data = self.test_data[test_id]
test_data['exc_type'] = exc_type
test_data['exc_value'] = exc_value
test_data['exc_tb'] = extracted_traceback
if when == 'call' and last_failed_exempt is not None:
test_data['last_failed_exempt'] = last_failed_exempt
# Ignore success, except for the 'call' step
# ignore successive failure, take only the first
if (outcome != 'passed' or when == 'call') \
traceback: json-serialised traceback (dumped using tbblib)
error: error message of the exception
"""
try:
import importlib as _importlib
import tblib as _tblib
if exdata["class"] == "UnicodeDecodeError":
exclass = _UnicodeDecodeError
else:
mod = _importlib.import_module(exdata["module"])
exclass = getattr(mod, exdata["class"])
ex = exclass("Error calling '%s' on '%s': %s" %
(function, service, exdata["error"]))
ex.__traceback__ = _tblib.Traceback.from_dict(
exdata["traceback"]).as_traceback()
except Exception as e:
from Acquire.Service import RemoteFunctionCallError
from Acquire.Service import exception_to_string \
as _exception_to_string
raise RemoteFunctionCallError(
"An exception occurred while calling '%s' on '%s'\n\n"
"CAUSE: %s\n\nEXDATA: %s" %
(function, service, _exception_to_string(e), exdata))
raise ex
return
# remove unused 'type' value
msg.contents.pop('type')
# NOTE: Fixes formatting issue used by logging lib, I.E. msg % args
args = msg.contents['args']
if isinstance(args, list):
msg.contents['args'] = tuple(args)
else:
msg.contents['args'] = args
exc_info = msg.contents['exc_info']
# deserialize exc_info
if exc_info:
import traceback
# FIXME
traceback.print_tb(Traceback.from_dict(exc_info).as_traceback())
return
# exc_info = (None, None, Traceback.from_dict(exc_info[2]).as_traceback())
"""
new_exc_info = []
# Exception type
# FIXME: bad exception handeling
try:
type_ = globals()['__builtins__'][exc_info[0]]
# pass in excption arguments
value = type_(*exc_info[1])
traceback = Traceback.from_dict(exc_info[2]).as_traceback()
new_exc_info = [type_, value, traceback]
msg.contents['exc_info'] = new_exc_info
except KeyError:
# FIXME
pass
"""
try:
import importlib as _importlib
import tblib as _tblib
if exdata["class"] == "UnicodeDecodeError":
exclass = _UnicodeDecodeError
else:
mod = _importlib.import_module(exdata["module"])
exclass = getattr(mod, exdata["class"])
ex = exclass("Error calling '%s' on '%s': %s" %
(function, service, exdata["error"]))
try:
ex.__traceback__ = _tblib.Traceback.from_dict(
exdata["traceback"]).as_traceback()
except:
# cannot get the traceback...
pass
except Exception as e:
from Acquire.Service import RemoteFunctionCallError
from Acquire.Service import exception_to_string \
as _exception_to_string
raise RemoteFunctionCallError(
"An exception occurred while calling '%s' on '%s'\n\n"
"CAUSE: %s\n\nEXDATA: %s" %
(function, service, _exception_to_string(e), exdata))
raise ex