import os
import sys

sys.path.append(os.getcwd())
import pullTrafficInfo
from sendToSQS import sendToSQS
from receiveFromSQS import receiveFromSQS

inst = (
    pullTrafficInfo.getTrafficInfo.getTrafficURL('M62')
    .findIncidents()
    .getIncidentInformation()
    .generateOutput()
)

inst.browser.quit()

instSend = sendToSQS.createSession(
    profileName='plex-aws',
    queueURL='https://sqs.eu-west-1.amazonaws.com'
    '/745437999005/slack-bot.fifo',
)

for item in inst.output:
    instSend.sendMessage(message=item, messageGroupId='slack-bot-M62')

instReceive = receiveFromSQS(
    instSend.session,
    queueURL='https://sqs.eu-west-1.amazonaws.com/745437999005'
    '/slack-bot.fifo',
)

instReceive.receiveAllMessages()

instReceive.savetoDisk(f'{os.getcwd()}')
