예제 #1
0
파일: archive.py 프로젝트: guoyu07/PyStow
    def add_mtree(self, mtree_spec, name, timestamp, get_func):
        self.dbg("Stow(<%d>,%s)" % (len(mtree_spec), str(get_func)))

        assert type(mtree_spec) == str
        assert type(name) == str
        assert type(timestamp) == int

        mt = mtree.mtree(mtree_spec)
        if mt.root == None:
            print("XXX: Empty mtree")
            return None

        mtmd5 = self.add_bytes(mtree_spec)
        self.dbg("  mtree_md5 " + mtmd5)

        self.ss = name + "\n"
        self.ss += "%d\n" % timestamp
        self.ss += mtmd5 + "\n"

        def cb(typ, obj, path, indent):
            if typ != 'f':
                return
            if 'md5digest' not in obj.a:
                return
            m = obj.a['md5digest']
            if self.has_entry(m):
                return
            body = get_func(path, obj.a['md5digest'])
            if body == None:
                self.dbg("  - " + path)
                return
            x = self.add_bytes(body)
            if x != m:
                self.ss += m + " -> " + x + "\n"
                self.dbg("  m " + path + " <%d> " % len(body) + "%s -> %s" %
                         (m, x))
                return
            self.dbg("  + " + path + " <%d> " % len(body) + " " + x)

        mt.tree(cb)

        self.add_entry("INDEX_%d" % timestamp, "mtree", self.ss)
        return mtmd5
예제 #2
0
파일: archive.py 프로젝트: bsdphk/PyStow
	def add_mtree(self, mtree_spec, name, timestamp, get_func):
		self.dbg("Stow(<%d>,%s)" % (len(mtree_spec), str(get_func)))

		assert type(mtree_spec) == str
		assert type(name) == str
		assert type(timestamp) == int

		mt = mtree.mtree(mtree_spec)
		if mt.root == None:
			print("XXX: Empty mtree")
			return None

		mtmd5 = self.add_bytes(mtree_spec)
		self.dbg("  mtree_md5 " + mtmd5)

		self.ss = name + "\n"
		self.ss += "%d\n" % timestamp
		self.ss += mtmd5 + "\n"

		def cb(typ, obj, path, indent):
			if typ != 'f':
				return
			if 'md5digest' not in obj.a:
				return
			m = obj.a['md5digest']
			if self.has_entry(m):
				return
			body = get_func(path, obj.a['md5digest'])
			if body == None:
				self.dbg("  - " + path)
				return
			x = self.add_bytes(body)
			if x != m:
				self.ss += m + " -> " + x + "\n"
				self.dbg("  m " + path + " <%d> " % len(body) + "%s -> %s" % (m, x))
				return
			self.dbg("  + " + path + " <%d> " % len(body) + " " + x)

		mt.tree(cb)

		self.add_entry("INDEX_%d" % timestamp, "mtree", self.ss)
		return mtmd5
예제 #3
0
파일: archive.py 프로젝트: bsdphk/PyStow
	for i in lidx:
		print(i)
		sys.stdout.flush()
		j,m,b = s.get_entry(i)
		if m != "mtree":
			print("XXX: method=\"%s\"" % m, i, j)
			continue
		l = b.splitlines()
		print(i,j,m,l)
		im5 = l[2]
		mtr = s.get_bytes(im5)
		if mtr == None:
			print("XXX: get mtree failed", i, im5)
			continue
		print("XX: ", len(mtr))
		mx = mtree.mtree(mtr)

		def cb(typ, obj, path, indent):
			if typ != 'f':
				return
			if 'md5digest' not in obj.a:
				return
			md = obj.a['md5digest']
			if md in chkd:
				if chkd[md] == False:
					print("XXX Missing", md, l[0], l[1], path)
				return
			bb = s.get_bytes(md)
			if bb == None:
				print("XXX Missing", md, l[0], l[1], path)
				sys.stdout.flush()
예제 #4
0
파일: archive.py 프로젝트: guoyu07/PyStow
    for i in lidx:
        print(i)
        sys.stdout.flush()
        j, m, b = s.get_entry(i)
        if m != "mtree":
            print("XXX: method=\"%s\"" % m, i, j)
            continue
        l = b.splitlines()
        print(i, j, m, l)
        im5 = l[2]
        mtr = s.get_bytes(im5)
        if mtr == None:
            print("XXX: get mtree failed", i, im5)
            continue
        print("XX: ", len(mtr))
        mx = mtree.mtree(mtr)

        def cb(typ, obj, path, indent):
            if typ != 'f':
                return
            if 'md5digest' not in obj.a:
                return
            md = obj.a['md5digest']
            if md in chkd:
                if chkd[md] == False:
                    print("XXX Missing", md, l[0], l[1], path)
                return
            bb = s.get_bytes(md)
            if bb == None:
                print("XXX Missing", md, l[0], l[1], path)
                sys.stdout.flush()