mirror of
https://github.com/Unidata/python-awips.git
synced 2025-02-24 06:57:56 -05:00
- brought over all the pythonPackages from the following repos/packages: - awips2/pythonPackages - awips2/edexOsgi/com.raytheon.uf.common.alertviz/pythonPackages - awips2/edexOsgi/com.raytheon.uf.common.mpe/pythonPackages - awips2/edexOsgi/com.raytheon.uf.common.dataplugin.text/pythonPackages - awips2/edexOsgi/com.raytheon.uf.common.dataplugin.grid/pythonPackages - awips2/edexOsgi/com.raytheon.uf.common.activetable/pythonPackages - awips2/edexOsgi/com.raytheon.uf.common.management/pythonPackages - awips2/edexOsgi/com.raytheon.uf.common.dataplugin.gfe/pythonPackages - awips2/edexOsgi/com.raytheon.uf.common.dataplugin.radar/pythonPackages - awips2/edexOsgi/com.raytheon.uf.common.site/pythonPackages - awips2-core/common/com.raytheon.uf.common.auth/pythonPackages - awips2-core/common/com.raytheon.uf.common.message/pythonPackages - awips2-core/common/com.raytheon.uf.common.localization/pythonPackages - awips2-core/common/com.raytheon.uf.common.datastorage/pythonPackages - awips2-core/common/com.raytheon.uf.common.pointdata/pythonPackages - awips2-core/common/com.raythoen.uf.common.pypies/pythonPackages - awips2-core/common/com.raytheon.uf.common.dataaccess/pythonPackages - awips2-core/common/com.raytheon.uf.common.dataplugin.level/pythonPackages - awips2-core/common/com.raytheon.uf.common.serialization/pythonPackages - awips2-core/common/com.raytheon.uf.common.time/pythonPackages - awips2-core/common/com.raytheon.uf.common.dataplugin/pythonPackages - awips2-core/common/com.raytheon.uf.common.dataquery/pythonPackages - updated the _init_.py file in dynamicserialize/dstypes/com/raytheon/uf/common to have all the proper elements listed - started to replace "ufpy" instances with "awips" - awips/test/testQpidTimeToLive.py - awips/test/dafTests/testWarning.py - awips/test/dafTests/testCombinedTimeQuery.py - will continue the "ufpy" replacement in a separate commit for easier clarity
98 lines
2.9 KiB
Python
98 lines
2.9 KiB
Python
##
|
|
# This software was developed and / or modified by Raytheon Company,
|
|
# pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
|
#
|
|
# U.S. EXPORT CONTROLLED TECHNICAL DATA
|
|
# This software product contains export-restricted data whose
|
|
# export/transfer/disclosure is restricted by U.S. law. Dissemination
|
|
# to non-U.S. persons whether in the United States or abroad requires
|
|
# an export license or other authorization.
|
|
#
|
|
# Contractor Name: Raytheon Company
|
|
# Contractor Address: 6825 Pine Street, Suite 340
|
|
# Mail Stop B8
|
|
# Omaha, NE 68106
|
|
# 402.291.0100
|
|
#
|
|
# See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
|
# further licensing information.
|
|
##
|
|
#
|
|
# SOFTWARE HISTORY
|
|
#
|
|
# Date Ticket# Engineer Description
|
|
# ------------- -------- ------------ --------------------------------------------
|
|
# Mar 09, 2011 njensen Initial Creation.
|
|
# Aug 15, 2013 2169 bkowal Decompress data read from the queue
|
|
# Jun 24, 2020 8187 randerso Added program for qpid connection_id
|
|
#
|
|
#
|
|
|
|
import time
|
|
import threading
|
|
|
|
|
|
TIME_TO_SLEEP = 300
|
|
|
|
class ListenThread(threading.Thread):
|
|
|
|
def __init__(self, hostname, portNumber, topicName):
|
|
self.hostname = hostname
|
|
self.portNumber = portNumber
|
|
self.topicName = topicName
|
|
self.nMessagesReceived = 0
|
|
self.waitSecond = 0
|
|
self.stopped = False
|
|
threading.Thread.__init__(self)
|
|
|
|
def run(self):
|
|
from awips import QpidSubscriber
|
|
self.qs = QpidSubscriber.QpidSubscriber(host=self.hostname, port=self.portNumber, decompress=True, program="testQpidTimeToLive")
|
|
self.qs.topicSubscribe(self.topicName, self.receivedMessage)
|
|
|
|
def receivedMessage(self, msg):
|
|
print("Received message")
|
|
self.nMessagesReceived += 1
|
|
if self.waitSecond == 0:
|
|
fmsg = open('/tmp/rawMessage', 'w')
|
|
fmsg.write(msg)
|
|
fmsg.close()
|
|
|
|
while self.waitSecond < TIME_TO_SLEEP and not self.stopped:
|
|
if self.waitSecond % 60 == 0:
|
|
print(time.strftime('%H:%M:%S'), "Sleeping and stuck in not so infinite while loop")
|
|
self.waitSecond += 1
|
|
time.sleep(1)
|
|
|
|
print(time.strftime('%H:%M:%S'), "Received", self.nMessagesReceived, "messages")
|
|
|
|
def stop(self):
|
|
print("Stopping")
|
|
self.stopped = True
|
|
self.qs.close()
|
|
|
|
|
|
|
|
def main():
|
|
print("Starting up at", time.strftime('%H:%M:%S'))
|
|
|
|
topic = 'edex.alerts'
|
|
host = 'localhost'
|
|
port = 5672
|
|
|
|
thread = ListenThread(host, port, topic)
|
|
try:
|
|
thread.start()
|
|
while True:
|
|
time.sleep(3)
|
|
except KeyboardInterrupt:
|
|
pass
|
|
finally:
|
|
thread.stop()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|
|
|
|
|