From ca19ff0c9a96c27d49b6d5431501ae733f8a308f Mon Sep 17 00:00:00 2001 From: Daniel Tomlinson Date: Sat, 12 Oct 2019 03:05:38 +0100 Subject: [PATCH] completed full run script --- slack-bot/traffic-scraper/.DS_Store | Bin 0 -> 6148 bytes .../prd/11-10-2019_00:30:27.json | 1 - .../prd/11-10-2019_01:47:12.json | 1 - .../prd/11-10-2019_01:47:23.json | 1 - .../prd/11-10-2019_01:47:27.json | 1 - .../prd/11-10-2019_01:47:35.json | 1 - .../pullTrafficInfo.cpython-37.pyc | Bin 5192 -> 5090 bytes .../__pycache__/receiveFromSQS.cpython-37.pyc | Bin 0 -> 4282 bytes .../prd/__pycache__/sendToSQS.cpython-37.pyc | Bin 0 -> 1648 bytes slack-bot/traffic-scraper/prd/loadResults.py | 8 +++++ .../traffic-scraper/prd/pullTrafficInfo.py | 8 ++--- .../traffic-scraper/prd/receiveFromSQS.py | 29 +++--------------- slack-bot/traffic-scraper/prd/sendToSQS.py | 28 ++++++++--------- slack-bot/traffic-scraper/prd/test-run.py | 17 +++++----- 14 files changed, 38 insertions(+), 57 deletions(-) create mode 100644 slack-bot/traffic-scraper/.DS_Store delete mode 100644 slack-bot/traffic-scraper/prd/11-10-2019_00:30:27.json delete mode 100644 slack-bot/traffic-scraper/prd/11-10-2019_01:47:12.json delete mode 100644 slack-bot/traffic-scraper/prd/11-10-2019_01:47:23.json delete mode 100644 slack-bot/traffic-scraper/prd/11-10-2019_01:47:27.json delete mode 100644 slack-bot/traffic-scraper/prd/11-10-2019_01:47:35.json create mode 100644 slack-bot/traffic-scraper/prd/__pycache__/receiveFromSQS.cpython-37.pyc create mode 100644 slack-bot/traffic-scraper/prd/__pycache__/sendToSQS.cpython-37.pyc create mode 100644 slack-bot/traffic-scraper/prd/loadResults.py diff --git a/slack-bot/traffic-scraper/.DS_Store b/slack-bot/traffic-scraper/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..56a3d0619346b45d3b975de38839c52deb1b7602 GIT binary patch literal 6148 zcmeH~J!%6%427R!7lt%jrkutH@C^oIpTHMLVMr5fV@T>bdY*ooY+RcqJc0B^niaeI z6+0^cw*NZsfC<2c?uxC4nHlpHZn)$8eY#&hua^&2yb8QT%#4)@v;EqZh=2%)fCz|y z2rP&|p5oZNF6f!`C?X&N%OK$2hemhpr6V;y9Sku7P}eMnaUHV+wRwTsOGhdzG^^>s zs?}l)@p`mVTV2;nM{2giYWT3av-uQ5vuuYoCN%3I3L+o^GXks3CqMs>^hfjmtVO8^ zh`>K1VC%!_u;)wF+4|@8y#8KQUk^GpE@$}l6Trle;x~F2_nR-My>z6qLeq~xU{DZ& HrxN%97hw^P literal 0 HcmV?d00001 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 0678d9c380cece1a110a93f226090175e1baf202..826c4f4340bd6938f071e911daaa46f10ad0f5fe 100644 GIT binary patch delta 929 zcmZXSPfyf97{=*#+b+9X78b<_Q4sl8HAqC`g?JE&k|3DKX%gL(c3_9Joz2^+q6hs7 z;>3$FCftk%joE_-V@y2x6&yWz;GieJf%A4zP}}6!&O6UMede8hn)){BUUuDbm%esq zc5ZEL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WM1=r^X41Nr~} 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 0000000000000000000000000000000000000000..caae40c1821e67ad692d2fd9f177b5660298f198 GIT binary patch literal 4282 zcmai1&vVfVsy03 z@caIg(P~-bfT00izi(I`^y>Y?DhNtz*~2c+!@I zV|K(bsw0cX%qz+nS(4>r?zwVAR`8}IM`acFvK*7+xR1zLc~MS6qav@!OL7XWQF&QT z<6HFwvza%B_08$33YtOdS#V3m?X?GM-8mUIlT@{$t=eX+YG=PT`|G89|4Kf_L&{R# zV@KjdoHEXOX!}-=pV*S0QoGO-kj@r^EJ}u%#j3WF-K6g7LbBHhl%nCZ>-(*!mHNIe zCP9+4;z&EquoXn9BFAWVcQ4orzIu39yKQ`LYz0Z((smMro2m!}Rf2%EOTOO>8%g5( z|75TKy!2HPsANf|aXV~9NgOTRkAfA2UDp#Z^F+hl@V36^k`EBz-``l zg65~iFj3*%xuIpBQEhTk!%yI%E@tgl(U5$L9|9BGv2I9y}*? z$H2&&+zL|PK*?|Pl@ntHZ_K=Y(?wgYDD_6n+q*%ul|HQtMPBr(gRW+t%xZ5;SH&D= zOc`ttYOqQ*NvV z)&Uo=>kd~R_4uKPW+g1VZTG|^xH-+H*`b{ldiD_qSMgr*9ibklj?5(lo*W+*fH2asry2B)&B!+H_92bRPF%>+b{TS{CuHHJIK{XJi&?B9ja~shb!XTL zyn5*L*h!`5kWLQ~^Ox+sxRdBY2XQ^sm4|x~Wuh;Yij^*?Mzj@Zr_t#Ik<9opme1_x<~7vN6TS?> z0MTHuogzLdskBOErkcd>om3towq^++L#ded+DeybHVLd{#cNb$cF zBtv$@g3ej!U9u;I8D=@0C}wk)J0RP*aCsT+2|mSbLqVIDEg>9xLX;7QtN7A=_y2mJ zNxq^Vp~l5!*!Vpf85@n{2ha99De^e5Zy65#=}?&HhCE1kqUd&L?cX*!na1*=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!mjP7b3W&9etH>DZAqR@ga^yQTpXa&ilQWo zrHrD#(0_jn-bgOwfT?1ZrMWEf!K<7<73r_Mzt{gc&9XF}^bS`F-X0EQ7ANoa#)TTF^+oK-M8t4{K`Gea8l;EinE)1{ zJJ6*`65$?pu#eBTZhSVUy++i4U=aNgy4(h#&R%{}U92mUxAhK)@Bguq!GaD7v(O47MqNrL#g8xU%G1`ydQ;ExZMN8z^jH0$-c1HII1s{QeC= zZv7vS(X*gsYT6JKYPuaovx3cmv61$p=yV=ujm3>3cx5`MAiG=Byy{qyzka0{T_q6ybHp^=JSmt Icd<|Z2gEF_b^rhX literal 0 HcmV?d00001 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()}')