"""Script for executing the lambda locally against AWS Dev.""" import os from src import app as index os.environ['OWSREQUEST_SERVICE_MAP'] = '{"ows-asset-transcoder": "localhost:5001"}' processing_status = { 'Records': [ { 'Sns': { 'Subject': None, 'Message': '{"status": "processing", "errors": null, "input": {"key": ' '"81a0289f_d674_4aab_ab95_333dc61fb331.wav", "bucket": "dev-orcd-asset-transcoder-input"}}', 'Timestamp': '2020-05-19T19:07:13.041Z' } } ] } audio_waveform_success = { 'Records': [ { 'Sns': { 'Subject': None, 'Message': '{"status": "waveform_completed", "final_assets": [{"key": ' '"e2ce85c9_1bbc_4e47_9132_144e5671166d.dat", "asset_type": "DAT", "asset_subtype": null}], ' '"input": {"key": "bb1ad880_e62f_47c7_87c3_fdb4e8a2566f.wav", "bucket": ' '"dev-orcd-asset-transcoder-input"}}', 'Timestamp': '2020-06-03T20:08:52.329Z' } } ] } audio_waveform_error = { 'Records': [ { 'Sns': { 'Subject': None, 'Message': '{"status": "error", "errors": {"audio_waveform_error": "An error occurred during the audio ' 'waveform generation. Error message: expected str, bytes or os.PathLike object, ' 'not NoneType"}, "input": {"key": "81a0289f_d674_4aab_ab95_333dc61fb331.wav", ' '"bucket": "dev-orcd-asset-transcoder-input"}}', 'Timestamp': '2020-05-19T19:16:25.578Z' } } ] } image_encoding_error = { 'Records': [ { 'Sns': { 'Subject': None, 'Message': '{"status": "error", "errors": {"image_encoding_error": "An error occurred during the ' 'encoding. Error message: \'tuple\' object has no attribute \'ljust\'"}, "input": {"key": ' '"efb71882_b187_4d73_b14f_94753e263904.tif", "bucket": "dev-orcd-asset-transcoder-input"}}', 'Timestamp': '2020-05-19T19:09:50.478Z' } } ] } image_encoding_success = { 'Records': [ { 'Sns': { 'Subject': None, 'Message': '{"status": "completed", "final_assets": [{"key": "images/cover/' '5d8009dc_3d71_47d1_977d_d690e09b50e3_6b5ae514_d7a1_4e31_9402_1f2ce49929c5.jpeg", ' '"asset_type": "JPG", "asset_subtype": "cover"}, {"key": "images/large_cover/' '1ec685a1_e05b_4b05_a3b6_8d91dd9b5fe6_6b5ae514_d7a1_4e31_9402_1f2ce49929c5.jpeg", ' '"asset_type": "JPG", "asset_subtype": "large_cover"}, {"key": "images/xlarge_cover/' 'e0a0af1f_0bcb_41c6_b4b1_0e1656abb843_6b5ae514_d7a1_4e31_9402_1f2ce49929c5.jpeg", ' '"asset_type": "JPG", "asset_subtype": "xlarge_cover"}, {"key": "images/tif/' 'b264b582_0039_4f8b_923b_377bd2cdeff1_6b5ae514_d7a1_4e31_9402_1f2ce49929c5.tif", ' '"asset_type": "TIF", "asset_subtype": null}], "input": {"key": ' '"6b5ae514_d7a1_4e31_9402_1f2ce49929c5.jpg", "bucket": "dev-orcd-asset-transcoder-input"}}', 'Timestamp': '2020-06-02T21:01:12.689Z' } } ] } audio_encoding_success = { 'Records': [ { 'Sns': { 'Subject': 'Amazon Elastic Transcoder has finished transcoding job 1591131847133-vt306g.', 'Message': '{"state": "COMPLETED","version": "2012-09-25","jobId": "1591131847133-vt306g",' '"pipelineId": "1581101525157-xjcv85","input": {"key": ' '"fbaa96d4_5ea3_430a_b712_385c8a67f501.wav"},"inputCount": 1,"outputs": [{"id": "1",' '"presetId": "1351620000001-300110", "key": "1db43bfa_d8e8_4c1d_88cf_41fb21549434.flac",' '"status": "Complete", "duration": 36}, {"id": "2", "presetId": ' '"1351620000001-300010", "key": "17ad883b_4fff_45bb_a235_c25b88e5a016.mp3", "status":' '"Complete", "duration": 36}]}', 'Timestamp': '2020-06-02T21:04:12.896Z', } } ] } audio_encoding_error = { 'Records': [ { 'Sns': { 'Subject': 'The Amazon Elastic Transcoder job 1591199434601-9by88e has failed.', 'Message': '{"state": "ERROR","errorCode": 4000,"messageDetails": ' '"4000 0e78cd2e-77b5-4702-9c55-72a45398e245: Amazon Elastic Transcoder could not interpret ' 'the media file.","version": "2012-09-25","jobId": "1591199434601-9by88e","pipelineId": ' '"1581101525157-xjcv85","input": {"key": "017a3220_1f5f_4364_a93c_b10dccda7054.tif"},' '"inputCount": 1,"outputs": [{"id": "1", "presetId": "1351620000001-300010", ' '"key": "encoding-image.mp3", "thumbnailPattern": "", "status": "Error", ' '"statusDetail": "4000 0e78cd2e-77b5-4702-9c55-72a45398e245: Amazon Elastic Transcoder ' 'could not interpret the media file.", "errorCode": 4000}]}', 'Timestamp': '2020-06-03T15:50:39.592Z' } } ] } if __name__ == '__main__': for event in [processing_status, audio_encoding_success, audio_waveform_error, image_encoding_error, image_encoding_success, audio_encoding_success, audio_encoding_error]: print(index.sns_event_get_final_status_details(event))