updating receiveFromSQS.py

This commit is contained in:
2019-10-08 02:42:29 +01:00
parent 713084c336
commit 13b9a6d039
5 changed files with 190 additions and 114 deletions

View File

@@ -1,12 +1,14 @@
import boto3
import os
import sys
sys.path.append(os.getcwd())
sys.path.append('/home/dtomlinson/projects/slack-bot/traffic-scraper/prd')
from pullTrafficInfo import getTrafficInfo
import base64
# import emoji
import hashlib
# import hashlib
from datetime import datetime
motorway = 'A3'
@@ -17,8 +19,12 @@ sqs = session.client('sqs')
# queue = sqs.create_queue(QueueName='test', Attributes={'DelaySeconds': '5'})
inst = getTrafficInfo.getTrafficURL(motorway).findIncidents() \
.getIncidentInformation().generateOutput()
inst = (
getTrafficInfo.getTrafficURL(motorway)
.findIncidents()
.getIncidentInformation()
.generateOutput()
)
# encoded = base64.b64encode(inst.output[0].encode())
# decoded = base64.b64decode(encoded).decode()
@@ -51,13 +57,12 @@ queueURL = 'https://sqs.eu-west-1.amazonaws.com/745437999005/slack-bot.fifo'
# # print(encoded.encode())
# # print(base64.b64decode(encoded.encode()).decode())
queueAttributes = sqs\
.get_queue_attributes(QueueUrl=queueURL,
AttributeNames=['ApproximateNumberOfMessages'])
queueAttributes = sqs.get_queue_attributes(
QueueUrl=queueURL, AttributeNames=['ApproximateNumberOfMessages']
)
response = sqs.receive_message(QueueUrl=queueURL,
MaxNumberOfMessages=10)
response = sqs.receive_message(QueueUrl=queueURL, MaxNumberOfMessages=10)
if 'Messages' in response:
for message in response['Messages']:
# print(message['Body'])