Exemplo n.º 1
0
    def collect_info(self, obj_item, info_dict, trunk_storage):
        """
        Schema 1: return dict that contains compressed size, may need to scan all items
            in dict, such as thumb compressed size and file compressed size
        Schema 2: only return size, store collected info directly to trunk storage
        """
        item_info_dict = obj_item.getItemInfo()
        fullPath = obj_item["fullPath"]
        mime_type = obj_item["mime_type"]
        # Add thumb info
        thumbFullPath = getThumb(fullPath, self.working_dir, mime_type)
        if not (thumbFullPath is None):
            thumbObj = self.dbInst.getFsObjFromFullPath(thumbFullPath)
            thumbUfsUrl = thumbObj.getObjUfsUrl()
            item_info_dict["thumbnailFullPath"] = thumbFullPath
            item_info_dict["thumbnailUuid"] = thumbObj["uuid"]
            item_info_dict["thumbnailUrl"] = thumbUfsUrl
            item_info_dict["thumbnailHeadMd5"] = thumbObj.headMd5()
            # Store thumbnail info
            info_dict[thumbUfsUrl] = thumbObj.getItemInfo()
            #########################################
            # Add thumb file to zip, it is not stored until finalize the current trunk
            #########################################
            added_size = trunk_storage.add_file(thumbFullPath)
            ####################################################
            # Add item info, it is not stored until finalize the current trunk
            ####################################################
            self.add_new_info(info_dict, obj_item.getObjUfsUrl(), item_info_dict)
            ncl(item_info_dict)
            return added_size

        else:
            ncl("No thumb generated", fullPath)
            return 0
Exemplo n.º 2
0
 def addItem(self, itemObj):
     infoDict = itemObj.getItemInfo()
     fullPath = itemObj["fullPath"]
     #Add thumb info
     thumbFullPath = getThumb(fullPath, gWorkingDir)
     if not (thumbFullPath is None):
         thumbObj = self.dbInst.getFsObjFromFullPath(thumbFullPath)
         thumbUfsUrl = thumbObj.getObjUfsUrl()
         infoDict["thumbnailFullPath"] = thumbFullPath
         infoDict["thumbnailUuid"] = thumbObj["uuid"]
         infoDict["thumbnailUrl"] = thumbUfsUrl
         infoDict["thumbnailHeadMd5"] = thumbObj.headMd5()
         self.collectionInfoDict[thumbUfsUrl] = thumbObj.getItemInfo()
     #Add item info
     self.collectionInfoDict[itemObj.getObjUfsUrl()] = infoDict
     ncl(infoDict)
     #Add file to zip
     thumbnailZippedSize = self.getZipFile().addfile(unicode(thumbFullPath), unicode(thumbFullPath))
     return gDefaultInfoSize*2 + thumbnailZippedSize.compress_size
Exemplo n.º 3
0
    def getThumb(self, fullPath):
        #cl(fullPath)
        #path = transform.transformDirToInternal(fullPath)
        path = fullPath
        ncl(path)
        if True:
            #print path
            if os.path.isdir(path):
                return os.path.join(self.prodRootPath,self.existingIconRelativePath+'folder-images-icon.png')
            ext = path.split('.')[-1].lower()
            newPath = thumbLib.getThumb(path)
            if not (newPath is None):
                return newPath
            sup = ['doc','zip','wav','xls','txt','rar', 'pdf', 'ppt']
            #picSup = ['flv','mov','avi','rm','rmvb','jpg','jpeg','png','gif','bmp','wmv','mp4','3gp','mpg','mpeg', 'exe']

            if ext in sup:
                #print os.path.join(self.prodRootPath,self.existingIconRelativePath+'online\\512px\\%s.png'%ext)
                return os.path.join(self.prodRootPath,self.existingIconRelativePath+'online\\512px\\%s.png'%ext)
            else:
                return os.path.join(self.prodRootPath,self.existingIconRelativePath+'online\\512px\\_page.png')