Exemple #1
0
def process_message(message):
    logger.debug("process_message()")

    message_body = json.loads(message.body)

    if 'message' in message_body and message_body['message'] == "event::call-bunny":
        params = message_body.get('params')
        if params is None:
            logger.error('Empty params in message')
            return False
        job_id = params.get('jobId')
        source = params.get('source')
        dlcs_id = params.get('dlcsId')
        encoded_formats = params.get('formats')
        decoded_formats = base64.b64decode(encoded_formats)
        formats = json.loads(decoded_formats)
        outputs = []
        for format in formats:
            outputs.append({
                'Key': format.get('destination'),
                'PresetId': get_preset_id(format.get('transcodePolicy'))
            })
        # outputs = map(lambda o: {'Key': o.get('destination'),
        #                             'PresetId': get_preset_id(o.get('transcodePolicy'))}, formats)
        logger.debug("transcoding for jobId: %s" % (job_id,))

        transcodeJob = transcode_video(job_id, dlcs_id, source, outputs)
        if transcodeJob is None:
            raise Exception("transcode job creation failed")

        metadataKey = "%s/metadata" % (dlcs_id)
        metadataBody = '<JobInProgress><ElasticTranscoderJob>%s</ElasticTranscoderJob></JobInProgress>' % transcodeJob
        aws.put_s3_object(s3, settings.METADATA_BUCKET, metadataKey, metadataBody)
    else:
        logger.info("Unknown message type received")
        return False, "Unknown message type"
    def store_json(self, image_uri, json_data):

        logging.debug("storing index data in s3 for %s", image_uri)
        encoded_uri = quote_plus(image_uri)
        aws.put_s3_object(self.s3, settings.INDEX_BUCKET, encoded_uri,
                          json_data)
Exemple #3
0
def store_job_data(bucket, key, data):
    aws.put_s3_object(s3, bucket, key, data)
    def store_metadata(self, image_uri, metadata):

        logging.debug("storing metadata in s3 for %s", image_uri)
        encoded_uri = quote_plus(image_uri)
        aws.put_s3_object(self.s3, settings.TEXT_METADATA_BUCKET, encoded_uri,
                          metadata)