def __call__(self, *args, **kwargs):
        # print 'calling obj {name} with arguments {args} {kwargs}'.format(name=self.obj_name, args=args,
        # kwargs=kwargs)
        try:
            serial = kwargs["serial"]
        except KeyError:
            log.error("Serial number is missing in the arguments")
            raise KeyError

        dessert = get_dessert(serial)
        if dessert > "O":
            device_type = get_device_type(serial)
            device_name = device_type + "_" + dessert
        else:
            device_name = "automotive_O"
        module_path = ".".join(self.obj_module.split(".")[:-1])
        module_path = ".".join([module_path, device_name])
        module_path = ".".join(
            [module_path, self.obj_module.split(".")[-1:][0]])

        target_module = abstract_utils.import_module_from_path(module_path)
        if self.obj_type == "class":
            return abstract_utils.get_obj(target_module, self.obj_name)(*args, **kwargs)
        else:
            return abstract_utils.get_obj(target_module, self.obj_name, obj_type="function")(*args, **kwargs)
Esempio n. 2
0
    def _start_step(self,
                    step_module,
                    step_name,
                    step_info,
                    parallel_iterative=False,
                    stop_on_exception=True,
                    *args,
                    **kwargs):
        self.target_module = abstract_utils.import_module(step_module)
        step = abstract_utils.get_obj(self.target_module, step_name)
        sys.stdout = stepstdout = StringIO()
        #        sys.stderr = stepstderr = StringIO()
        step_info['name'] = step.__name__
        step_info['status'] = "running"
        step_info['exception'] = str()

        runcount = (-1 if parallel_iterative else 1)

        while runcount != 0:
            try:
                step(*args, **kwargs)()
            except Exception, e:
                sys.stdout.write(str(e) + "\n")
                step_info['exception'] = str(e)
                if stop_on_exception:
                    break
            finally:
Esempio n. 3
0
 def __call__(self, original_class):
     return abstract_utils.get_obj(self.target_module,
                                   original_class.__name__)