diff --git a/slack-bot/traffic-scraper/.DS_Store b/slack-bot/traffic-scraper/.DS_Store new file mode 100644 index 0000000..56a3d06 Binary files /dev/null and b/slack-bot/traffic-scraper/.DS_Store differ diff --git a/slack-bot/traffic-scraper/prd/11-10-2019_00:30:27.json b/slack-bot/traffic-scraper/prd/11-10-2019_00:30:27.json deleted file mode 100644 index 7c384a9..0000000 --- a/slack-bot/traffic-scraper/prd/11-10-2019_00:30:27.json +++ /dev/null @@ -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"] \ No newline at end of file diff --git a/slack-bot/traffic-scraper/prd/11-10-2019_01:47:12.json b/slack-bot/traffic-scraper/prd/11-10-2019_01:47:12.json deleted file mode 100644 index e137bdb..0000000 --- a/slack-bot/traffic-scraper/prd/11-10-2019_01:47:12.json +++ /dev/null @@ -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"] \ No newline at end of file diff --git a/slack-bot/traffic-scraper/prd/11-10-2019_01:47:23.json b/slack-bot/traffic-scraper/prd/11-10-2019_01:47:23.json deleted file mode 100644 index 5c9f81f..0000000 --- a/slack-bot/traffic-scraper/prd/11-10-2019_01:47:23.json +++ /dev/null @@ -1 +0,0 @@ -["START"] \ No newline at end of file diff --git a/slack-bot/traffic-scraper/prd/11-10-2019_01:47:27.json b/slack-bot/traffic-scraper/prd/11-10-2019_01:47:27.json deleted file mode 100644 index a3f8861..0000000 --- a/slack-bot/traffic-scraper/prd/11-10-2019_01:47:27.json +++ /dev/null @@ -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"] \ No newline at end of file diff --git a/slack-bot/traffic-scraper/prd/11-10-2019_01:47:35.json b/slack-bot/traffic-scraper/prd/11-10-2019_01:47:35.json deleted file mode 100644 index 55ced93..0000000 --- a/slack-bot/traffic-scraper/prd/11-10-2019_01:47:35.json +++ /dev/null @@ -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"] \ No newline at end of file diff --git a/slack-bot/traffic-scraper/prd/__pycache__/pullTrafficInfo.cpython-37.pyc b/slack-bot/traffic-scraper/prd/__pycache__/pullTrafficInfo.cpython-37.pyc index 0678d9c..826c4f4 100644 Binary files a/slack-bot/traffic-scraper/prd/__pycache__/pullTrafficInfo.cpython-37.pyc and b/slack-bot/traffic-scraper/prd/__pycache__/pullTrafficInfo.cpython-37.pyc differ diff --git a/slack-bot/traffic-scraper/prd/__pycache__/receiveFromSQS.cpython-37.pyc b/slack-bot/traffic-scraper/prd/__pycache__/receiveFromSQS.cpython-37.pyc new file mode 100644 index 0000000..caae40c Binary files /dev/null and b/slack-bot/traffic-scraper/prd/__pycache__/receiveFromSQS.cpython-37.pyc differ diff --git a/slack-bot/traffic-scraper/prd/__pycache__/sendToSQS.cpython-37.pyc b/slack-bot/traffic-scraper/prd/__pycache__/sendToSQS.cpython-37.pyc new file mode 100644 index 0000000..9f81004 Binary files /dev/null and b/slack-bot/traffic-scraper/prd/__pycache__/sendToSQS.cpython-37.pyc differ diff --git a/slack-bot/traffic-scraper/prd/loadResults.py b/slack-bot/traffic-scraper/prd/loadResults.py new file mode 100644 index 0000000..5798372 --- /dev/null +++ b/slack-bot/traffic-scraper/prd/loadResults.py @@ -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) diff --git a/slack-bot/traffic-scraper/prd/pullTrafficInfo.py b/slack-bot/traffic-scraper/prd/pullTrafficInfo.py index f44ec19..21351c1 100644 --- a/slack-bot/traffic-scraper/prd/pullTrafficInfo.py +++ b/slack-bot/traffic-scraper/prd/pullTrafficInfo.py @@ -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) diff --git a/slack-bot/traffic-scraper/prd/receiveFromSQS.py b/slack-bot/traffic-scraper/prd/receiveFromSQS.py index 387856c..aa48794 100644 --- a/slack-bot/traffic-scraper/prd/receiveFromSQS.py +++ b/slack-bot/traffic-scraper/prd/receiveFromSQS.py @@ -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) diff --git a/slack-bot/traffic-scraper/prd/sendToSQS.py b/slack-bot/traffic-scraper/prd/sendToSQS.py index 0a8eb8f..2d3ebee 100644 --- a/slack-bot/traffic-scraper/prd/sendToSQS.py +++ b/slack-bot/traffic-scraper/prd/sendToSQS.py @@ -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') diff --git a/slack-bot/traffic-scraper/prd/test-run.py b/slack-bot/traffic-scraper/prd/test-run.py index b38a7d3..ba681e5 100644 --- a/slack-bot/traffic-scraper/prd/test-run.py +++ b/slack-bot/traffic-scraper/prd/test-run.py @@ -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()}')