Esempio n. 1
0
    def enq_file(self, f):
        """
        f[0] path f[1] mode f[2] size - we enq all in one shot
        CMD = copy src  dest  off_start  last_chunk
        """
        chunks = f.st_size / self.chunksize
        remaining = f.st_size % self.chunksize

        workcnt = 0

        if f.st_size == 0:  # empty file
            ck = ChunkSum(f.path)
            self.enq(ck)
            self.logger.debug("%s" % ck, extra=self.d)
            workcnt += 1
        else:
            for i in range(chunks):
                ck = ChunkSum(f.path)
                ck.offset = i * self.chunksize
                ck.length = self.chunksize
                self.enq(ck)
                self.logger.debug("%s" % ck, extra=self.d)
            workcnt += chunks

        if remaining > 0:
            # send remainder
            ck = ChunkSum(f.path)
            ck.offset = chunks * self.chunksize
            ck.length = remaining
            self.enq(ck)
            self.logger.debug("%s" % ck, extra=self.d)
            workcnt += 1

        # tally work cnt
        self.workcnt += workcnt
Esempio n. 2
0
    def enq_file(self, f):
        """
        f[0] path f[1] mode f[2] size - we enq all in one shot
        CMD = copy src  dest  off_start  last_chunk
        """
        chunks = f.st_size / self.chunksize
        remaining = f.st_size % self.chunksize

        workcnt = 0

        if f.st_size == 0:  # empty file
            ck = ChunkSum(f.path)
            self.enq(ck)
            self.logger.debug("%s" % ck, extra=self.d)
            workcnt += 1
        else:
            for i in range(chunks):
                ck = ChunkSum(f.path)
                ck.offset = i * self.chunksize
                ck.length = self.chunksize
                self.enq(ck)
                self.logger.debug("%s" % ck, extra=self.d)
            workcnt += chunks

        if remaining > 0:
            # send remainder
            ck = ChunkSum(f.path)
            ck.offset = chunks * self.chunksize
            ck.length = remaining
            self.enq(ck)
            self.logger.debug("%s" % ck, extra=self.d)
            workcnt += 1

        # tally work cnt
        self.workcnt += workcnt
Esempio n. 3
0
def gen_chunksum(b, sig):
    b = os.path.relpath(b, sig.prefix)
    try:
        fn, offset, length, digest = b.split("!@")
    except ValueError as e:
        print("Parsing error: %s" % b)
        sys.exit(1)

    c = ChunkSum(fn)
    c.offset = int(offset)
    c.length = int(length)
    c.digest = digest.strip()
    return c
Esempio n. 4
0
def gen_chunksum(b, sig):
    b = os.path.relpath(b, sig.prefix)
    try:
        fn, offset, length, digest = b.split("!@")
    except ValueError as e:
        print("Parsing error: %s" % b)
        sys.exit(1)

    c = ChunkSum(fn)
    c.offset = int(offset)
    c.length = int(length)
    c.digest = digest.strip()
    return c