in sample-demo-app/aws_python_sample_application/image_processor.py [0:0]
def run(self):
try:
messages = self._extract_tasks()
if len(messages) == 0:
return
for image_key in messages:
image_name = self._get_name_from_key(image_key)
print("Image name: " + image_name)
image_name_without_file_suffix = image_name.split(".")[-2]
image_file_suffix = image_name.split(".")[-1]
temp_image_path = image_name_without_file_suffix + "-" + str(random.randrange(100000))
self._download_image(image_key, temp_image_path + "." + image_file_suffix)
self.bw_image_processor.monochrome_and_upload(temp_image_path + "." + image_file_suffix)
self.brighten_image_processor.brighten_and_upload(temp_image_path + "." + image_file_suffix)
delete_file(temp_image_path + "." + image_file_suffix)
except Exception as e:
print("Failed to process message from SQS queue...")
print(e)