def _new_actor(self, actor_type, actor_id=None, credentials=None):
        """Return a 'bare' actor of actor_type, raises an exception on failure."""
        if credentials is not None:
            sec = Security()
            sec.set_principal(credentials)
            sec.authenticate_principal()
        else:
            sec = None
        (found, is_primitive, class_) = ActorStore(security=sec).lookup(actor_type)
        if not found:
            # Here assume a primtive actor, now become shadow actor
            _log.analyze(self.node.id, "+ NOT FOUND CREATE SHADOW ACTOR", {'class': class_})
            found = True
            is_primitive = True
            class_ = ShadowActor
        if not found or not is_primitive:
            _log.error("Requested actor %s is not available" % (actor_type))
            raise Exception("ERROR_NOT_FOUND")
        try:
            # Create a 'bare' instance of the actor
            a = class_(actor_type, actor_id=actor_id)
        except Exception as e:
            _log.exception("")
            _log.error("The actor %s(%s) can't be instantiated." % (actor_type, class_.__init__))
            raise(e)
        try:
            a.set_credentials(credentials, security=sec)
            a._calvinsys = self.node.calvinsys()
            a.check_requirements()
        except Exception as e:
            _log.exception("Catched new from state")
            _log.analyze(self.node.id, "+ FAILED REQS CREATE SHADOW ACTOR", {'class': class_})
            a = ShadowActor(actor_type, actor_id=actor_id)
            a.set_credentials(credentials, security=sec)
            a._calvinsys = self.node.calvinsys()
        return a
dataset/ETHPy150Open EricssonResearch/calvin-base/calvin/runtime/north/actormanager.py/ActorManager._new_actor/original