def ScanFileInfo(self, dirPath, fileName): global FileInfoQueue global ScanDone global ThumbnailQueue global SubDirQueue global StartTime global DirCount global FilesCount global TotalImages global KnownFilesCount if not self.keepGoing: return fullFileName = os.path.join(dirPath, fileName) """Name, DirPath, Extension, MimeType, Category, Description, Size, Created, CDate, CMonth, Modified, MDate, MMonth, Accessed, ADate, AMonth, MD5,KnownFile,NewPath """ #propList = [] #propList.append(fileName) #propList.append(dirPath) if os.path.isfile(fullFileName): FilesCount += 1 Extension, MimeType, Description, Category = self.GetFileMimeInfo(fullFileName) try: st = os.stat(fullFileName) Modified = st[ST_MTIME] Size = st[ST_SIZE] Created = st[ST_CTIME] Accessed = st[ST_ATIME] except Exception, value: self.errorLog.write('MAC Info Failed on %s; Error: %s\n'%(os.path.join(root, afile), value)) self.errorLog.flush() #print "Failed to get information on file: %s Error: %s"%(fullFileName, value) Modified = 'N/A' Size = 'N/A' Created = 'N/A' Accessed = 'N/A' Globals.MimeTypeSet.add(MimeType) hashes = CommonFunctions.GetFileHashesAsDict(fullFileName, bufferSize=1024*1024*16, MD5=True, SHA1=False) KnownFile = 0 MD5 = "N/A" if hashes: if self.dbNSRL: if self.CheckMD5Hash(self.dbNSRL, hashes['MD5']): self.knownFilesLog.write("%s; MD5: %s \n"%(fullFileName, hashes['MD5'])) KnownFilesCount += 1 KnownFile = 1 #return MD5 = hashes['MD5'] mDate, mMonth, aDate, aMonth, cDate, cMonth = self.GetAllMACTimes(Modified, Accessed, Created) FileInfoQueue.put((fileName, dirPath, Extension, MimeType, Category, Description, Size, Created, cDate, cMonth, Modified, mDate, mMonth, Accessed, aDate, aMonth, MD5, KnownFile, "")) #work on image file if MimeType.find("image/") == 0: TotalImages += 1 try: thumbnail = self.GetThumbnail(fullFileName).GetData() #= thumbnail.GetData() except: thumbnail = 'N/A' ThumbnailQueue.put((dirPath, fileName, thumbnail)) #work on zip, rar and other compressed files if zipfile.is_zipfile(fullFileName): if Extension.find("x") == -1 and Extension.find("jar") == -1: unzippedPath = os.path.join(dirPath, fileName) self.HandleRecursiveZipFile(unzippedPath, dirPath, fileName)
except Exception, value: self.errorLog.write('MAC Info Failed; Error: %s\n' % (str(value))) self.errorLog.flush() Modified = 'None' Size = 'None' Created = 'None' Accessed = 'None' #if not newFile.MimeType in Globals.MimeTypeSet: Globals.MimeTypeSet.add(MimeType) hashes = CommonFunctions.GetFileHashesAsDict(fullFileName, bufferSize=1024 * 1024 * 16, MD5=True, SHA1=False) KnownFile = 0 MD5 = "None" if hashes: if self.dbNSRL: if self.CheckMD5Hash(self.dbNSRL, hashes['MD5']): #self.knownFilesLog.write("%s\t\t%s\n"%(unicode(fullFileName), unicode(hashes['MD5']))) self.KnownFilesCount += 1 KnownFile = 1 #return MD5 = hashes['MD5'] mDate, mMonth, aDate, aMonth, cDate, cMonth = self.GetAllMACTimes(