create test-run script
This commit is contained in:
1
slack-bot/traffic-scraper/prd/11-10-2019_01:47:12.json
Normal file
1
slack-bot/traffic-scraper/prd/11-10-2019_01:47:12.json
Normal 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"]
|
||||
1
slack-bot/traffic-scraper/prd/11-10-2019_01:47:23.json
Normal file
1
slack-bot/traffic-scraper/prd/11-10-2019_01:47:23.json
Normal file
@@ -0,0 +1 @@
|
||||
["START"]
|
||||
1
slack-bot/traffic-scraper/prd/11-10-2019_01:47:27.json
Normal file
1
slack-bot/traffic-scraper/prd/11-10-2019_01:47:27.json
Normal 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"]
|
||||
1
slack-bot/traffic-scraper/prd/11-10-2019_01:47:35.json
Normal file
1
slack-bot/traffic-scraper/prd/11-10-2019_01:47:35.json
Normal 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"]
|
||||
@@ -149,7 +149,7 @@ inst = receiveFromSQS.createSession(
|
||||
'.com/745437999005/slack-bot.fifo',
|
||||
)
|
||||
|
||||
output = inst.receiveNMessages(numberOfMessages=6).generateOutput(type='json')
|
||||
output = inst.receiveNMessages(numberOfMessages=4).generateOutput(type='json')
|
||||
inst.savetoDisk(
|
||||
'/Users/dtomlinson/OneDrive - William Hill'
|
||||
' Organisation Limited/Mac/git_repos/python-VM/slack-bot/traffic-scraper'
|
||||
|
||||
@@ -15,7 +15,7 @@ class sendToSQS(object):
|
||||
def __init__(self, session, queueURL):
|
||||
super(sendToSQS, self).__init__()
|
||||
self.session = session
|
||||
self.sqs = session.client("sqs")
|
||||
self.sqs = session.client('sqs')
|
||||
self.queueURL = queueURL
|
||||
|
||||
@classmethod
|
||||
@@ -24,7 +24,7 @@ class sendToSQS(object):
|
||||
return cls(session, queueURL)
|
||||
|
||||
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:
|
||||
message = (base64.b64encode(message.encode())).decode()
|
||||
if not dedup:
|
||||
@@ -42,17 +42,17 @@ class sendToSQS(object):
|
||||
MessageGroupId=messageGroupId,
|
||||
)
|
||||
if msg is not None:
|
||||
print(msg["MessageId"])
|
||||
print(msg['MessageId'])
|
||||
|
||||
|
||||
inst = sendToSQS.createSession(
|
||||
profileName="plex-aws",
|
||||
queueURL="https://sqs.eu-west-1.amazonaws.com"
|
||||
"/745437999005/slack-bot.fifo",
|
||||
profileName='plex-aws',
|
||||
queueURL='https://sqs.eu-west-1.amazonaws.com'
|
||||
'/745437999005/slack-bot.fifo',
|
||||
)
|
||||
|
||||
instM = (
|
||||
getTrafficInfo.getTrafficURL("M62")
|
||||
getTrafficInfo.getTrafficURL('M62')
|
||||
.findIncidents()
|
||||
.getIncidentInformation()
|
||||
.generateOutput()
|
||||
@@ -60,4 +60,4 @@ instM = (
|
||||
|
||||
for _ in range(0, 5):
|
||||
for item in instM.output:
|
||||
inst.sendMessage(message=item, messageGroupId="slack-bot-M62")
|
||||
inst.sendMessage(message=item, messageGroupId='slack-bot-M62')
|
||||
|
||||
36
slack-bot/traffic-scraper/prd/test-run.py
Normal file
36
slack-bot/traffic-scraper/prd/test-run.py
Normal 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()}'
|
||||
)
|
||||
Reference in New Issue
Block a user