create test-run script

This commit is contained in:
2019-10-11 02:30:09 +01:00
parent 36bf49f0ca
commit ac366716ee
7 changed files with 49 additions and 9 deletions

View File

@@ -0,0 +1 @@
["START", "Did someone say M62!? \ud83d\ude27 Let's check the latest updates from Highways England as of 01:47:03! \ud83d\ude93\ud83d\udea8", "There are currently no reported congestion incidents on the M62 \ud83e\udd14", "There are currently no reported accident incidents on the M62 \ud83e\udd14", "Don't fret, Andy can always work from home! \ud83c\udfe1", "END", "START", "Did someone say M62!? \ud83d\ude27 Let's check the latest updates from Highways England as of 01:47:03! \ud83d\ude93\ud83d\udea8", "There are currently no reported congestion incidents on the M62 \ud83e\udd14", "There are currently no reported accident incidents on the M62 \ud83e\udd14", "Don't fret, Andy can always work from home! \ud83c\udfe1", "END"]

View File

@@ -0,0 +1 @@
["START"]

View File

@@ -0,0 +1 @@
["Did someone say M62!? \ud83d\ude27 Let's check the latest updates from Highways England as of 01:47:03! \ud83d\ude93\ud83d\udea8"]

View File

@@ -0,0 +1 @@
["There are currently no reported congestion incidents on the M62 \ud83e\udd14", "There are currently no reported accident incidents on the M62 \ud83e\udd14", "Don't fret, Andy can always work from home! \ud83c\udfe1", "END"]

View File

@@ -149,7 +149,7 @@ inst = receiveFromSQS.createSession(
'.com/745437999005/slack-bot.fifo', '.com/745437999005/slack-bot.fifo',
) )
output = inst.receiveNMessages(numberOfMessages=6).generateOutput(type='json') output = inst.receiveNMessages(numberOfMessages=4).generateOutput(type='json')
inst.savetoDisk( inst.savetoDisk(
'/Users/dtomlinson/OneDrive - William Hill' '/Users/dtomlinson/OneDrive - William Hill'
' Organisation Limited/Mac/git_repos/python-VM/slack-bot/traffic-scraper' ' Organisation Limited/Mac/git_repos/python-VM/slack-bot/traffic-scraper'

View File

@@ -15,7 +15,7 @@ class sendToSQS(object):
def __init__(self, session, queueURL): def __init__(self, session, queueURL):
super(sendToSQS, self).__init__() super(sendToSQS, self).__init__()
self.session = session self.session = session
self.sqs = session.client("sqs") self.sqs = session.client('sqs')
self.queueURL = queueURL self.queueURL = queueURL
@classmethod @classmethod
@@ -24,7 +24,7 @@ class sendToSQS(object):
return cls(session, queueURL) return cls(session, queueURL)
def sendMessage(self, message, messageGroupId, b64=True, dedup=False): def sendMessage(self, message, messageGroupId, b64=True, dedup=False):
currentTime = datetime.now().strftime("%H:%M:%S.%f") currentTime = datetime.now().strftime('%H:%M:%S.%f')
if b64: if b64:
message = (base64.b64encode(message.encode())).decode() message = (base64.b64encode(message.encode())).decode()
if not dedup: if not dedup:
@@ -42,17 +42,17 @@ class sendToSQS(object):
MessageGroupId=messageGroupId, MessageGroupId=messageGroupId,
) )
if msg is not None: if msg is not None:
print(msg["MessageId"]) print(msg['MessageId'])
inst = sendToSQS.createSession( inst = sendToSQS.createSession(
profileName="plex-aws", profileName='plex-aws',
queueURL="https://sqs.eu-west-1.amazonaws.com" queueURL='https://sqs.eu-west-1.amazonaws.com'
"/745437999005/slack-bot.fifo", '/745437999005/slack-bot.fifo',
) )
instM = ( instM = (
getTrafficInfo.getTrafficURL("M62") getTrafficInfo.getTrafficURL('M62')
.findIncidents() .findIncidents()
.getIncidentInformation() .getIncidentInformation()
.generateOutput() .generateOutput()
@@ -60,4 +60,4 @@ instM = (
for _ in range(0, 5): for _ in range(0, 5):
for item in instM.output: for item in instM.output:
inst.sendMessage(message=item, messageGroupId="slack-bot-M62") inst.sendMessage(message=item, messageGroupId='slack-bot-M62')

View File

@@ -0,0 +1,36 @@
import os
import sys
sys.path.append(os.getcwd())
from getTrafficInfo import getTrafficInfo
from sendToSQS import sendToSQS
from receiveFromSQS import receiveFromSQS
inst = (
getTrafficInfo.getTrafficURL('M62')
.findIncidents()
.getIncidentInformation()
.generateOutput()
)
instSend = sendToSQS.createSession(
profileName='plex-aws',
queueURL='https://sqs.eu-west-1.amazonaws.com'
'/745437999005/slack-bot.fifo',
)
for item in instSend.output:
inst.sendMessage(message=item, messageGroupId='slack-bot-M62')
instReceive = receiveFromSQS(
instSend.session,
queueURL='https://sqs.eu-west-1.amazonaws.com/745437999005'
'/slack-bot.fifo',
)
output = instReceive.receiveNMessages(numberOfMessages=4).generateOutput(
type='json'
)
instReceive.savetoDisk(
f'{os.getcwd()}'
)