def verify_not_cached(self, ctx, blocks):
     for block in blocks:
         for chk in block[1]:
             full_path = os.path.join(ctx.arch_cache_dir(),
                                      chk_file_name(chk))
             if os.path.exists(full_path):
                 print "Already cached: ", chk
                 self.assertTrue(False)
 def verify_cached(self, ctx, blocks):
     for index, block in enumerate(blocks):
         count = 0
         for ordinal, chk in enumerate(block[1]):
             full_path = os.path.join(ctx.arch_cache_dir(),
                                      chk_file_name(chk))
             if os.path.exists(full_path):
                 print "%s: CACHED" % str((index, ordinal))
                 self.assertTrue(os.path.getsize(full_path) ==
                                 block[0])
                 count += 1
             else:
                 print "%s: MISSING" % str((index, ordinal))
         self.assertTrue(count > 0)
Esempio n. 3
0
def cached_block(cache_dir, uri, block):
    """ Return the file name of a cached block. """
    for chk in block[1]:
        full_path = os.path.join(cache_dir_name(cache_dir, uri),
                                 chk_file_name(chk))
        if os.path.exists(full_path):
            if os.path.getsize(full_path) != block[0]:
                raise IOError("Wrong size: %s, expected: %i, got: %i" %
                              (full_path, block[0],
                               os.path.getsize(full_path)))
            #print "FOUND: ", chk
            return full_path
        #else:
        #    print "MISSING: ", chk

    raise IOError("Not cached: %s" % str(block))