automated terminal push
This commit is contained in:
84
consumer (copy 1) (copy 1).py
Normal file
84
consumer (copy 1) (copy 1).py
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
import stomp
|
||||||
|
import time
|
||||||
|
import SullyGnomeRobot
|
||||||
|
import RestAPIClient
|
||||||
|
|
||||||
|
print("## ")
|
||||||
|
print("## starting > JMS consumer (yankee-sully-channels-monthly)")
|
||||||
|
print("## ")
|
||||||
|
|
||||||
|
class MyListener(stomp.ConnectionListener):
|
||||||
|
|
||||||
|
def on_message(headers, message):
|
||||||
|
|
||||||
|
print("** new message! **")
|
||||||
|
|
||||||
|
print("message / ", message)
|
||||||
|
|
||||||
|
print("messagebody / ", message.body)
|
||||||
|
|
||||||
|
print("checking the value does or doesnt exist in db")
|
||||||
|
|
||||||
|
alreadyExistsSuccess = RestAPIClient.searchURLSuccesses(message.body)
|
||||||
|
|
||||||
|
print("alreadyExistsSuccess / ", alreadyExistsSuccess)
|
||||||
|
|
||||||
|
if alreadyExistsSuccess.lower().strip() == "true":
|
||||||
|
|
||||||
|
print("this record exists (successes). returning. doing nothing")
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
print("didn't exist in success. check in errors now.")
|
||||||
|
|
||||||
|
alreadyExistsFailure = RestAPIClient.searchURLFailures(message.body)
|
||||||
|
|
||||||
|
print("alreadyExistsFailure / ", alreadyExistsFailure)
|
||||||
|
|
||||||
|
if alreadyExistsFailure.lower().strip() == "true":
|
||||||
|
|
||||||
|
print("this record exists (failures). returning. doing nothing")
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
print("didn't exist in success or errors. will process now")
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
SullyGnomeRobot.download(message.body)
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
|
||||||
|
print(f"exception / something went wrong when the sully gnome robot was downloading: {e}")
|
||||||
|
|
||||||
|
RestAPIClient.addDownloadFailure(message.body)
|
||||||
|
|
||||||
|
def on_error(headers, message):
|
||||||
|
|
||||||
|
print('received an error "%s"' % message)
|
||||||
|
|
||||||
|
RestAPIClient.addDownloadFailure(message.body)
|
||||||
|
|
||||||
|
print("## ")
|
||||||
|
print("## starting > JMS consumer (yankee-sully-channels-monthly)")
|
||||||
|
print("## ")
|
||||||
|
|
||||||
|
conn = stomp.Connection([('osiris.yankee.embanet.online', 61613)])
|
||||||
|
|
||||||
|
conn.set_listener('', MyListener())
|
||||||
|
|
||||||
|
conn.connect('admin', 'password', wait=True)
|
||||||
|
|
||||||
|
conn.subscribe('/queue/yankee-sully-channels-monthly', id=1, ack='auto', headers={'activemq.prefetchSize': 10})
|
||||||
|
|
||||||
|
print("## ")
|
||||||
|
print("## notification > connected to JMS server (yankee-sully-channels-monthly)")
|
||||||
|
print("## ")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
conn.disconnect()
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
import stomp
|
import stomp
|
||||||
import time
|
|
||||||
import SullyGnomeRobot
|
import SullyGnomeRobot
|
||||||
import RestAPIClient
|
import RestAPIClient
|
||||||
|
|
||||||
print("## ")
|
|
||||||
print("## starting > JMS consumer (yankee-sully-channels-monthly)")
|
|
||||||
print("## ")
|
|
||||||
|
|
||||||
class MyListener(stomp.ConnectionListener):
|
class MyListener(stomp.ConnectionListener):
|
||||||
|
|
||||||
@@ -59,10 +56,6 @@ class MyListener(stomp.ConnectionListener):
|
|||||||
|
|
||||||
RestAPIClient.addDownloadFailure(message.body)
|
RestAPIClient.addDownloadFailure(message.body)
|
||||||
|
|
||||||
print("## ")
|
|
||||||
print("## starting > JMS consumer (yankee-sully-channels-monthly)")
|
|
||||||
print("## ")
|
|
||||||
|
|
||||||
conn = stomp.Connection([('osiris.yankee.embanet.online', 61613)])
|
conn = stomp.Connection([('osiris.yankee.embanet.online', 61613)])
|
||||||
|
|
||||||
conn.set_listener('', MyListener())
|
conn.set_listener('', MyListener())
|
||||||
@@ -71,14 +64,7 @@ conn.connect('admin', 'password', wait=True)
|
|||||||
|
|
||||||
conn.subscribe('/queue/yankee-sully-channels-monthly', id=1, ack='auto', headers={'activemq.prefetchSize': 10})
|
conn.subscribe('/queue/yankee-sully-channels-monthly', id=1, ack='auto', headers={'activemq.prefetchSize': 10})
|
||||||
|
|
||||||
print("## ")
|
|
||||||
print("## notification > connected to JMS server (yankee-sully-channels-monthly)")
|
|
||||||
print("## ")
|
|
||||||
|
|
||||||
while True:
|
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
conn.disconnect()
|
conn.disconnect()
|
||||||
|
|||||||
24
consumer.py
24
consumer.py
@@ -1 +1,23 @@
|
|||||||
print("hello")
|
import time
|
||||||
|
|
||||||
|
print("## ")
|
||||||
|
print("## starting > JMS consumer (yankee-sully-channels-monthly)")
|
||||||
|
print("## ")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
print("## ")
|
||||||
|
print("## notification > connected to JMS server (yankee-sully-channels-monthly)")
|
||||||
|
print("## ")
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
time.sleep(1)
|
||||||
Reference in New Issue
Block a user