From 0d6d2ff76e85ef1cdf2b6cb87725796b70c86fbf Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 6 Feb 2025 23:51:17 -0500 Subject: [PATCH] automated terminal push --- consumer.py | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++- hello.py | 1 + test.py | 84 ---------------------------------------------------- 3 files changed, 85 insertions(+), 85 deletions(-) create mode 100644 hello.py delete mode 100644 test.py diff --git a/consumer.py b/consumer.py index ce47b77..a775274 100644 --- a/consumer.py +++ b/consumer.py @@ -1 +1,84 @@ -print("hello") \ No newline at end of file +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() diff --git a/hello.py b/hello.py new file mode 100644 index 0000000..ce47b77 --- /dev/null +++ b/hello.py @@ -0,0 +1 @@ +print("hello") \ No newline at end of file diff --git a/test.py b/test.py deleted file mode 100644 index a775274..0000000 --- a/test.py +++ /dev/null @@ -1,84 +0,0 @@ -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()