Python mako.template 模块,render() 实例源码

我们从Python开源项目中,提取了以下32个代码示例,用于说明如何使用mako.template.render()

项目:wechannel    作者:PegasusWang    | 项目源码 | 文件源码
def render_string(self, filename, **kwargs):
        '''Override render_string to use mako template.
        Like tornado render_string method, this method
        also pass request handler environment to template engine.
        '''
        try:
            template = self._lookup.get_template(filename)
            env_kwargs = dict(
                handler=self,
                request=self.request,
                current_user=self.current_user,
                locale=self.locale,
                _=self.locale.translate,
                static_url=self.static_url,
                xsrf_form_html=self.xsrf_form_html,
                reverse_url=self.application.reverse_url,
            )
            env_kwargs.update(kwargs)
            return template.render(**env_kwargs)
        except Exception:
            traceback.print_exc()
            return exceptions.html_error_template().render()
项目:teleport    作者:eomsoft    | 项目源码 | 文件源码
def prepare(self):
        super().prepare()
        if self._finished:
            return

        reference = self.request.uri

        user = self.get_current_user()
        if not user['is_login']:
            if reference != '/auth/login':
                x = quote(reference)
                self.redirect('/auth/login?ref={}'.format(x))
            else:
                self.redirect('/auth/login')
        else:
            if cfg.app_mode == APP_MODE_MAINTENANCE:
                if user['type'] != 100:
                    self.render('maintenance/index.mako')
                else:
                    if not reference.startswith('/maintenance/'):
                        if get_db().need_create:
                            self.redirect('/maintenance/install')
                        elif get_db().need_upgrade:
                            self.redirect('/maintenance/upgrade')
项目:third_person_im    作者:bstadie    | 项目源码 | 文件源码
def __init__(
            self, model_path, frame_skip=1, position_only=False,
            obs_noise=0.0, action_noise=0.0, template_string=None,
            template_args=None,
    ):
        self.full_model_path = model_path
        if template_string is None:
            if model_path.endswith(".mako"):
                with open(model_path) as template_file:
                    template = mako.template.Template(
                        template_file.read())
                template_string = template.render(
                    opts=template_args if template_args is not None else {},
                )
            else:
                with open(model_path, "r") as f:
                    template_string = f.read()
        world, extra_data = world_from_xml(template_string)
        self.world = world
        self.extra_data = extra_data
        self.initial_state = self._state
        self.viewer = None
        self.frame_skip = frame_skip
        self.timestep = self.extra_data.timeStep
        self.position_only = position_only
        self.obs_noise = obs_noise
        self.action_noise = action_noise
        self._action_bounds = None
        # cache the computation of position mask
        self._position_ids = None
        self._cached_obs = None
        self._cached_coms = {}
项目:third_person_im    作者:bstadie    | 项目源码 | 文件源码
def render(self, states=None, actions=None, pause=False):
        if not self.viewer:
            self.viewer = Box2DViewer(self.world)
        if states or actions or pause:
            raise NotImplementedError
        if not self.viewer:
            self.start_viewer()
        if self.viewer:
            self.viewer.loop_once()
项目:third_person_im    作者:bstadie    | 项目源码 | 文件源码
def render(self, close=False):
        if close:
            self.stop_viewer()
        else:
            #self.get_viewer().render()
            self.get_viewer().loop_once()
            data, width, height = self.get_viewer().get_image()
            return np.fromstring(data, dtype='uint8').reshape(height, width, 3)[::-1, :, :]
        return None
项目:rllabplusplus    作者:shaneshixiang    | 项目源码 | 文件源码
def __init__(
            self, model_path, frame_skip=1, position_only=False,
            obs_noise=0.0, action_noise=0.0, template_string=None,
            template_args=None,
    ):
        self.full_model_path = model_path
        if template_string is None:
            if model_path.endswith(".mako"):
                with open(model_path) as template_file:
                    template = mako.template.Template(
                        template_file.read())
                template_string = template.render(
                    opts=template_args if template_args is not None else {},
                )
            else:
                with open(model_path, "r") as f:
                    template_string = f.read()
        world, extra_data = world_from_xml(template_string)
        self.world = world
        self.extra_data = extra_data
        self.initial_state = self._state
        self.viewer = None
        self.frame_skip = frame_skip
        self.timestep = self.extra_data.timeStep
        self.position_only = position_only
        self.obs_noise = obs_noise
        self.action_noise = action_noise
        self._action_bounds = None
        # cache the computation of position mask
        self._position_ids = None
        self._cached_obs = None
        self._cached_coms = {}
项目:rllabplusplus    作者:shaneshixiang    | 项目源码 | 文件源码
def render(self, states=None, actions=None, pause=False):
        if not self.viewer:
            self.viewer = Box2DViewer(self.world)
        if states or actions or pause:
            raise NotImplementedError
        if not self.viewer:
            self.start_viewer()
        if self.viewer:
            self.viewer.loop_once()
项目:rllabplusplus    作者:shaneshixiang    | 项目源码 | 文件源码
def render(self, close=False, mode='human'):
        if mode == 'human':
            viewer = self.get_viewer()
            viewer.loop_once()
        elif mode == 'rgb_array':
            viewer = self.get_viewer()
            viewer.loop_once()
            # self.get_viewer(config=config).render()
            data, width, height = self.get_viewer().get_image()
            return np.fromstring(data, dtype='uint8').reshape(height, width, 3)[::-1,:,:]
        if close:
            self.stop_viewer()
项目:pypugjs    作者:matannoam    | 项目源码 | 文件源码
def jinja_process (src, filename):
        global jinja_env
        template = jinja_env.get_template(filename)
        return template.render()
项目:pypugjs    作者:matannoam    | 项目源码 | 文件源码
def jinja_process_variable_start_string (src, filename):
        global jinja_env
        template = jinja_env.get_template(filename)
        return template.render()
项目:pypugjs    作者:matannoam    | 项目源码 | 文件源码
def django_process(src, filename):
        compiled = process(src, filename=filename, compiler=DjangoCompiler)
        print(compiled)
        t = django.template.Template(compiled)

        ctx = django.template.Context()
        return t.render(ctx)
项目:pypugjs    作者:matannoam    | 项目源码 | 文件源码
def mako_process(src, filename):
        t = mako.template.Template(src, lookup=dirlookup,preprocessor=pypugjs.ext.mako.preprocessor, default_filters=['decode.utf8'])
        return t.render()
项目:wechannel    作者:PegasusWang    | 项目源码 | 文件源码
def render(self, filename, **kwargs):
        self.finish(self.render_string(filename, **kwargs))
项目:wechannel    作者:PegasusWang    | 项目源码 | 文件源码
def write_error(self, status_code, **kwargs):
        if status_code == 404:
            self.render('404.html')
        elif status_code == 500:
            self.render('500.html')
        else:
            super(BaseHandler, self).write_error(status_code, **kwargs)
项目:gail-driver    作者:sisl    | 项目源码 | 文件源码
def __init__(
            self, model_path, frame_skip=1, position_only=False,
            obs_noise=0.0, action_noise=0.0, template_string=None,
            template_args=None,
    ):
        self.full_model_path = model_path
        if template_string is None:
            if model_path.endswith(".mako"):
                with open(model_path) as template_file:
                    template = mako.template.Template(
                        template_file.read())
                template_string = template.render(
                    opts=template_args if template_args is not None else {},
                )
            else:
                with open(model_path, "r") as f:
                    template_string = f.read()
        world, extra_data = world_from_xml(template_string)
        self.world = world
        self.extra_data = extra_data
        self.initial_state = self._state
        self.viewer = None
        self.frame_skip = frame_skip
        self.timestep = self.extra_data.timeStep
        self.position_only = position_only
        self.obs_noise = obs_noise
        self.action_noise = action_noise
        self._action_bounds = None
        # cache the computation of position mask
        self._position_ids = None
        self._cached_obs = None
        self._cached_coms = {}
项目:gail-driver    作者:sisl    | 项目源码 | 文件源码
def render(self, states=None, actions=None, pause=False):
        if not self.viewer:
            self.viewer = Box2DViewer(self.world)
        if states or actions or pause:
            raise NotImplementedError
        if not self.viewer:
            self.start_viewer()
        if self.viewer:
            self.viewer.loop_once()
项目:gail-driver    作者:sisl    | 项目源码 | 文件源码
def render(self):
        viewer = self.get_viewer()
        viewer.loop_once()
项目:teleport    作者:eomsoft    | 项目源码 | 文件源码
def render_string(self, template_name, **kwargs):
        template = self.lookup.get_template(template_name)
        namespace = self.get_template_namespace()
        namespace.update(kwargs)
        return template.render(**namespace)
项目:teleport    作者:eomsoft    | 项目源码 | 文件源码
def render(self, template_path, **kwargs):
        if self._mode != self.MODE_HTTP:
            self.write_json(-1, 'should be web page request.')
            return
        self.finish(self.render_string(template_path, **kwargs))
项目:rllab    作者:rll    | 项目源码 | 文件源码
def __init__(
            self, model_path, frame_skip=1, position_only=False,
            obs_noise=0.0, action_noise=0.0, template_string=None,
            template_args=None,
    ):
        self.full_model_path = model_path
        if template_string is None:
            if model_path.endswith(".mako"):
                with open(model_path) as template_file:
                    template = mako.template.Template(
                        template_file.read())
                template_string = template.render(
                    opts=template_args if template_args is not None else {},
                )
            else:
                with open(model_path, "r") as f:
                    template_string = f.read()
        world, extra_data = world_from_xml(template_string)
        self.world = world
        self.extra_data = extra_data
        self.initial_state = self._state
        self.viewer = None
        self.frame_skip = frame_skip
        self.timestep = self.extra_data.timeStep
        self.position_only = position_only
        self.obs_noise = obs_noise
        self.action_noise = action_noise
        self._action_bounds = None
        # cache the computation of position mask
        self._position_ids = None
        self._cached_obs = None
        self._cached_coms = {}
项目:rllab    作者:rll    | 项目源码 | 文件源码
def render(self, states=None, actions=None, pause=False):
        if not self.viewer:
            self.viewer = Box2DViewer(self.world)
        if states or actions or pause:
            raise NotImplementedError
        if not self.viewer:
            self.start_viewer()
        if self.viewer:
            self.viewer.loop_once()
项目:rllab    作者:rll    | 项目源码 | 文件源码
def render(self, close=False, mode='human'):
        if mode == 'human':
            viewer = self.get_viewer()
            viewer.loop_once()
        elif mode == 'rgb_array':
            viewer = self.get_viewer()
            viewer.loop_once()
            # self.get_viewer(config=config).render()
            data, width, height = self.get_viewer().get_image()
            return np.fromstring(data, dtype='uint8').reshape(height, width, 3)[::-1,:,:]
        if close:
            self.stop_viewer()
项目:maml_rl    作者:cbfinn    | 项目源码 | 文件源码
def __init__(
            self, model_path, frame_skip=1, position_only=False,
            obs_noise=0.0, action_noise=0.0, template_string=None,
            template_args=None,
    ):
        self.full_model_path = model_path
        if template_string is None:
            if model_path.endswith(".mako"):
                with open(model_path) as template_file:
                    template = mako.template.Template(
                        template_file.read())
                template_string = template.render(
                    opts=template_args if template_args is not None else {},
                )
            else:
                with open(model_path, "r") as f:
                    template_string = f.read()
        world, extra_data = world_from_xml(template_string)
        self.world = world
        self.extra_data = extra_data
        self.initial_state = self._state
        self.viewer = None
        self.frame_skip = frame_skip
        self.timestep = self.extra_data.timeStep
        self.position_only = position_only
        self.obs_noise = obs_noise
        self.action_noise = action_noise
        self._action_bounds = None
        # cache the computation of position mask
        self._position_ids = None
        self._cached_obs = None
        self._cached_coms = {}
项目:maml_rl    作者:cbfinn    | 项目源码 | 文件源码
def render(self, states=None, actions=None, pause=False):
        if not self.viewer:
            self.viewer = Box2DViewer(self.world)
        if states or actions or pause:
            raise NotImplementedError
        if not self.viewer:
            self.start_viewer()
        if self.viewer:
            self.viewer.loop_once()
项目:maml_rl    作者:cbfinn    | 项目源码 | 文件源码
def __init__(self, action_noise=0.0, file_path=None, template_args=None):
        # compile template
        if file_path is None:
            if self.__class__.FILE is None:
                raise "Mujoco file not specified"
            file_path = osp.join(MODEL_DIR, self.__class__.FILE)
        if file_path.endswith(".mako"):
            lookup = mako.lookup.TemplateLookup(directories=[MODEL_DIR])
            with open(file_path) as template_file:
                template = mako.template.Template(
                    template_file.read(), lookup=lookup)
            content = template.render(
                opts=template_args if template_args is not None else {},
            )
            tmp_f, file_path = tempfile.mkstemp(text=True)
            with open(file_path, 'w') as f:
                f.write(content)
            self.model = MjModel(file_path)
            os.close(tmp_f)
        else:
            self.model = MjModel(file_path)
        self.data = self.model.data
        self.viewer = None
        self.init_qpos = self.model.data.qpos
        self.init_qvel = self.model.data.qvel
        self.init_qacc = self.model.data.qacc
        self.init_ctrl = self.model.data.ctrl
        self.qpos_dim = self.init_qpos.size
        self.qvel_dim = self.init_qvel.size
        self.ctrl_dim = self.init_ctrl.size
        self.action_noise = action_noise
        if "frame_skip" in self.model.numeric_names:
            frame_skip_id = self.model.numeric_names.index("frame_skip")
            addr = self.model.numeric_adr.flat[frame_skip_id]
            self.frame_skip = int(self.model.numeric_data.flat[addr])
        else:
            self.frame_skip = 1
        if "init_qpos" in self.model.numeric_names:
            init_qpos_id = self.model.numeric_names.index("init_qpos")
            addr = self.model.numeric_adr.flat[init_qpos_id]
            size = self.model.numeric_size.flat[init_qpos_id]
            init_qpos = self.model.numeric_data.flat[addr:addr + size]
            self.init_qpos = init_qpos
        self.dcom = None
        self.current_com = None
        self.reset()
        super(MujocoEnv, self).__init__()
项目:maml_rl    作者:cbfinn    | 项目源码 | 文件源码
def render(self):
        viewer = self.get_viewer()
        viewer.loop_once()
项目:third_person_im    作者:bstadie    | 项目源码 | 文件源码
def __init__(self, action_noise=0.0, file_path=None, template_args=None):
        # compile template
        if file_path is None:
            if self.__class__.FILE is None:
                raise "Mujoco file not specified"
            file_path = osp.join(MODEL_DIR, self.__class__.FILE)
        if file_path.endswith(".mako"):
            lookup = mako.lookup.TemplateLookup(directories=[MODEL_DIR])
            with open(file_path) as template_file:
                template = mako.template.Template(
                    template_file.read(), lookup=lookup)
            content = template.render(
                opts=template_args if template_args is not None else {},
            )
            tmp_f, file_path = tempfile.mkstemp(text=True)
            with open(file_path, 'w') as f:
                f.write(content)
            self.model = MjModel(file_path)
            os.close(tmp_f)
        else:
            self.model = MjModel(file_path)
        self.data = self.model.data
        self.viewer = None
        self.init_qpos = self.model.data.qpos
        self.init_qvel = self.model.data.qvel
        self.init_qacc = self.model.data.qacc
        self.init_ctrl = self.model.data.ctrl
        self.qpos_dim = self.init_qpos.size
        self.qvel_dim = self.init_qvel.size
        self.ctrl_dim = self.init_ctrl.size
        self.action_noise = action_noise
        if "frame_skip" in self.model.numeric_names:
            frame_skip_id = self.model.numeric_names.index("frame_skip")
            addr = self.model.numeric_adr.flat[frame_skip_id]
            self.frame_skip = int(self.model.numeric_data.flat[addr])
        else:
            self.frame_skip = 1
        if "init_qpos" in self.model.numeric_names:
            init_qpos_id = self.model.numeric_names.index("init_qpos")
            addr = self.model.numeric_adr.flat[init_qpos_id]
            size = self.model.numeric_size.flat[init_qpos_id]
            init_qpos = self.model.numeric_data.flat[addr:addr + size]
            self.init_qpos = init_qpos
        self.dcom = None
        self.current_com = None
        self.reset()
        super(MujocoEnv, self).__init__()
项目:rllabplusplus    作者:shaneshixiang    | 项目源码 | 文件源码
def __init__(self, action_noise=0.0, file_path=None, template_args=None):
        # compile template
        if file_path is None:
            if self.__class__.FILE is None:
                raise "Mujoco file not specified"
            file_path = osp.join(MODEL_DIR, self.__class__.FILE)
        if file_path.endswith(".mako"):
            lookup = mako.lookup.TemplateLookup(directories=[MODEL_DIR])
            with open(file_path) as template_file:
                template = mako.template.Template(
                    template_file.read(), lookup=lookup)
            content = template.render(
                opts=template_args if template_args is not None else {},
            )
            tmp_f, file_path = tempfile.mkstemp(text=True)
            with open(file_path, 'w') as f:
                f.write(content)
            self.model = MjModel(file_path)
            os.close(tmp_f)
        else:
            self.model = MjModel(file_path)
        self.data = self.model.data
        self.viewer = None
        self.init_qpos = self.model.data.qpos
        self.init_qvel = self.model.data.qvel
        self.init_qacc = self.model.data.qacc
        self.init_ctrl = self.model.data.ctrl
        self.qpos_dim = self.init_qpos.size
        self.qvel_dim = self.init_qvel.size
        self.ctrl_dim = self.init_ctrl.size
        self.action_noise = action_noise
        if "frame_skip" in self.model.numeric_names:
            frame_skip_id = self.model.numeric_names.index("frame_skip")
            addr = self.model.numeric_adr.flat[frame_skip_id]
            self.frame_skip = int(self.model.numeric_data.flat[addr])
        else:
            self.frame_skip = 1
        if "init_qpos" in self.model.numeric_names:
            init_qpos_id = self.model.numeric_names.index("init_qpos")
            addr = self.model.numeric_adr.flat[init_qpos_id]
            size = self.model.numeric_size.flat[init_qpos_id]
            init_qpos = self.model.numeric_data.flat[addr:addr + size]
            self.init_qpos = init_qpos
        self.dcom = None
        self.current_com = None
        self.reset()
        super(MujocoEnv, self).__init__()
项目:rllabplusplus    作者:shaneshixiang    | 项目源码 | 文件源码
def __init__(self,
                 difficulty=1.0,
                 texturedir='/tmp/mujoco_textures',
                 hfield_dir='/tmp/mujoco_terrains',
                 regen_terrain=True,
                 *args, **kwargs):
        Serializable.quick_init(self, locals())

        self.difficulty = max(difficulty, self.MIN_DIFFICULTY)
        self.texturedir = texturedir
        self.hfield_dir = hfield_dir

        model_cls = self.__class__.MODEL_CLASS
        if model_cls is None:
            raise "MODEL_CLASS unspecified!"

        template_file_name = 'hill_' + model_cls.__module__.split('.')[-1] + '.xml.mako'

        template_options=dict(
            difficulty=self.difficulty,
            texturedir=self.texturedir,
            hfield_file=os.path.join(self.hfield_dir, self.HFIELD_FNAME))

        file_path = os.path.join(MODEL_DIR, template_file_name)
        lookup = mako.lookup.TemplateLookup(directories=[MODEL_DIR])
        with open(file_path) as template_file:
            template = mako.template.Template(
                template_file.read(), lookup=lookup)
        content = template.render(opts=template_options)

        tmp_f, file_path = tempfile.mkstemp(text=True)
        with open(file_path, 'w') as f:
            f.write(content)

        if self._iam_terrain_generator(regen_terrain):
            self._gen_terrain(regen_terrain)
            os.remove(self._get_lock_path())

        inner_env = model_cls(*args, file_path=file_path, **kwargs)  # file to the robot specifications
        ProxyEnv.__init__(self, inner_env)  # here is where the robot env will be initialized

        os.close(tmp_f)
项目:gail-driver    作者:sisl    | 项目源码 | 文件源码
def __init__(self, action_noise=0.0, file_path=None, template_args=None):
        # compile template
        if file_path is None:
            if self.__class__.FILE is None:
                raise "Mujoco file not specified"
            file_path = osp.join(MODEL_DIR, self.__class__.FILE)
        if file_path.endswith(".mako"):
            lookup = mako.lookup.TemplateLookup(directories=[MODEL_DIR])
            with open(file_path) as template_file:
                template = mako.template.Template(
                    template_file.read(), lookup=lookup)
            content = template.render(
                opts=template_args if template_args is not None else {},
            )
            tmp_f, file_path = tempfile.mkstemp(text=True)
            with open(file_path, 'w') as f:
                f.write(content)
            self.model = MjModel(file_path)
            os.close(tmp_f)
        else:
            self.model = MjModel(file_path)
        self.data = self.model.data
        self.viewer = None
        self.init_qpos = self.model.data.qpos
        self.init_qvel = self.model.data.qvel
        self.init_qacc = self.model.data.qacc
        self.init_ctrl = self.model.data.ctrl
        self.qpos_dim = self.init_qpos.size
        self.qvel_dim = self.init_qvel.size
        self.ctrl_dim = self.init_ctrl.size
        self.action_noise = action_noise
        if "frame_skip" in self.model.numeric_names:
            frame_skip_id = self.model.numeric_names.index("frame_skip")
            addr = self.model.numeric_adr.flat[frame_skip_id]
            self.frame_skip = int(self.model.numeric_data.flat[addr])
        else:
            self.frame_skip = 1
        if "init_qpos" in self.model.numeric_names:
            init_qpos_id = self.model.numeric_names.index("init_qpos")
            addr = self.model.numeric_adr.flat[init_qpos_id]
            size = self.model.numeric_size.flat[init_qpos_id]
            init_qpos = self.model.numeric_data.flat[addr:addr + size]
            self.init_qpos = init_qpos
        self.dcom = None
        self.current_com = None
        self.reset()
        super(MujocoEnv, self).__init__()
项目:rllab    作者:rll    | 项目源码 | 文件源码
def __init__(self, action_noise=0.0, file_path=None, template_args=None):
        # compile template
        if file_path is None:
            if self.__class__.FILE is None:
                raise "Mujoco file not specified"
            file_path = osp.join(MODEL_DIR, self.__class__.FILE)
        if file_path.endswith(".mako"):
            lookup = mako.lookup.TemplateLookup(directories=[MODEL_DIR])
            with open(file_path) as template_file:
                template = mako.template.Template(
                    template_file.read(), lookup=lookup)
            content = template.render(
                opts=template_args if template_args is not None else {},
            )
            tmp_f, file_path = tempfile.mkstemp(text=True)
            with open(file_path, 'w') as f:
                f.write(content)
            self.model = MjModel(file_path)
            os.close(tmp_f)
        else:
            self.model = MjModel(file_path)
        self.data = self.model.data
        self.viewer = None
        self.init_qpos = self.model.data.qpos
        self.init_qvel = self.model.data.qvel
        self.init_qacc = self.model.data.qacc
        self.init_ctrl = self.model.data.ctrl
        self.qpos_dim = self.init_qpos.size
        self.qvel_dim = self.init_qvel.size
        self.ctrl_dim = self.init_ctrl.size
        self.action_noise = action_noise
        if "frame_skip" in self.model.numeric_names:
            frame_skip_id = self.model.numeric_names.index("frame_skip")
            addr = self.model.numeric_adr.flat[frame_skip_id]
            self.frame_skip = int(self.model.numeric_data.flat[addr])
        else:
            self.frame_skip = 1
        if "init_qpos" in self.model.numeric_names:
            init_qpos_id = self.model.numeric_names.index("init_qpos")
            addr = self.model.numeric_adr.flat[init_qpos_id]
            size = self.model.numeric_size.flat[init_qpos_id]
            init_qpos = self.model.numeric_data.flat[addr:addr + size]
            self.init_qpos = init_qpos
        self.dcom = None
        self.current_com = None
        self.reset()
        super(MujocoEnv, self).__init__()
项目:rllab    作者:rll    | 项目源码 | 文件源码
def __init__(self,
                 difficulty=1.0,
                 texturedir='/tmp/mujoco_textures',
                 hfield_dir='/tmp/mujoco_terrains',
                 regen_terrain=True,
                 *args, **kwargs):
        Serializable.quick_init(self, locals())

        self.difficulty = max(difficulty, self.MIN_DIFFICULTY)
        self.texturedir = texturedir
        self.hfield_dir = hfield_dir

        model_cls = self.__class__.MODEL_CLASS
        if model_cls is None:
            raise "MODEL_CLASS unspecified!"

        template_file_name = 'hill_' + model_cls.__module__.split('.')[-1] + '.xml.mako'

        template_options=dict(
            difficulty=self.difficulty,
            texturedir=self.texturedir,
            hfield_file=os.path.join(self.hfield_dir, self.HFIELD_FNAME))

        file_path = os.path.join(MODEL_DIR, template_file_name)
        lookup = mako.lookup.TemplateLookup(directories=[MODEL_DIR])
        with open(file_path) as template_file:
            template = mako.template.Template(
                template_file.read(), lookup=lookup)
        content = template.render(opts=template_options)

        tmp_f, file_path = tempfile.mkstemp(text=True)
        with open(file_path, 'w') as f:
            f.write(content)

        if self._iam_terrain_generator(regen_terrain):
            self._gen_terrain(regen_terrain)
            os.remove(self._get_lock_path())

        inner_env = model_cls(*args, file_path=file_path, **kwargs)  # file to the robot specifications
        ProxyEnv.__init__(self, inner_env)  # here is where the robot env will be initialized

        os.close(tmp_f)