completed full run script

This commit is contained in:
2019-10-12 03:05:38 +01:00
parent ac366716ee
commit ca19ff0c9a
14 changed files with 38 additions and 57 deletions

BIN
slack-bot/traffic-scraper/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -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"]

View File

@@ -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"]

View File

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

View File

@@ -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"]

View File

@@ -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"]

View 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)

View File

@@ -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)

View File

@@ -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)

View File

@@ -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')

View File

@@ -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()}')