def test_files(self): # outfilename = "test_files" try: clip = FPClip(self.pool) clip.open(clipid, FPLibrary.FP_OPEN_ASTREE) numfiles = clip.getNumBlobs() assert numfiles, "Missing blobs" for i in range(numfiles + 1): blob_id = clip.fetchNext() if not blob_id: break blob_tag = FPTag(blob_id) print(("tag: %r" % blob_tag)) if blob_tag.getBlobSize() < 1: print(("Empty blob %s" % i)) blob_tag.close() continue outfilename = blob_tag.getTagName() print(("tag name : %s" % outfilename)) fh = FPFileOutputStream( "outfile.{name}.{i}".format(name=outfilename, i=i)) print("reading file from centera...") blob_tag.blobRead(fh.stream, 0) print("ok") fh.close() blob_tag.close() finally: print("closing clip") clip.close() assert outfilename, "Missing tag: %r" % outfilename
def getTags(self): """ :return: an iterable of (tag_name, tag_size) """ numfiles = self.getNumBlobs() if not numfiles: return for blob_id in self.getBlobs(): blob_tag = FPTag(blob_id) tag_name = blob_tag.getTagName() blob_size = blob_tag.getBlobSize() blob_tag.close() yield tag_name, blob_size
# clipid = raw_input( "Clip id: " ) clip.open(clipid, FPLibrary.FP_OPEN_ASTREE) for a in "name retention.period numfiles".split(): clip.getDescriptionAttribute(a) top = clip.getTopTag() print("tag: %r" % top) for i in range(clip.getNumBlobs() + 1): blob_id = clip.fetchNext() if not blob_id: break blob_tag = FPTag(blob_id) if blob_tag.getBlobSize() < 1: blob_tag.close() continue print("tag: %r" % blob_tag) file = FPFileOutputStream(outfilename + ".%s" % i) print("reading file from centera...") blob_tag.blobRead(file.stream, 0) print("ok") file.close() blob_tag.close() clip.close() pool.close()