in rabbitmq/vidispine_message_processor.py [0:0]
def handle_notification(self, notification:JobNotification, routing_key:str):
"""
takes a constructed JobNotification, works out what it means and performs the relevant actions
:param notification: JobNotification instance
:param routing_key: routing key with which this was sent
:return: none
"""
try:
asset = DeliverableAsset.objects.get(job_id=notification.jobId)
except DeliverableAsset.DoesNotExist:
logger.warning("Received a message for job {0}. Cannot find a matching asset.".format(notification.jobId))
return
if notification.status in ['FAILED_TOTAL', 'ABORTED_PENDING', 'ABORTED']:
if notification.type == 'TRANSCODE':
asset.status = DELIVERABLE_ASSET_STATUS_TRANSCODE_FAILED
else:
asset.status = DELIVERABLE_ASSET_STATUS_INGEST_FAILED
asset.ingest_complete_dt = get_current_time()
asset.save()
elif notification.status == 'READY' or notification.status == 'STARTED' or notification.status == 'VIDINET_JOB':
if notification.type == 'TRANSCODE':
asset.status = DELIVERABLE_ASSET_STATUS_TRANSCODING
else:
asset.status = DELIVERABLE_ASSET_STATUS_INGESTING
asset.save()
elif notification.status in ['FINISHED','FINISHED_WARNING']:
if notification.type == 'TRANSCODE':
asset.status = DELIVERABLE_ASSET_STATUS_TRANSCODED
duration_seconds, version = self.get_item_metadata(notification.itemId)
try:
asset.version = int(version)
except ValueError as e:
logger.warning("{0}: asset version '{1}' could not be converted into number".format(notification.itemId, version))
asset.duration_seconds = duration_seconds
asset.ingest_complete_dt = get_current_time()
else:
asset.online_item_id = notification.itemId
if asset.type in self.DONT_TRANSCODE_THESE_TYPES:
asset.status = DELIVERABLE_ASSET_STATUS_TRANSCODED
else:
asset.status = DELIVERABLE_ASSET_STATUS_INGESTED
if routing_key == 'vidispine.job.essence_version.stop':
try:
asset.create_proxy()
except Exception as e:
logger.exception(
"{0} for asset {1} in bundle {2}: could not create proxy due to:".format(
asset.online_item_id,
asset.id,
asset.deliverable.id),
exc_info=e)
asset.save()