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
retention = raw_input( "Retention (in seconds): " ) clip.setRetentionPeriod( long(retention) ) top_handle = clip.getTopTag() blob_tag = FPTag( top_handle, "file" ) filename = raw_input( "Filename: " ) file = FPFileInputStream( filename, 16*1024 ) blob_tag.blobWrite( file.stream, 0 ) file.close() blob_tag.close() clipid = clip.write() print clipid clip.close() pool.close() except FPClientException, c: print c traceback.print_exc(file=sys.stdout) except FPServerException, s: print s except FPNetException, n:
retention = raw_input("Retention (in seconds): ") clip.setRetentionPeriod(long(retention)) top_handle = clip.getTopTag() blob_tag = FPTag(top_handle, "file") filename = raw_input("Filename: ") file = FPFileInputStream(filename, 16 * 1024) blob_tag.blobWrite(file.stream, 0) file.close() blob_tag.close() clipid = clip.write() print clipid clip.close() pool.close() except FPClientException, c: print c traceback.print_exc(file=sys.stdout) except FPServerException, s: print s except FPNetException, n: