geia sas. sygnwmh pou den mporw na grapsw ellhnika alla den to dexetai sto pc mou. grafw se python k uelw na sygrinw arxeia. na blepw an einai ola panomoiotupa k otan den einai na exw ena mnma oti diaferoun ekei k ekei. poia einai h kaluterh me8odos na to kanw? sas parakalw xreiazomai thn boh8eia sas. pws 8a eimai ekato ta ekato sigourh pws mporw na sbhsw ta arxika? mexri twra exw auto:
import os, sys, traceback
import hashlib
import stat
import mmap
import traceback
import multiprocessing
from multiprocessing import Process, JoinableQueue
inst_name = "in14"
dir1="/users/serdon/in14"
dir ="/users/experiment_in14"
num_procs = multiprocessing.cpu_count()
num_procs *= 4
def get_hash(fh, sz):
h = hashlib.sha1()
while True:
buf = fh.read(65536)
if len(buf) == 0: break
h.update(buf)
return h.digest()
def chk(path, lf, dir):
path = os.path.join(dir, path)
st = None
st1 = None
try:
st = os.lstat(path)
st1 = os.lstat(path)
except:
lf.write("Missing from the copy: " + path + "\n")
lf.flush()
return
if not stat.S_ISREG(st.st_mode):
return
if st.st_size != st1.st_size:
lf.write("c.Size differ: " + path + "\n")
lf.flush()
return
if st.st_size == 0: return
hv = None
hv1 = None
try:
fh = open(path, "r")
hv = get_hash(fh, st.st_size)
fh.close()
fh = open(path, "r")
hv1 = get_hash(fh, st.st_size)
fh.close()
except:
lf.write("c.Open error: " + path + "\n")
lf.flush()
return
if hv != hv1:
lf.write("c.Digests differ: " + path + "\n")
lf.flush()
def proc_chk(q, lf, dir):
while True:
path = q.get()
if path == "done":
break
chk(path, lf, dir)
q.task_done()
q.task_done()
q = JoinableQueue()
lf = open("/var/tmp/differ_files2", "w+")
path = os.path.realpath(sys.argv[0])
path1 = os.path.realpath(sys.argv[1])
o_cwd = os.getcwd()
os.chdir(dir)
cwd = os.getcwd()
for i in range(0, num_procs):
p = Process(target=proc_chk, args=(q, lf, dir1))
p.start()
for dirpath, dirnames, filenames in os.walk(".", followlinks=False):
for f in filenames:
q.put(os.path.join(dirpath, f))
for i in range(0, num_procs):
q.put("done")
q.join()
lf.close()
os.chdir(o_cwd)
###############################################
import os, sys, traceback
import hashlib
import stat
import mmap
import traceback
import multiprocessing
from multiprocessing import Process, JoinableQueue
inst_name = "in14"
dir="/users/serdon/in14"
dir1 ="/users/experiment_in14"
num_procs = multiprocessing.cpu_count()
num_procs *= 4
def get_hash(fh, sz):
h = hashlib.sha1()
while True:
buf = fh.read(65536)
if len(buf) == 0: break
h.update(buf)
return h.digest()
def chk(path, lf, dir):
path1 = os.path.join(dir, path)
st = None
st1 = None
try:
st = os.lstat(path)
st1 = os.lstat(path1)
except:
lf.write("Missing from the original: " + path1 + "\n")
lf.flush()
return
if not stat.S_ISREG(st.st_mode):
return
if st.st_size != st1.st_size:
lf.write("o.Size differ: " + path1 + "\n")
lf.flush()
return
if st.st_size == 0: return
hv = None
hv1 = None
try:
fh = open(path, "r")
hv = get_hash(fh, st.st_size)
fh.close()
fh = open(path1, "r")
hv1 = get_hash(fh, st.st_size)
fh.close()
except:
lf.write("Open error: " + path1 + "\n")
lf.flush()
return
if hv != hv1:
lf.write("o.Digests differ: " + path1 + "\n")
lf.flush()
def proc_chk(q, lf, dir):
while True:
path1 = q.get()
if path1 == "done":
break
chk(path1, lf, dir)
q.task_done()
q.task_done()
q = JoinableQueue()
lf = open("/var/tmp/differ_files2", "a+")
path = os.path.realpath(sys.argv[0])
path1 = os.path.realpath(sys.argv[1])
o_cwd = os.getcwd()
os.chdir(dir)
cwd = os.getcwd()
for i in range(0, num_procs):
p = Process(target=proc_chk, args=(q, lf, dir1))
p.start()
for dirpath, dirnames, filenames in os.walk(".", followlinks=False):
for f in filenames:
q.put(os.path.join(dirpath, f))
for i in range(0, num_procs):
q.put("done")
q.join()
lf.close()
os.chdir(o_cwd)
k leitoyrgei mia xara to 8ema einai pws mou zhthsan me to na elenxw ta koina shmeia me to dircmp and compare trees. poia h gnwmh sas gi auto?