def FetchBlobsForSignedBinary(
    binary_urn,
    token = None
):
  """Retrieves blobs for the given binary from the datastore.

  Args:
    binary_urn: RDFURN that uniquely identifies the binary.
    token: ACL token to use with the legacy (non-relational) datastore.

  Returns:
    A tuple containing an iterator for all the binary's blobs and an
    RDFDatetime representing when the binary's contents were saved
    to the datastore.

  Raises:
    SignedBinaryNotFoundError: If no signed binary with the given URN exists.
  """
  if _ShouldUseLegacyDatastore():
    try:
      aff4_stream = aff4.FACTORY.Open(
          binary_urn, aff4_type=collects.GRRSignedBlob, mode="r", token=token)
    except aff4.InstantiationError:
      raise SignedBinaryNotFoundError(binary_urn)
    timestamp = aff4_stream.Get(aff4_stream.Schema.TYPE).age
    return (blob for blob in aff4_stream), timestamp
  else:
    try:
      references, timestamp = data_store.REL_DB.ReadSignedBinaryReferences(
          _SignedBinaryIDFromURN(binary_urn))
    except db.UnknownSignedBinaryError:
      raise SignedBinaryNotFoundError(binary_urn)
    blob_ids = [r.blob_id for r in references.items]
    raw_blobs = (data_store.BLOBS.ReadBlob(blob_id) for blob_id in blob_ids)
    blobs = (
        rdf_crypto.SignedBlob.FromSerializedString(raw_blob)
        for raw_blob in raw_blobs)
    return blobs, timestamp
def FetchBlobsForSignedBinary ( binary_urn , token = None ) : if _ShouldUseLegacyDatastore ( ) : try : aff4_stream = aff4 . FACTORY . Open ( binary_urn , aff4_type = collects . GRRSignedBlob , mode = "r" , token = token ) except aff4 . InstantiationError : raise SignedBinaryNotFoundError ( binary_urn ) timestamp = aff4_stream . Get ( aff4_stream . Schema . TYPE ) . age return ( blob for blob in aff4_stream ) , timestamp else : try : references , timestamp = data_store . REL_DB . ReadSignedBinaryReferences ( _SignedBinaryIDFromURN ( binary_urn ) ) except db . UnknownSignedBinaryError : raise SignedBinaryNotFoundError ( binary_urn ) blob_ids = [ r . blob_id for r in references . items ] raw_blobs = ( data_store . BLOBS . ReadBlob ( blob_id ) for blob_id in blob_ids ) blobs = ( rdf_crypto . SignedBlob . FromSerializedString ( raw_blob ) for raw_blob in raw_blobs ) return blobs , timestamp
Retrieves blobs for the given binary from the datastore.

  Args:
    binary_urn: RDFURN that uniquely identifies the binary.
    token: ACL token to use with the legacy (non-relational) datastore.

  Returns:
    A tuple containing an iterator for all the binary's blobs and an
    RDFDatetime representing when the binary's contents were saved
    to the datastore.

  Raises:
    SignedBinaryNotFoundError: If no signed binary with the given URN exists.