Ejemplo n.º 1
0
    def gen_digest(self, filepath):
        NOCARE_FILES = ['digest.md5', 'skipfiles.txt']
        #gamelist = self.getGameList()
        #for game in gamelist:
        if True:
            try:
                filepath = filepath.strip().lower()
                filepath = os.path.normpath(filepath)
                if filepath[-1] == '\\':  #rid of terminated character
                    filepath = filepath[:-1]
                file = "%s/digest.md5" % filepath

                fp = open(file, 'w')
                self.getLogger().debug(u"扫描文件目录(%s)..." % (filepath))
                #不能记录game.path前缀
                for root, dirs, files in os.walk(filepath, topdown=False):
                    for name in files:
                        if NOCARE_FILES.count(name) != 0:
                            continue
                        file = os.path.join(root, name).lower().strip()
                        size = os.stat(file).st_size
                        digest = codec.calcFileMd5Digest(file)
                        if size == 0:
                            #print file,size,digest
                            #return
                            pass
                        idx = file.index(filepath)
                        file = file[idx + len(filepath):]  #保留\
                        fp.write(file + DELIMITER + str(size) + DELIMITER +
                                 digest + "\n")
                fp.close()
            except:
                print traceback.print_exc()
        pass
Ejemplo n.º 2
0
 def getFileDigest(self, file, current=None):
     digest = ''
     try:
         digest = codec.calcFileMd5Digest(file)
     except:
         pass
     return digest
Ejemplo n.º 3
0
	def gen_digest(self):
		NOCARE_FILES=['digest.md5','skipfiles.txt']
		gamelist = self.getGameList()
		for game in gamelist:
			try:
				file = "%s/digest.md5"%game.path
				fp = open(file,'w')
				self.getLogger().debug("scan game(%s,%s)..."%(game.name,game.path))
				#扫描游戏目录
				#不能记录game.path前缀
				for root, dirs, files in os.walk(game.path, topdown=False):
					for name in files:
						if NOCARE_FILES.count(name)!=0:
							continue
						file = os.path.join(root, name).lower()
						size = os.stat(file).st_size
						digest = codec.calcFileMd5Digest(file)
						if size == 0:
							#print file,size,digest
							#return
							pass
						idx = file.index(game.path)						
						file = file[idx+len(game.path):]
						fp.write(file+DELIMITER+str(size)+DELIMITER+digest+"\n")
				fp.close()
			except:
				print traceback.print_exc()
		pass	
Ejemplo n.º 4
0
	def gen_digest(self):
		gamelist = self.getGameList()
		for game in gamelist:
			try:
				#game.path = game.path.decode('utf-8') #还原为默认utf16编码
				file = "%s/digest.md5"%game.path
				fp = open(file,'w')
				self.getLogger().debug("scan game(%s,%s)..."%(game.name,game.path))
				#扫描游戏目录
				#不能记录game.path前缀
				
				for root, dirs, files in os.walk(game.path, topdown=False):
					for name in files:
						if name =='digest.md5':
							continue
						file = os.path.join(root, name)
						size = os.stat(file).st_size
						digest = codec.calcFileMd5Digest(file)
						if size == 0:
							#print file,size,digest
							#return
							pass
						#print file
						idx = file.index(game.path)						
						file = file[idx+len(game.path):]
						file = file.encode('utf-8') #存储时写入utf8编码
						fp.write(file+DELIMITER+str(size)+DELIMITER+digest+"\n")
				fp.close()
			except:
				print traceback.print_exc()
		pass	
Ejemplo n.º 5
0
 def gen_digest(self):
     NOCARE_FILES = ['digest.md5', 'skipfiles.txt']
     gamelist = self.getGameList()
     for game in gamelist:
         try:
             file = "%s/digest.md5" % game.path
             fp = open(file, 'w')
             self.getLogger().debug("scan game(%s,%s)..." %
                                    (game.name, game.path))
             #扫描游戏目录
             #不能记录game.path前缀
             for root, dirs, files in os.walk(game.path, topdown=False):
                 for name in files:
                     if NOCARE_FILES.count(name) != 0:
                         continue
                     file = os.path.join(root, name).lower()
                     size = os.stat(file).st_size
                     digest = codec.calcFileMd5Digest(file)
                     if size == 0:
                         #print file,size,digest
                         #return
                         pass
                     idx = file.index(game.path)
                     file = file[idx + len(game.path):]
                     fp.write(file + DELIMITER + str(size) + DELIMITER +
                              digest + "\n")
             fp.close()
         except:
             print traceback.print_exc()
     pass
Ejemplo n.º 6
0
	def gen_digest(self,filepath):
		NOCARE_FILES=['digest.md5','skipfiles.txt']
		#gamelist = self.getGameList()
		#for game in gamelist:
		if True:
			try:
				filepath = filepath.strip().lower()
				filepath = os.path.normpath(filepath)
				if filepath[-1]=='\\': #rid of terminated character
					filepath=filepath[:-1]				
				file = "%s/digest.md5"%filepath
				
				fp = open(file,'w')
				self.getLogger().debug(u"扫描文件目录(%s)..."%(filepath))				
				#不能记录game.path前缀
				for root, dirs, files in os.walk(filepath, topdown=False):
					for name in files:
						if NOCARE_FILES.count(name)!=0:
							continue
						file = os.path.join(root, name).lower().strip()
						size = os.stat(file).st_size
						digest = codec.calcFileMd5Digest(file)
						if size == 0:
							#print file,size,digest
							#return
							pass
						idx = file.index(filepath)
						file = file[idx+len(filepath):] #保留\
						fp.write(file+DELIMITER+str(size)+DELIMITER+digest+"\n")
				fp.close()
			except:
				print traceback.print_exc()
		pass	
Ejemplo n.º 7
0
    def getFileDescList(self, path, current=None):
        rs = []
        try:
            print "calc digest and return..."
            #print ">>getFileDescList:%s"%path
            path = path.decode('utf-8')
            print path
            for root, dirs, files in os.walk(path, topdown=False):
                for name in files:
                    root = root.decode('utf-8')
                    name = name.decode('utf-8')
                    #file = os.path.join(root, name)
                    file = "%s/%s" % (root, name)
                    print file
                    #file = file.encode('utf-8')
                    fe = FileEntryT()
                    fe.size = os.stat(file).st_size
                    fe.timestamp = 0
                    fe.digest = codec.calcFileMd5Digest(file)

                    idx = file.index(path)
                    file = file[idx + len(path):]
                    fe.filename = file
                    rs.append(fe)
                    print fe
        except:
            print traceback.print_exc()
            pass
        #print str(rs)
        print rs
        return rs
Ejemplo n.º 8
0
def getFileDescList(self, path, current=None):
	rs=[]
	try:
		for root, dirs, files in os.walk(path, topdown=False):
			for name in files:
				file = os.path.join(root, name)
				fe = FileEntryT()
				fe.filename = file
				fe.size = os.stat(file).st_size
				fe.timestamp = 0
				fe.digest = codec.calcFileMd5Digest(file)
				rs.append(fe)
	except:
		pass
	return rs
Ejemplo n.º 9
0
def getFileDescList(self, path, current=None):
	rs=[]
	try:
		for root, dirs, files in os.walk(path, topdown=False):
			for name in files:
				file = os.path.join(root, name)
				fe = FileEntryT()
				fe.filename = file
				fe.size = os.stat(file).st_size
				fe.timestamp = 0
				fe.digest = codec.calcFileMd5Digest(file)
				rs.append(fe)
	except:
		pass
	return rs
Ejemplo n.º 10
0
    def getFileDescList(self, path, current=None):
        rs = []
        try:
            print "calc digest and return..."
            #print ">>getFileDescList:%s"%path
            for root, dirs, files in os.walk(path, topdown=False):
                for name in files:
                    file = os.path.join(root, name)
                    fe = FileEntryT()
                    fe.filename = file.lower()
                    fe.size = os.stat(file).st_size
                    fe.timestamp = 0
                    fe.digest = codec.calcFileMd5Digest(file)
                    rs.append(fe)
        except:
            print traceback.print_exc()
            pass
        #print str(rs)

        return rs