completed full run script
This commit is contained in:
@@ -1 +0,0 @@
|
||||
["START", "Did someone say M62!? \ud83d\ude27 Let's check the latest updates from Highways England as of 00:30:21! \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", "Hey Andy, have you thought about getting the train? \ud83d\ude85", "END"]
|
||||
@@ -1 +0,0 @@
|
||||
["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 +0,0 @@
|
||||
["START"]
|
||||
@@ -1 +0,0 @@
|
||||
["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 +0,0 @@
|
||||
["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"]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
8
slack-bot/traffic-scraper/prd/loadResults.py
Normal file
8
slack-bot/traffic-scraper/prd/loadResults.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import json
|
||||
|
||||
with open('/Users/dtomlinson/OneDrive - William Hill Organisation Limited'
|
||||
'/Mac/git_repos/python-VM/slack-bot/traffic-scraper/'
|
||||
'prd/12-10-2019_02:53:32.json', 'r') as jsonFile:
|
||||
data = json.load(jsonFile)
|
||||
for item in data:
|
||||
print(item)
|
||||
@@ -186,7 +186,7 @@ class getTrafficInfo(object):
|
||||
return self
|
||||
|
||||
|
||||
inst = getTrafficInfo.getTrafficURL('M62').findIncidents() \
|
||||
.getIncidentInformation().generateOutput()
|
||||
for i in inst.output:
|
||||
print(i)
|
||||
# inst = getTrafficInfo.getTrafficURL('M62').findIncidents() \
|
||||
# .getIncidentInformation().generateOutput()
|
||||
# for i in inst.output:
|
||||
# print(i)
|
||||
|
||||
@@ -127,34 +127,15 @@ class receiveFromSQS(object):
|
||||
)
|
||||
return self
|
||||
|
||||
def generateOutput(self, type='json'):
|
||||
if type == 'json':
|
||||
self.output = json.dumps(self.messages)
|
||||
return self.output
|
||||
# def generateOutput(self, outputType='json'):
|
||||
# if outputType == 'json':
|
||||
# self.output = json.dumps(self.messages)
|
||||
# return self.output
|
||||
|
||||
def savetoDisk(self, path):
|
||||
self.timeNow = datetime.now().strftime('%d-%m-%Y_%H:%M:%S')
|
||||
if self.output is None:
|
||||
self.generateOutput()
|
||||
if len(self.messages) > 0:
|
||||
with open(f'{path}/{self.timeNow}.json', 'w+') as outputFile:
|
||||
outputFile.write(self.output)
|
||||
json.dump(self.messages, outputFile)
|
||||
else:
|
||||
print('No messages to save')
|
||||
|
||||
|
||||
inst = receiveFromSQS.createSession(
|
||||
profileName='plex-aws',
|
||||
queueURL='https://sqs.eu-west-1.amazonaws'
|
||||
'.com/745437999005/slack-bot.fifo',
|
||||
)
|
||||
|
||||
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'
|
||||
'/prd'
|
||||
)
|
||||
# inst.receiveAllMessages()
|
||||
for item in inst.messages:
|
||||
print(item)
|
||||
|
||||
@@ -45,19 +45,19 @@ class sendToSQS(object):
|
||||
print(msg['MessageId'])
|
||||
|
||||
|
||||
inst = sendToSQS.createSession(
|
||||
profileName='plex-aws',
|
||||
queueURL='https://sqs.eu-west-1.amazonaws.com'
|
||||
'/745437999005/slack-bot.fifo',
|
||||
)
|
||||
# inst = sendToSQS.createSession(
|
||||
# profileName='plex-aws',
|
||||
# queueURL='https://sqs.eu-west-1.amazonaws.com'
|
||||
# '/745437999005/slack-bot.fifo',
|
||||
# )
|
||||
|
||||
instM = (
|
||||
getTrafficInfo.getTrafficURL('M62')
|
||||
.findIncidents()
|
||||
.getIncidentInformation()
|
||||
.generateOutput()
|
||||
)
|
||||
# instM = (
|
||||
# getTrafficInfo.getTrafficURL('M62')
|
||||
# .findIncidents()
|
||||
# .getIncidentInformation()
|
||||
# .generateOutput()
|
||||
# )
|
||||
|
||||
for _ in range(0, 5):
|
||||
for item in instM.output:
|
||||
inst.sendMessage(message=item, messageGroupId='slack-bot-M62')
|
||||
# for _ in range(0, 5):
|
||||
# for item in instM.output:
|
||||
# inst.sendMessage(message=item, messageGroupId='slack-bot-M62')
|
||||
|
||||
@@ -2,12 +2,12 @@ import os
|
||||
import sys
|
||||
|
||||
sys.path.append(os.getcwd())
|
||||
from getTrafficInfo import getTrafficInfo
|
||||
import pullTrafficInfo
|
||||
from sendToSQS import sendToSQS
|
||||
from receiveFromSQS import receiveFromSQS
|
||||
|
||||
inst = (
|
||||
getTrafficInfo.getTrafficURL('M62')
|
||||
pullTrafficInfo.getTrafficInfo.getTrafficURL('M62')
|
||||
.findIncidents()
|
||||
.getIncidentInformation()
|
||||
.generateOutput()
|
||||
@@ -19,8 +19,8 @@ instSend = sendToSQS.createSession(
|
||||
'/745437999005/slack-bot.fifo',
|
||||
)
|
||||
|
||||
for item in instSend.output:
|
||||
inst.sendMessage(message=item, messageGroupId='slack-bot-M62')
|
||||
for item in inst.output:
|
||||
instSend.sendMessage(message=item, messageGroupId='slack-bot-M62')
|
||||
|
||||
instReceive = receiveFromSQS(
|
||||
instSend.session,
|
||||
@@ -28,9 +28,6 @@ instReceive = receiveFromSQS(
|
||||
'/slack-bot.fifo',
|
||||
)
|
||||
|
||||
output = instReceive.receiveNMessages(numberOfMessages=4).generateOutput(
|
||||
type='json'
|
||||
)
|
||||
instReceive.savetoDisk(
|
||||
f'{os.getcwd()}'
|
||||
)
|
||||
instReceive.receiveAllMessages()
|
||||
|
||||
instReceive.savetoDisk(f'{os.getcwd()}')
|
||||
|
||||
Reference in New Issue
Block a user