in Bot2/ImageUpdate/hello_world/twitterUpdateImage.py [0:0]
def process_messages(auth, eventReceived):
count = 0
imageWithFaces = 0
for message in eventReceived['Records']:
# Print out the body and tweet id
body = message['body']
print 'message body {}'.format(body)
step_0 = body.split(' ')
tweet_id = step_0[0]
mediaURL = step_0[1]
print "url: " + mediaURL
step_1 = tweet_id.split('@')
t_id = step_1[1]
step_2 = t_id.split(':')
t_id = step_2[0]
print "tweetID: " + t_id
# Check if tweet has been already processed
t_list = (ssm.get_parameter(Name='day-tweet-processed'))['Parameter']['Value']
print "Liste: " + t_list
check = idinlist(t_list, t_id)
print "Check value: " + str(check)
if(check != True):
print "Go to tweet if faces present"
# Gather the image and check if faces are present
count = count + 1
logger.info("Count: %i" % count)
respImage = requests.get(mediaURL+":large")
faceDetails = get_faces(respImage.content)
logger.info(faceDetails)
img = Image.open(BytesIO(respImage.content))
addidtolist(t_list, t_id)
if len(faceDetails) == 0:
print "No faces in the image"
else:
imageWithFaces += 1
processed = updateImage(faceDetails, img)
tweetImage(auth, processed)
return imageWithFaces