def ingest(event):
<EOL>set_service_status(Service.INGEST, ServiceStatus.BUSY)<EOL>notify.notify('<STR_LIT>')<EOL>recording_state(event.uid, '<STR_LIT>')<EOL>update_event_status(event, Status.UPLOADING)<EOL>service = config('<STR_LIT>')<EOL>service = service[randrange(<NUM_LIT:0>, len(service))]<EOL>logger.info('<STR_LIT>' + service)<EOL>logger.info('<STR_LIT>')<EOL>mediapackage = http_request(service + '<STR_LIT>')<EOL>prop = '<STR_LIT>'<EOL>dcns = '<STR_LIT>'<EOL>for attachment in event.get_data().get('<STR_LIT>'):<EOL><INDENT>data = attachment.get('<STR_LIT:data>')<EOL>if attachment.get('<STR_LIT>') == prop:<EOL><INDENT>workflow_def, workflow_config = get_config_params(data)<EOL><DEDENT>elif attachment.get('<STR_LIT>') == '<STR_LIT>' and dcns in data:<EOL><INDENT>name = attachment.get('<STR_LIT>', '<STR_LIT>').rsplit('<STR_LIT:.>', <NUM_LIT:1>)[<NUM_LIT:0>]<EOL>logger.info('<STR_LIT>' % name)<EOL>fields = [('<STR_LIT>', mediapackage),<EOL>('<STR_LIT>', '<STR_LIT>' % name),<EOL>('<STR_LIT>', data.encode('<STR_LIT:utf-8>'))]<EOL>mediapackage = http_request(service + '<STR_LIT>', fields)<EOL><DEDENT><DEDENT>for (flavor, track) in event.get_tracks():<EOL><INDENT>logger.info('<STR_LIT>'.format(flavor, track))<EOL>track = track.encode('<STR_LIT:ascii>', '<STR_LIT:ignore>')<EOL>fields = [('<STR_LIT>', mediapackage), ('<STR_LIT>', flavor),<EOL>('<STR_LIT>', (pycurl.FORM_FILE, track))]<EOL>mediapackage = http_request(service + '<STR_LIT>', fields)<EOL><DEDENT>logger.info('<STR_LIT>')<EOL>fields = [('<STR_LIT>', mediapackage)]<EOL>if workflow_def:<EOL><INDENT>fields.append(('<STR_LIT>', workflow_def))<EOL><DEDENT>if event.uid:<EOL><INDENT>fields.append(('<STR_LIT>',<EOL>event.uid.encode('<STR_LIT:ascii>', '<STR_LIT:ignore>')))<EOL><DEDENT>fields += workflow_config<EOL>mediapackage = http_request(service + '<STR_LIT>', fields)<EOL>recording_state(event.uid, '<STR_LIT>')<EOL>update_event_status(event, Status.FINISHED_UPLOADING)<EOL>notify.notify('<STR_LIT>')<EOL>set_service_status_immediate(Service.INGEST, ServiceStatus.IDLE)<EOL>logger.info('<STR_LIT>')<EOL>
Ingest a finished recording to the Opencast server.