Beispiel #1
0
    def InitImageServer(self, backData):
        try:
            if backData.res.code == 200:
                # 选择了分流才设置
                if self.server.address:
                    self.server.imageServer = ToolUtil.GetUrlHost(
                        backData.res.data["imageServer"])
                    Log.Info("初始化图片服务器成功, info:{}".format(
                        self.server.imageServer))

                return Status.Ok
            else:
                return Status.Error
        except Exception as es:
            Log.Error(es)
            return Status.Error
Beispiel #2
0
    def __DealHeaders(self, request, token):
        if self.token:
            request.headers["authorization"] = self.token
        if token:
            request.headers["authorization"] = token

        if self.address:
            host = ToolUtil.GetUrlHost(request.url)
            if host in config.Url:
                request.url = request.url.replace(host, self.address).replace("https://", "http://")
                request.headers["Host"] = host
            else:
                request.url = request.url.replace(host, self.imageServer)

        if request.method.lower() == "post":
            request.headers["Content-Type"] = "application/json; charset=UTF-8"
Beispiel #3
0
    def InitImageServer(self, backData):
        try:
            if backData.res.code == 200:
                # 选择了分流才设置
                if self.server.address:
                    self.server.imageServer = ToolUtil.GetUrlHost(
                        backData.res.data["imageServer"])
                    Log.Info("初始化图片服务器成功, info:{}".format(
                        self.server.imageServer))

                return Status.Ok
            else:
                return Status.Error
        except Exception as es:
            import sys
            cur_tb = sys.exc_info()[
                2]  # return (exc_type, exc_value, traceback)
            e = sys.exc_info()[1]
            Log.Error(cur_tb, e)
            return Status.Error