コード例 #1
0
    def AddConvert(self):
        savePath = os.path.join(self.parent.savePath,
                                ToolUtil.GetCanSaveName(self.epsTitle))
        filePath = os.path.join(
            savePath, "{:04}.{}".format(self.curPreConvertId + 1, "jpg"))
        if not os.path.isfile(filePath):
            self.status = DownloadInfo.NotFound
            self.parent.SetConvertStatu(self.status)
            return
        isConvertNext = True
        while self.curPreConvertId < self.picCnt:
            if os.path.isfile(self.curConvertPath):
                self.curPreConvertId += 1
            else:
                isConvertNext = False
                f = open(filePath, "rb")
                data = f.read()
                f.close()

                w, h = ToolUtil.GetPictureSize(data)
                model = ToolUtil.GetDownloadScaleModel(w, h)
                QtTask().AddConvertTask("",
                                        data,
                                        model,
                                        self.AddConvertBack,
                                        cleanFlag="download_{}".format(
                                            self.parent.bookId))
                break
        self.parent.UpdateTableItem()
        if isConvertNext:
            self.StartConvert()
        return
コード例 #2
0
    def AddConvert(self):
        savePath = os.path.join(self.parent.savePath, ToolUtil.GetCanSaveName(self.epsTitle))
        filePath = os.path.join(savePath, "{:04}.{}".format(self.curPreConvertId + 1, "jpg"))
        if not os.path.isfile(filePath):
            self.status = DownloadInfo.Error
            self.parent.SetConvertStatu(self.status)
            return
        if os.path.isfile(self.curConvertPath):
            self.curPreConvertId += 1
            return self.StartConvert()
        f = open(filePath, "rb")
        data = f.read()
        f.close()

        w, h = ToolUtil.GetPictureSize(data)
        model = ToolUtil.GetDownloadScaleModel(w, h)
        QtTask().AddConvertTask("", data, model, self.AddConvertBack,
                                cleanFlag="download_".format(self.parent.bookId))
        return