base_class.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:zmirror 作者: aploium 项目源码 文件源码
def reload_zmirror(self, configs_dict=None):
        self.del_temp_var()

        import config
        importlib.reload(config)

        test_config_names = (name for name in dir(self.C) if name[:2] != '__' and name[-2:] != '__')
        for config_name in test_config_names:
            config_value = getattr(self.C, config_name)
            setattr(config, config_name, config_value)

        if configs_dict is not None:
            for config_name, config_value in configs_dict.items():
                setattr(config, config_name, config_value)

        import zmirror.cache_system as cache_system
        import zmirror.zmirror as zmirror
        importlib.reload(cache_system)
        importlib.reload(zmirror)

        zmirror.app.config['TESTING'] = True

        # ?????????, ? del_temp_var() ???
        if hasattr(self.C, "my_host_port"):
            port = getattr(self.C, "my_host_port", None)
            my_host_name = getattr(self.C, "my_host_name", "127.0.0.1")
            if port is not None:
                self.C.my_host_name_no_port = my_host_name
                self.C.my_host_name = self.C.my_host_name_no_port + ":" + str(port)
            else:
                self.C.my_host_name_no_port = my_host_name
        elif hasattr(self.C, "my_host_name"):
            self.C.my_host_name_no_port = self.C.my_host_name

        self.client = zmirror.app.test_client()  # type: FlaskClient
        self.app = zmirror.app  # type: Flask
        self.zmirror = zmirror
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号