Active Member Koray 1998 Posted February 17, 2015 Active Member Share Posted February 17, 2015 import md5,zlib,os import sys #import app SUBFOLDER_CHECK = 0 target_folder = "D:/M2/Pvp/" LogFile = 'Gtools_log.txt' if not os.path.exists(LogFile): a=open(LogFile, "a") a.close() def Log(wut): yaz=open(LogFile, "w") yaz.write(wut) yaz.close() def Hata(wut): Log(wut) os.popen("start " + LogFile) #app.Exit() def GetCrc(fileName): prev = 0 for eachLine in open(fileName,"rb"): prev = zlib.crc32(eachLine, prev) crccikti = str("%X"%(prev & 0xFFFFFFFF)) return crccikti.lower() def GetMd5(file): m = md5.new() fp = open(file,"rb") while 1: data = fp.read(1024) if not data:break m.update(data) fp.close() hashcikti = m.hexdigest() return hashcikti.lower() def GetSize(file): return str(os.path.getsize(file)) def ReturnHash(file,size,md5,crc): if GetMd5(file) != md5 : Hata("WRONG Md5: " + file) elif GetCrc(file) != crc: Hata("WRONG Crc: " + file) elif GetSize(file) != size: Hata("WRONG Size: " + file) def SetFolderData(s): setdata=open(LogFile, "a") setdata.writelines(s + 'n') setdata.close() def GetFolderData(): global target_folder r = "" newlist = [] liste = [f for f in os.listdir(target_folder) if os.path.isfile] if not SUBFOLDER_CHECK: for i in xrange(len(liste)): for c in liste: if int(GetSize(target_folder + c)) > 0: if "." in c: newlist.append© break for q in xrange(len(newlist)): for v in newlist: print "FILE: " + target_folder + v + " SIZE: " + str(GetSize(target_folder + v)) + " MD5: " + GetMd5(target_folder + v) + " CRC: " + GetCrc(target_folder + v) SetFolderData(" ['" + target_folder + v + "','" + str(GetSize(target_folder + v)) + "','" + GetMd5(target_folder + v) + "','" + GetCrc(target_folder + v) + "']") break os.popen("start "+os.getcwd()+""+LogFile) if SUBFOLDER_CHECK: for root, dirs, files in os.walk(target_folder): path = root.split('/') for file in files: if not path[-1] == "": r = '/' cikti = target_folder+str(path[-1])+r+file print cikti SetFolderData(" ['" + target_folder.split("/")[-1]+str(path[-1])+r+file + "','" + str(GetSize(cikti)) + "','" + GetMd5(cikti) + "','" + GetCrc(cikti) + "']") os.popen("start "+os.getcwd()+""+LogFile) def Control(): # FILE SIZE MD5 CRC FileList = [ ['uitaskbar.py','59801','38365e196f9d26dadf85a4e253f638c7','b1a49039'], ['uitaskbar.pyc','49195','b2df8f9ba38a3db44baa648a4bfd705f','6ddf37d4'], ] for i in xrange(len(FileList)): for x in FileList: ReturnHash(x[0], x[1], x[2], x[3]) break ###IF GET HASH #GetFolderData() ###IF CHECK HASH Control() Mirror I writing simple directory check script, you can check folder and subfolders hash(crc, md5) and size check If you can get folder hash values activate Control() func, If you can check folder hash values activate GetFolderData() func. 4 Link to comment Share on other sites More sharing options...
vagabond20 102 Posted March 4, 2015 Share Posted March 4, 2015 Thanks bro. 1 Link to comment Share on other sites More sharing options...
gamerteam500 9 Posted December 18, 2015 Share Posted December 18, 2015 We are adding detail where you configure it bro? Link to comment Share on other sites More sharing options...
Recommended Posts