def ReadSignedBinaryReferences(self, binary_id, cursor=None): """Reads blob references for the signed binary with the given id.""" cursor.execute( """ SELECT blob_references, UNIX_TIMESTAMP(timestamp) FROM signed_binary_references WHERE binary_type = %s AND binary_path_hash = %s """, [ binary_id.binary_type.SerializeToDataStore(), mysql_utils.Hash(binary_id.path) ]) row = cursor.fetchone() if not row: raise db.UnknownSignedBinaryError(binary_id) raw_references, timestamp = row # TODO(hanuszczak): pytype does not understand overloads, so we have to cast # to a non-optional object. datetime = cast(rdfvalue.RDFDatetime, mysql_utils.TimestampToRDFDatetime(timestamp)) references = rdf_objects.BlobReferences.FromSerializedBytes( raw_references) return references, datetime
def ReadSignedBinaryReferences(self, binary_id): """See db.Database.""" binary_key = _SignedBinaryKeyFromID(binary_id) try: references, timestamp = self.signed_binary_references[binary_key] except KeyError: raise db.UnknownSignedBinaryError(binary_id) return references.Copy(), timestamp.Copy()
def ReadSignedBinaryReferences( self, binary_id: rdf_objects.SignedBinaryID ) -> Tuple[rdf_objects.BlobReferences, rdfvalue.RDFDatetime]: """See db.Database.""" binary_key = _SignedBinaryKeyFromID(binary_id) try: references, timestamp = self.signed_binary_references[binary_key] except KeyError: raise db.UnknownSignedBinaryError(binary_id) return references.Copy(), timestamp.Copy()