dir1, dir2 = sys.argv[1:3] for i in xrange(1000): dir1fn = "%s/%s" % (dir1, i) dir2fn = "%s/%s" % (dir2, i) # Write signature file f1 = open(dir1fn, "rb") sigfile = open("sig", "wb") librsync.filesig(f1, sigfile, 2048) f1.close() sigfile.close() # Write delta file f2 = open(dir2fn, "r") sigfile = open("sig", "rb") deltafile = open("delta", "wb") librsync.filerdelta(sigfile, f2, deltafile) f2.close() sigfile.close() deltafile.close() # Write patched file f1 = open(dir1fn, "rb") newfile = open("%s/%s.out" % (dir1, i), "wb") deltafile = open("delta", "rb") librsync.filepatch(f1, deltafile, newfile) f1.close() deltafile.close() newfile.close()
#!/usr/bin/env python import os, sys, librsync from testdata import * old = "oldfile.bin" new = "newfile.bin" sig = "sigfileT.bin" dif = "diffileT.bin" upd = "updfileT.bin" olddata = get_olddata(old, 256 * KB) newdata = get_newdata(new, olddata) librsync.rs_trace_set_level(librsync.RS_LOG_DEBUG) s = librsync.filesig(open(old, "rb"), open(sig, "wb"), 1024) print s s = librsync.filerdelta(open(sig, "rb"), open(new, "rb"), open(dif, "wb")) print s s = librsync.filepatch(open(old, "rb"), open(dif, "rb"), open(upd, "wb")) print s
#!/usr/bin/env python import os, sys, librsync from testdata import * old = "oldfile.bin" new = "newfile.bin" sig = "sigfileT.bin" dif = "diffileT.bin" upd = "updfileT.bin" olddata = get_olddata(old, 256 * KB) newdata = get_newdata(new, olddata) librsync.rs_trace_set_level(librsync.RS_LOG_DEBUG) s = librsync.filesig(open(old, 'rb'), open(sig, 'wb'), 1024) print s s = librsync.filerdelta(open(sig, 'rb'), open(new, 'rb'), open(dif, 'wb')) print s s = librsync.filepatch(open(old, 'rb'), open(dif, 'rb'), open(upd, 'wb')) print s
for i in xrange(1000): dir1fn = "%s/%s" % (dir1, i) dir2fn = "%s/%s" % (dir2, i) # Write signature file f1 = open(dir1fn, "rb") sigfile = open("sig", "wb") librsync.filesig(f1, sigfile, 2048) f1.close() sigfile.close() # Write delta file f2 = open(dir2fn, "r") sigfile = open("sig", "rb") deltafile = open("delta", "wb") librsync.filerdelta(sigfile, f2, deltafile) f2.close() sigfile.close() deltafile.close() # Write patched file f1 = open(dir1fn, "rb") newfile = open("%s/%s.out" % (dir1, i), "wb") deltafile = open("delta", "rb") librsync.filepatch(f1, deltafile, newfile) f1.close() deltafile.close() newfile.close()