mirror of
https://github.com/Unidata/python-awips.git
synced 2025-02-23 14:57:56 -05:00
after running 2to3
This commit is contained in:
parent
25aeba5224
commit
6a2db72ffd
248 changed files with 11891 additions and 454 deletions
|
@ -35,7 +35,7 @@
|
|||
#
|
||||
|
||||
import logging
|
||||
import NotificationMessage
|
||||
from . import NotificationMessage
|
||||
|
||||
class AlertVizHandler(logging.Handler):
|
||||
|
||||
|
|
69
awips/AlertVizHandler.py.bak
Normal file
69
awips/AlertVizHandler.py.bak
Normal file
|
@ -0,0 +1,69 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
|
||||
#
|
||||
# Pure python logging mechanism for logging to AlertViz from
|
||||
# pure python (ie not JEP). DO NOT USE IN PYTHON CALLED
|
||||
# FROM JAVA.
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 08/18/10 njensen Initial Creation.
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
import logging
|
||||
import NotificationMessage
|
||||
|
||||
class AlertVizHandler(logging.Handler):
|
||||
|
||||
def __init__(self, host='localhost', port=61999, category='LOCAL', source='ANNOUNCER', level=logging.NOTSET):
|
||||
logging.Handler.__init__(self, level)
|
||||
self._category = category
|
||||
self._host = host
|
||||
self._port = port
|
||||
self._source = source
|
||||
|
||||
def emit(self, record):
|
||||
"Implements logging.Handler's interface. Record argument is a logging.LogRecord."
|
||||
priority = None
|
||||
if record.levelno >= 50:
|
||||
priority = 'CRITICAL'
|
||||
elif record.levelno >= 40:
|
||||
priority = 'SIGNIFICANT'
|
||||
elif record.levelno >= 30:
|
||||
priority = 'PROBLEM'
|
||||
elif record.levelno >= 20:
|
||||
priority = 'EVENTA'
|
||||
elif record.levelno >= 10:
|
||||
priority = 'EVENTB'
|
||||
else:
|
||||
priority = 'VERBOSE'
|
||||
|
||||
msg = self.format(record)
|
||||
|
||||
notify = NotificationMessage.NotificationMessage(self._host, self._port, msg, priority, self._category, self._source)
|
||||
notify.send()
|
||||
|
|
@ -63,10 +63,10 @@ def convertToDateTime(timeArg):
|
|||
return datetime.datetime(*timeArg[:6])
|
||||
elif isinstance(timeArg, float):
|
||||
# seconds as float, should be avoided due to floating point errors
|
||||
totalSecs = long(timeArg)
|
||||
totalSecs = int(timeArg)
|
||||
micros = int((timeArg - totalSecs) * MICROS_IN_SECOND)
|
||||
return _convertSecsAndMicros(totalSecs, micros)
|
||||
elif isinstance(timeArg, (int, long)):
|
||||
elif isinstance(timeArg, int):
|
||||
# seconds as integer
|
||||
totalSecs = timeArg
|
||||
return _convertSecsAndMicros(totalSecs, 0)
|
||||
|
|
107
awips/DateTimeConverter.py.bak
Normal file
107
awips/DateTimeConverter.py.bak
Normal file
|
@ -0,0 +1,107 @@
|
|||
# #
|
||||
# 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.
|
||||
# #
|
||||
|
||||
#
|
||||
# Functions for converting between the various "Java" dynamic serialize types
|
||||
# used by EDEX to the native python time datetime.
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 06/24/15 #4480 dgilling Initial Creation.
|
||||
#
|
||||
|
||||
import datetime
|
||||
import time
|
||||
|
||||
from dynamicserialize.dstypes.java.util import Date
|
||||
from dynamicserialize.dstypes.java.sql import Timestamp
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.time import TimeRange
|
||||
|
||||
|
||||
MAX_TIME = pow(2, 31) - 1
|
||||
MICROS_IN_SECOND = 1000000
|
||||
|
||||
|
||||
def convertToDateTime(timeArg):
|
||||
"""
|
||||
Converts the given object to a python datetime object. Supports native
|
||||
python representations like datetime and struct_time, but also
|
||||
the dynamicserialize types like Date and Timestamp. Raises TypeError
|
||||
if no conversion can be performed.
|
||||
|
||||
Args:
|
||||
timeArg: a python object representing a date and time. Supported
|
||||
types include datetime, struct_time, float, int, long and the
|
||||
dynamicserialize types Date and Timestamp.
|
||||
|
||||
Returns:
|
||||
A datetime that represents the same date/time as the passed in object.
|
||||
"""
|
||||
if isinstance(timeArg, datetime.datetime):
|
||||
return timeArg
|
||||
elif isinstance(timeArg, time.struct_time):
|
||||
return datetime.datetime(*timeArg[:6])
|
||||
elif isinstance(timeArg, float):
|
||||
# seconds as float, should be avoided due to floating point errors
|
||||
totalSecs = long(timeArg)
|
||||
micros = int((timeArg - totalSecs) * MICROS_IN_SECOND)
|
||||
return _convertSecsAndMicros(totalSecs, micros)
|
||||
elif isinstance(timeArg, (int, long)):
|
||||
# seconds as integer
|
||||
totalSecs = timeArg
|
||||
return _convertSecsAndMicros(totalSecs, 0)
|
||||
elif isinstance(timeArg, (Date, Timestamp)):
|
||||
totalSecs = timeArg.getTime()
|
||||
return _convertSecsAndMicros(totalSecs, 0)
|
||||
else:
|
||||
objType = str(type(timeArg))
|
||||
raise TypeError("Cannot convert object of type " + objType + " to datetime.")
|
||||
|
||||
def _convertSecsAndMicros(seconds, micros):
|
||||
if seconds < MAX_TIME:
|
||||
rval = datetime.datetime.utcfromtimestamp(seconds)
|
||||
else:
|
||||
extraTime = datetime.timedelta(seconds=(seconds - MAX_TIME))
|
||||
rval = datetime.datetime.utcfromtimestamp(MAX_TIME) + extraTime
|
||||
return rval.replace(microsecond=micros)
|
||||
|
||||
def constructTimeRange(*args):
|
||||
"""
|
||||
Builds a python dynamicserialize TimeRange object from the given
|
||||
arguments.
|
||||
|
||||
Args:
|
||||
args*: must be a TimeRange or a pair of objects that can be
|
||||
converted to a datetime via convertToDateTime().
|
||||
|
||||
Returns:
|
||||
A TimeRange.
|
||||
"""
|
||||
|
||||
if len(args) == 1 and isinstance(args[0], TimeRange):
|
||||
return args[0]
|
||||
if len(args) != 2:
|
||||
raise TypeError("constructTimeRange takes exactly 2 arguments, " + str(len(args)) + " provided.")
|
||||
startTime = convertToDateTime(args[0])
|
||||
endTime = convertToDateTime(args[1])
|
||||
return TimeRange(startTime, endTime)
|
|
@ -1,19 +1,19 @@
|
|||
##
|
||||
# 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
|
||||
# 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
|
||||
#
|
||||
# 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.
|
||||
##
|
||||
|
@ -21,14 +21,14 @@
|
|||
from string import Template
|
||||
|
||||
import ctypes
|
||||
import stomp
|
||||
from . import stomp
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
import threading
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
import ThriftClient
|
||||
from . import ThriftClient
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.alertviz import AlertVizRequest
|
||||
from dynamicserialize import DynamicSerializationManager
|
||||
|
||||
|
@ -89,8 +89,8 @@ class NotificationMessage:
|
|||
priorityInt = int(5)
|
||||
|
||||
if (priorityInt < 0 or priorityInt > 5):
|
||||
print "Error occurred, supplied an invalid Priority value: " + str(priorityInt)
|
||||
print "Priority values are 0, 1, 2, 3, 4 and 5."
|
||||
print("Error occurred, supplied an invalid Priority value: " + str(priorityInt))
|
||||
print("Priority values are 0, 1, 2, 3, 4 and 5.")
|
||||
sys.exit(1)
|
||||
|
||||
if priorityInt is not None:
|
||||
|
@ -100,8 +100,8 @@ class NotificationMessage:
|
|||
|
||||
def connection_timeout(self, connection):
|
||||
if (connection is not None and not connection.is_connected()):
|
||||
print "Connection Retry Timeout"
|
||||
for tid, tobj in threading._active.items():
|
||||
print("Connection Retry Timeout")
|
||||
for tid, tobj in list(threading._active.items()):
|
||||
if tobj.name is "MainThread":
|
||||
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(SystemExit))
|
||||
if res != 0 and res != 1:
|
||||
|
@ -150,14 +150,14 @@ class NotificationMessage:
|
|||
serverResponse = None
|
||||
try:
|
||||
serverResponse = thriftClient.sendRequest(alertVizRequest)
|
||||
except Exception, ex:
|
||||
print "Caught exception submitting AlertVizRequest: ", str(ex)
|
||||
except Exception as ex:
|
||||
print("Caught exception submitting AlertVizRequest: ", str(ex))
|
||||
|
||||
if (serverResponse != "None"):
|
||||
print "Error occurred submitting Notification Message to AlertViz receiver: ", serverResponse
|
||||
print("Error occurred submitting Notification Message to AlertViz receiver: ", serverResponse)
|
||||
sys.exit(1)
|
||||
else:
|
||||
print "Response: " + str(serverResponse)
|
||||
print("Response: " + str(serverResponse))
|
||||
|
||||
def createRequest(message, priority, source, category, audioFile):
|
||||
obj = AlertVizRequest()
|
||||
|
|
178
awips/NotificationMessage.py.bak
Normal file
178
awips/NotificationMessage.py.bak
Normal file
|
@ -0,0 +1,178 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
from string import Template
|
||||
|
||||
import ctypes
|
||||
import stomp
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
import threading
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
import ThriftClient
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.alertviz import AlertVizRequest
|
||||
from dynamicserialize import DynamicSerializationManager
|
||||
|
||||
#
|
||||
# Provides a capability of constructing notification messages and sending
|
||||
# them to a STOMP data source.
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 09/30/08 chammack Initial Creation.
|
||||
# 11/03/10 5849 cjeanbap Moved to awips package from
|
||||
# com.raytheon.uf.tools.cli
|
||||
# 01/07/11 5645 cjeanbap Added audio file to Status Message.
|
||||
# 05/27/11 3050 cjeanbap Added if-statement to check Priority
|
||||
# value
|
||||
#
|
||||
class NotificationMessage:
|
||||
|
||||
priorityMap = {
|
||||
0: 'CRITICAL',
|
||||
1: 'SIGNIFICANT',
|
||||
2: 'PROBLEM',
|
||||
3: 'EVENTA',
|
||||
4: 'EVENTB',
|
||||
5: 'VERBOSE'}
|
||||
|
||||
def __init__(self, host='localhost', port=61999, message='', priority='PROBLEM', category="LOCAL", source="ANNOUNCER", audioFile="NONE"):
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.message = message
|
||||
self.audioFile = audioFile
|
||||
self.source = source
|
||||
self.category = category
|
||||
|
||||
priorityInt = None
|
||||
|
||||
try:
|
||||
priorityInt = int(priority)
|
||||
except:
|
||||
pass
|
||||
|
||||
if priorityInt is None:
|
||||
#UFStatus.java contains mapping of Priority to Logging level mapping
|
||||
if priority == 'CRITICAL' or priority == 'FATAL':
|
||||
priorityInt = int(0)
|
||||
elif priority == 'SIGNIFICANT' or priority == 'ERROR':
|
||||
priorityInt = int(1)
|
||||
elif priority == 'PROBLEM' or priority == 'WARN':
|
||||
priorityInt = int(2)
|
||||
elif priority == 'EVENTA' or priority == 'INFO':
|
||||
priorityInt = int(3)
|
||||
elif priority == 'EVENTB':
|
||||
priorityInt = int(4)
|
||||
elif priority == 'VERBOSE' or priority == 'DEBUG':
|
||||
priorityInt = int(5)
|
||||
|
||||
if (priorityInt < 0 or priorityInt > 5):
|
||||
print "Error occurred, supplied an invalid Priority value: " + str(priorityInt)
|
||||
print "Priority values are 0, 1, 2, 3, 4 and 5."
|
||||
sys.exit(1)
|
||||
|
||||
if priorityInt is not None:
|
||||
self.priority = self.priorityMap[priorityInt]
|
||||
else:
|
||||
self.priority = priority
|
||||
|
||||
def connection_timeout(self, connection):
|
||||
if (connection is not None and not connection.is_connected()):
|
||||
print "Connection Retry Timeout"
|
||||
for tid, tobj in threading._active.items():
|
||||
if tobj.name is "MainThread":
|
||||
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(SystemExit))
|
||||
if res != 0 and res != 1:
|
||||
# problem, reset state
|
||||
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, 0)
|
||||
|
||||
def send(self):
|
||||
# depending on the value of the port number indicates the distribution
|
||||
# of the message to AlertViz
|
||||
# 9581 is global distribution thru ThriftClient to Edex
|
||||
# 61999 is local distribution
|
||||
if (self.port == 61999):
|
||||
# use stomp.py
|
||||
conn = stomp.Connection(host_and_ports=[(self.host, self.port)])
|
||||
timeout = threading.Timer(5.0, self.connection_timeout, [conn])
|
||||
|
||||
try:
|
||||
timeout.start();
|
||||
conn.start()
|
||||
finally:
|
||||
timeout.cancel()
|
||||
|
||||
conn.connect()
|
||||
|
||||
sm = ET.Element("statusMessage")
|
||||
sm.set("machine", socket.gethostname())
|
||||
sm.set("priority", self.priority)
|
||||
sm.set("category", self.category)
|
||||
sm.set("sourceKey", self.source)
|
||||
sm.set("audioFile", self.audioFile)
|
||||
msg = ET.SubElement(sm, "message")
|
||||
msg.text = self.message
|
||||
details = ET.SubElement(sm, "details")
|
||||
msg = ET.tostring(sm, "UTF-8")
|
||||
|
||||
try :
|
||||
conn.send(msg, destination='/queue/messages')
|
||||
time.sleep(2)
|
||||
finally:
|
||||
conn.stop()
|
||||
else:
|
||||
# use ThriftClient
|
||||
alertVizRequest = createRequest(self.message, self.priority, self.source, self.category, self.audioFile)
|
||||
thriftClient = ThriftClient.ThriftClient(self.host, self.port, "/services")
|
||||
|
||||
serverResponse = None
|
||||
try:
|
||||
serverResponse = thriftClient.sendRequest(alertVizRequest)
|
||||
except Exception, ex:
|
||||
print "Caught exception submitting AlertVizRequest: ", str(ex)
|
||||
|
||||
if (serverResponse != "None"):
|
||||
print "Error occurred submitting Notification Message to AlertViz receiver: ", serverResponse
|
||||
sys.exit(1)
|
||||
else:
|
||||
print "Response: " + str(serverResponse)
|
||||
|
||||
def createRequest(message, priority, source, category, audioFile):
|
||||
obj = AlertVizRequest()
|
||||
|
||||
obj.setMachine(socket.gethostname())
|
||||
obj.setPriority(priority)
|
||||
obj.setCategory(category)
|
||||
obj.setSourceKey(source)
|
||||
obj.setMessage(message)
|
||||
if (audioFile is not None):
|
||||
obj.setAudioFile(audioFile)
|
||||
else:
|
||||
obj.setAudioFile('\0')
|
||||
|
||||
return obj
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -35,7 +35,7 @@
|
|||
import qpid
|
||||
import zlib
|
||||
|
||||
from Queue import Empty
|
||||
from queue import Empty
|
||||
from qpid.exceptions import Closed
|
||||
|
||||
class QpidSubscriber:
|
||||
|
@ -56,7 +56,7 @@ class QpidSubscriber:
|
|||
if (topicName == 'edex.alerts'):
|
||||
self.decompress = True
|
||||
|
||||
print "Establishing connection to broker on", self.host
|
||||
print("Establishing connection to broker on", self.host)
|
||||
queueName = topicName + self.__session.name
|
||||
self.__session.queue_declare(queue=queueName, exclusive=True, auto_delete=True, arguments={'qpid.max_count':100, 'qpid.policy_type':'ring'})
|
||||
self.__session.exchange_bind(exchange='amq.topic', queue=queueName, binding_key=topicName)
|
||||
|
@ -67,7 +67,7 @@ class QpidSubscriber:
|
|||
queue = self.__session.incoming(local_queue_name)
|
||||
self.__session.message_subscribe(serverQueueName, destination=local_queue_name)
|
||||
queue.start()
|
||||
print "Connection complete to broker on", self.host
|
||||
print("Connection complete to broker on", self.host)
|
||||
|
||||
while self.subscribed:
|
||||
try:
|
||||
|
@ -75,7 +75,7 @@ class QpidSubscriber:
|
|||
content = message.body
|
||||
self.__session.message_accept(qpid.datatypes.RangedSet(message.id))
|
||||
if (self.decompress):
|
||||
print "Decompressing received content"
|
||||
print("Decompressing received content")
|
||||
try:
|
||||
# http://stackoverflow.com/questions/2423866/python-decompressing-gzip-chunk-by-chunk
|
||||
d = zlib.decompressobj(16+zlib.MAX_WBITS)
|
||||
|
|
97
awips/QpidSubscriber.py.bak
Normal file
97
awips/QpidSubscriber.py.bak
Normal file
|
@ -0,0 +1,97 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
#
|
||||
# Provides a Python-based interface for subscribing to qpid queues and topics.
|
||||
#
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 11/17/10 njensen Initial Creation.
|
||||
# 08/15/13 2169 bkowal Optionally gzip decompress any data that is read.
|
||||
#
|
||||
#
|
||||
|
||||
import qpid
|
||||
import zlib
|
||||
|
||||
from Queue import Empty
|
||||
from qpid.exceptions import Closed
|
||||
|
||||
class QpidSubscriber:
|
||||
|
||||
def __init__(self, host='127.0.0.1', port=5672, decompress=False):
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.decompress = decompress;
|
||||
socket = qpid.util.connect(host, port)
|
||||
self.__connection = qpid.connection.Connection(sock=socket, username='guest', password='guest')
|
||||
self.__connection.start()
|
||||
self.__session = self.__connection.session(str(qpid.datatypes.uuid4()))
|
||||
self.subscribed = True
|
||||
|
||||
def topicSubscribe(self, topicName, callback):
|
||||
# if the queue is edex.alerts, set decompress to true always for now to
|
||||
# maintain compatibility with existing python scripts.
|
||||
if (topicName == 'edex.alerts'):
|
||||
self.decompress = True
|
||||
|
||||
print "Establishing connection to broker on", self.host
|
||||
queueName = topicName + self.__session.name
|
||||
self.__session.queue_declare(queue=queueName, exclusive=True, auto_delete=True, arguments={'qpid.max_count':100, 'qpid.policy_type':'ring'})
|
||||
self.__session.exchange_bind(exchange='amq.topic', queue=queueName, binding_key=topicName)
|
||||
self.__innerSubscribe(queueName, callback)
|
||||
|
||||
def __innerSubscribe(self, serverQueueName, callback):
|
||||
local_queue_name = 'local_queue_' + serverQueueName
|
||||
queue = self.__session.incoming(local_queue_name)
|
||||
self.__session.message_subscribe(serverQueueName, destination=local_queue_name)
|
||||
queue.start()
|
||||
print "Connection complete to broker on", self.host
|
||||
|
||||
while self.subscribed:
|
||||
try:
|
||||
message = queue.get(timeout=10)
|
||||
content = message.body
|
||||
self.__session.message_accept(qpid.datatypes.RangedSet(message.id))
|
||||
if (self.decompress):
|
||||
print "Decompressing received content"
|
||||
try:
|
||||
# http://stackoverflow.com/questions/2423866/python-decompressing-gzip-chunk-by-chunk
|
||||
d = zlib.decompressobj(16+zlib.MAX_WBITS)
|
||||
content = d.decompress(content)
|
||||
except:
|
||||
# decompression failed, return the original content
|
||||
pass
|
||||
callback(content)
|
||||
except Empty:
|
||||
pass
|
||||
except Closed:
|
||||
self.close()
|
||||
|
||||
def close(self):
|
||||
self.subscribed = False
|
||||
try:
|
||||
self.__session.close(timeout=10)
|
||||
except:
|
||||
pass
|
|
@ -18,7 +18,7 @@
|
|||
# further licensing information.
|
||||
##
|
||||
|
||||
import httplib
|
||||
import http.client
|
||||
from dynamicserialize import DynamicSerializationManager
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.serialization.comm.response import ServerErrorResponse
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.serialization import SerializableExceptionWrapper
|
||||
|
@ -54,12 +54,12 @@ class ThriftClient:
|
|||
if (len(hostParts) > 1):
|
||||
hostString = hostParts[0]
|
||||
self.__uri = "/" + hostParts[1]
|
||||
self.__httpConn = httplib.HTTPConnection(hostString)
|
||||
self.__httpConn = http.client.HTTPConnection(hostString)
|
||||
else:
|
||||
if (port is None):
|
||||
self.__httpConn = httplib.HTTPConnection(host)
|
||||
self.__httpConn = http.client.HTTPConnection(host)
|
||||
else:
|
||||
self.__httpConn = httplib.HTTPConnection(host, port)
|
||||
self.__httpConn = http.client.HTTPConnection(host, port)
|
||||
|
||||
self.__uri = uri
|
||||
|
||||
|
|
101
awips/ThriftClient.py.bak
Normal file
101
awips/ThriftClient.py.bak
Normal file
|
@ -0,0 +1,101 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
import httplib
|
||||
from dynamicserialize import DynamicSerializationManager
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.serialization.comm.response import ServerErrorResponse
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.serialization import SerializableExceptionWrapper
|
||||
|
||||
#
|
||||
# Provides a Python-based interface for executing Thrift requests.
|
||||
#
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 09/20/10 dgilling Initial Creation.
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
class ThriftClient:
|
||||
|
||||
# How to call this constructor:
|
||||
# 1. Pass in all arguments separately (e.g.,
|
||||
# ThriftClient.ThriftClient("localhost", 9581, "/services"))
|
||||
# will return a Thrift client pointed at http://localhost:9581/services.
|
||||
# 2. Pass in all arguments through the host string (e.g.,
|
||||
# ThriftClient.ThriftClient("localhost:9581/services"))
|
||||
# will return a Thrift client pointed at http://localhost:9581/services.
|
||||
# 3. Pass in host/port arguments through the host string (e.g.,
|
||||
# ThriftClient.ThriftClient("localhost:9581", "/services"))
|
||||
# will return a Thrift client pointed at http://localhost:9581/services.
|
||||
def __init__(self, host, port=9581, uri="/services"):
|
||||
hostParts = host.split("/", 1)
|
||||
if (len(hostParts) > 1):
|
||||
hostString = hostParts[0]
|
||||
self.__uri = "/" + hostParts[1]
|
||||
self.__httpConn = httplib.HTTPConnection(hostString)
|
||||
else:
|
||||
if (port is None):
|
||||
self.__httpConn = httplib.HTTPConnection(host)
|
||||
else:
|
||||
self.__httpConn = httplib.HTTPConnection(host, port)
|
||||
|
||||
self.__uri = uri
|
||||
|
||||
self.__dsm = DynamicSerializationManager.DynamicSerializationManager()
|
||||
|
||||
def sendRequest(self, request, uri="/thrift"):
|
||||
message = self.__dsm.serializeObject(request)
|
||||
|
||||
self.__httpConn.connect()
|
||||
self.__httpConn.request("POST", self.__uri + uri, message)
|
||||
|
||||
response = self.__httpConn.getresponse()
|
||||
if (response.status != 200):
|
||||
raise ThriftRequestException("Unable to post request to server")
|
||||
|
||||
rval = self.__dsm.deserializeBytes(response.read())
|
||||
self.__httpConn.close()
|
||||
|
||||
# let's verify we have an instance of ServerErrorResponse
|
||||
# IF we do, through an exception up to the caller along
|
||||
# with the original Java stack trace
|
||||
# ELSE: we have a valid response and pass it back
|
||||
try:
|
||||
forceError = rval.getException()
|
||||
raise ThriftRequestException(forceError)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
return rval
|
||||
|
||||
|
||||
class ThriftRequestException(Exception):
|
||||
def __init__(self, value):
|
||||
self.parameter = value
|
||||
|
||||
def __str__(self):
|
||||
return repr(self.parameter)
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ def determineDrtOffset(timeStr):
|
|||
#print "gmtime", gm
|
||||
if synch:
|
||||
cur_t = time.mktime((gm[0], gm[1], gm[2], gm[3], 0, 0, 0, 0, 0))
|
||||
curStr = '%4s%2s%2s_%2s00\n' % (`gm[0]`,`gm[1]`,`gm[2]`,`gm[3]`)
|
||||
curStr = '%4s%2s%2s_%2s00\n' % (repr(gm[0]),repr(gm[1]),repr(gm[2]),repr(gm[3]))
|
||||
curStr = curStr.replace(' ','0')
|
||||
launchStr = timeStr + "," + curStr
|
||||
|
||||
|
|
108
awips/TimeUtil.py.bak
Normal file
108
awips/TimeUtil.py.bak
Normal file
|
@ -0,0 +1,108 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
# ----------------------------------------------------------------------------
|
||||
# This software is in the public domain, furnished "as is", without technical
|
||||
# support, and with no warranty, express or implied, as to its usefulness for
|
||||
# any purpose.
|
||||
#
|
||||
# offsetTime.py
|
||||
# Handles Displaced Real Time for various applications
|
||||
#
|
||||
# Author: hansen/romberg
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
import string
|
||||
import time
|
||||
|
||||
# Given the timeStr, return the offset (in seconds)
|
||||
# from the current time.
|
||||
# Also return the launchStr i.e. Programs launched from this
|
||||
# offset application will use the launchStr as the -z argument.
|
||||
# The offset will be positive for time in the future,
|
||||
# negative for time in the past.
|
||||
#
|
||||
# May still want it to be normalized to the most recent midnight.
|
||||
#
|
||||
# NOTES about synchronizing:
|
||||
# --With synchronizing on, the "current time" for all processes started
|
||||
# within a given hour will be the same.
|
||||
# This guarantees that GFE's have the same current time and ISC grid
|
||||
# time stamps are syncrhonized and can be exchanged.
|
||||
# Formatters launched from the GFE in this mode will be synchronized as
|
||||
# well by setting the launchStr to use the time difference format
|
||||
# (YYYYMMDD_HHMM,YYYYMMDD_HHMM).
|
||||
# --This does not solve the problem in the general case.
|
||||
# For example, if someone starts the GFE at 12:59 and someone
|
||||
# else starts it at 1:01, they will have different offsets and
|
||||
# current times.
|
||||
# --With synchronizing off, when the process starts, the current time
|
||||
# matches the drtTime in the command line. However, with synchronizing
|
||||
# on, the current time will be offset by the fraction of the hour at
|
||||
# which the process was started. Examples:
|
||||
# Actual Starting time: 20040617_1230
|
||||
# drtTime 20040616_0000
|
||||
# Synchronizing off:
|
||||
# GFE Spatial Editor at StartUp: 20040616_0000
|
||||
# Synchronizing on:
|
||||
# GFE Spatial Editor at StartUp: 20040616_0030
|
||||
#
|
||||
def determineDrtOffset(timeStr):
|
||||
launchStr = timeStr
|
||||
# Check for time difference
|
||||
if timeStr.find(",") >=0:
|
||||
times = timeStr.split(",")
|
||||
t1 = makeTime(times[0])
|
||||
t2 = makeTime(times[1])
|
||||
#print "time offset", t1-t2, (t1-t2)/3600
|
||||
return t1-t2, launchStr
|
||||
# Check for synchronized mode
|
||||
synch = 0
|
||||
if timeStr[0] == "S":
|
||||
timeStr = timeStr[1:]
|
||||
synch = 1
|
||||
drt_t = makeTime(timeStr)
|
||||
#print "input", year, month, day, hour, minute
|
||||
gm = time.gmtime()
|
||||
cur_t = time.mktime(gm)
|
||||
|
||||
# Synchronize to most recent hour
|
||||
# i.e. "truncate" cur_t to most recent hour.
|
||||
#print "gmtime", gm
|
||||
if synch:
|
||||
cur_t = time.mktime((gm[0], gm[1], gm[2], gm[3], 0, 0, 0, 0, 0))
|
||||
curStr = '%4s%2s%2s_%2s00\n' % (`gm[0]`,`gm[1]`,`gm[2]`,`gm[3]`)
|
||||
curStr = curStr.replace(' ','0')
|
||||
launchStr = timeStr + "," + curStr
|
||||
|
||||
#print "drt, cur", drt_t, cur_t
|
||||
offset = drt_t - cur_t
|
||||
#print "offset", offset, offset/3600, launchStr
|
||||
return int(offset), launchStr
|
||||
|
||||
def makeTime(timeStr):
|
||||
year = string.atoi(timeStr[0:4])
|
||||
month = string.atoi(timeStr[4:6])
|
||||
day = string.atoi(timeStr[6:8])
|
||||
hour = string.atoi(timeStr[9:11])
|
||||
minute = string.atoi(timeStr[11:13])
|
||||
# Do not use daylight savings because gmtime is not in daylight
|
||||
# savings time.
|
||||
return time.mktime((year, month, day, hour, minute, 0, 0, 0, 0))
|
||||
|
|
@ -47,7 +47,7 @@ import subprocess
|
|||
THRIFT_HOST = "edex"
|
||||
USING_NATIVE_THRIFT = False
|
||||
|
||||
if sys.modules.has_key('jep'):
|
||||
if 'jep' in sys.modules:
|
||||
# intentionally do not catch if this fails to import, we want it to
|
||||
# be obvious that something is configured wrong when running from within
|
||||
# Java instead of allowing false confidence and fallback behavior
|
||||
|
|
215
awips/dataaccess/DataAccessLayer.py.bak
Normal file
215
awips/dataaccess/DataAccessLayer.py.bak
Normal file
|
@ -0,0 +1,215 @@
|
|||
# #
|
||||
# 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.
|
||||
# #
|
||||
|
||||
|
||||
#
|
||||
# Published interface for awips.dataaccess package
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 12/10/12 njensen Initial Creation.
|
||||
# Feb 14, 2013 1614 bsteffen refactor data access framework
|
||||
# to use single request.
|
||||
# 04/10/13 1871 mnash move getLatLonCoords to JGridData and add default args
|
||||
# 05/29/13 2023 dgilling Hook up ThriftClientRouter.
|
||||
# 03/03/14 2673 bsteffen Add ability to query only ref times.
|
||||
# 07/22/14 3185 njensen Added optional/default args to newDataRequest
|
||||
# 07/30/14 3185 njensen Renamed valid identifiers to optional
|
||||
# Apr 26, 2015 4259 njensen Updated for new JEP API
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
THRIFT_HOST = "edex"
|
||||
USING_NATIVE_THRIFT = False
|
||||
|
||||
if sys.modules.has_key('jep'):
|
||||
# intentionally do not catch if this fails to import, we want it to
|
||||
# be obvious that something is configured wrong when running from within
|
||||
# Java instead of allowing false confidence and fallback behavior
|
||||
import JepRouter
|
||||
router = JepRouter
|
||||
else:
|
||||
from awips.dataaccess import ThriftClientRouter
|
||||
router = ThriftClientRouter.ThriftClientRouter(THRIFT_HOST)
|
||||
USING_NATIVE_THRIFT = True
|
||||
|
||||
|
||||
def getAvailableTimes(request, refTimeOnly=False):
|
||||
"""
|
||||
Get the times of available data to the request.
|
||||
|
||||
Args:
|
||||
request: the IDataRequest to get data for
|
||||
refTimeOnly: optional, use True if only unique refTimes should be
|
||||
returned (without a forecastHr)
|
||||
|
||||
Returns:
|
||||
a list of DataTimes
|
||||
"""
|
||||
return router.getAvailableTimes(request, refTimeOnly)
|
||||
|
||||
def getGridData(request, times=[]):
|
||||
"""
|
||||
Gets the grid data that matches the request at the specified times. Each
|
||||
combination of parameter, level, and dataTime will be returned as a
|
||||
separate IGridData.
|
||||
|
||||
Args:
|
||||
request: the IDataRequest to get data for
|
||||
times: a list of DataTimes, a TimeRange, or None if the data is time
|
||||
agnostic
|
||||
|
||||
Returns:
|
||||
a list of IGridData
|
||||
"""
|
||||
return router.getGridData(request, times)
|
||||
|
||||
def getGeometryData(request, times=[]):
|
||||
"""
|
||||
Gets the geometry data that matches the request at the specified times.
|
||||
Each combination of geometry, level, and dataTime will be returned as a
|
||||
separate IGeometryData.
|
||||
|
||||
Args:
|
||||
request: the IDataRequest to get data for
|
||||
times: a list of DataTimes, a TimeRange, or None if the data is time
|
||||
agnostic
|
||||
|
||||
Returns:
|
||||
a list of IGeometryData
|
||||
"""
|
||||
return router.getGeometryData(request, times)
|
||||
|
||||
def getAvailableLocationNames(request):
|
||||
"""
|
||||
Gets the available location names that match the request without actually
|
||||
requesting the data.
|
||||
|
||||
Args:
|
||||
request: the request to find matching location names for
|
||||
|
||||
Returns:
|
||||
a list of strings of available location names.
|
||||
"""
|
||||
return router.getAvailableLocationNames(request)
|
||||
|
||||
def getAvailableParameters(request):
|
||||
"""
|
||||
Gets the available parameters names that match the request without actually
|
||||
requesting the data.
|
||||
|
||||
Args:
|
||||
request: the request to find matching parameter names for
|
||||
|
||||
Returns:
|
||||
a list of strings of available parameter names.
|
||||
"""
|
||||
return router.getAvailableParameters(request)
|
||||
|
||||
def getAvailableLevels(request):
|
||||
"""
|
||||
Gets the available levels that match the request without actually
|
||||
requesting the data.
|
||||
|
||||
Args:
|
||||
request: the request to find matching levels for
|
||||
|
||||
Returns:
|
||||
a list of strings of available levels.
|
||||
"""
|
||||
return router.getAvailableLevels(request)
|
||||
|
||||
def getRequiredIdentifiers(datatype):
|
||||
"""
|
||||
Gets the required identifiers for this datatype. These identifiers
|
||||
must be set on a request for the request of this datatype to succeed.
|
||||
|
||||
Args:
|
||||
datatype: the datatype to find required identifiers for
|
||||
|
||||
Returns:
|
||||
a list of strings of required identifiers
|
||||
"""
|
||||
return router.getRequiredIdentifiers(datatype)
|
||||
|
||||
def getOptionalIdentifiers(datatype):
|
||||
"""
|
||||
Gets the optional identifiers for this datatype.
|
||||
|
||||
Args:
|
||||
datatype: the datatype to find optional identifiers for
|
||||
|
||||
Returns:
|
||||
a list of strings of optional identifiers
|
||||
"""
|
||||
return router.getOptionalIdentifiers(datatype)
|
||||
|
||||
def newDataRequest(datatype=None, **kwargs):
|
||||
""""
|
||||
Creates a new instance of IDataRequest suitable for the runtime environment.
|
||||
All args are optional and exist solely for convenience.
|
||||
|
||||
Args:
|
||||
datatype: the datatype to create a request for
|
||||
parameters: a list of parameters to set on the request
|
||||
levels: a list of levels to set on the request
|
||||
locationNames: a list of locationNames to set on the request
|
||||
envelope: an envelope to limit the request
|
||||
**kwargs: any leftover kwargs will be set as identifiers
|
||||
|
||||
Returns:
|
||||
a new IDataRequest
|
||||
"""
|
||||
return router.newDataRequest(datatype, **kwargs)
|
||||
|
||||
def getSupportedDatatypes():
|
||||
"""
|
||||
Gets the datatypes that are supported by the framework
|
||||
|
||||
Returns:
|
||||
a list of strings of supported datatypes
|
||||
"""
|
||||
return router.getSupportedDatatypes()
|
||||
|
||||
|
||||
def changeEDEXHost(newHostName):
|
||||
"""
|
||||
Changes the EDEX host the Data Access Framework is communicating with. Only
|
||||
works if using the native Python client implementation, otherwise, this
|
||||
method will throw a TypeError.
|
||||
|
||||
Args:
|
||||
newHostHame: the EDEX host to connect to
|
||||
"""
|
||||
if USING_NATIVE_THRIFT:
|
||||
global THRIFT_HOST
|
||||
THRIFT_HOST = newHostName
|
||||
global router
|
||||
router = ThriftClientRouter.ThriftClientRouter(THRIFT_HOST)
|
||||
else:
|
||||
raise TypeError("Cannot call changeEDEXHost when using JepRouter.")
|
|
@ -45,7 +45,7 @@ class PyData(IData):
|
|||
return self.__attributes[key]
|
||||
|
||||
def getAttributes(self):
|
||||
return self.__attributes.keys()
|
||||
return list(self.__attributes.keys())
|
||||
|
||||
def getDataTime(self):
|
||||
return self.__time
|
||||
|
|
57
awips/dataaccess/PyData.py.bak
Normal file
57
awips/dataaccess/PyData.py.bak
Normal file
|
@ -0,0 +1,57 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
#
|
||||
# Implements IData for use by native Python clients to the Data Access
|
||||
# Framework.
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 06/03/13 dgilling Initial Creation.
|
||||
#
|
||||
#
|
||||
|
||||
from awips.dataaccess import IData
|
||||
|
||||
class PyData(IData):
|
||||
|
||||
def __init__(self, dataRecord):
|
||||
self.__time = dataRecord.getTime()
|
||||
self.__level = dataRecord.getLevel()
|
||||
self.__locationName = dataRecord.getLocationName()
|
||||
self.__attributes = dataRecord.getAttributes()
|
||||
|
||||
def getAttribute(self, key):
|
||||
return self.__attributes[key]
|
||||
|
||||
def getAttributes(self):
|
||||
return self.__attributes.keys()
|
||||
|
||||
def getDataTime(self):
|
||||
return self.__time
|
||||
|
||||
def getLevel(self):
|
||||
return self.__level
|
||||
|
||||
def getLocationName(self):
|
||||
return self.__locationName
|
|
@ -45,14 +45,14 @@ class PyGeometryData(IGeometryData, PyData.PyData):
|
|||
self.__geometry = geometry
|
||||
self.__dataMap = {}
|
||||
tempDataMap = geoDataRecord.getDataMap()
|
||||
for key, value in tempDataMap.items():
|
||||
for key, value in list(tempDataMap.items()):
|
||||
self.__dataMap[key] = (value[0], value[1], value[2])
|
||||
|
||||
def getGeometry(self):
|
||||
return self.__geometry
|
||||
|
||||
def getParameters(self):
|
||||
return self.__dataMap.keys()
|
||||
return list(self.__dataMap.keys())
|
||||
|
||||
def getString(self, param):
|
||||
value = self.__dataMap[param][0]
|
||||
|
@ -64,7 +64,7 @@ class PyGeometryData(IGeometryData, PyData.PyData):
|
|||
if t == 'INT':
|
||||
return int(value)
|
||||
elif t == 'LONG':
|
||||
return long(value)
|
||||
return int(value)
|
||||
elif t == 'FLOAT':
|
||||
return float(value)
|
||||
elif t == 'DOUBLE':
|
||||
|
|
79
awips/dataaccess/PyGeometryData.py.bak
Normal file
79
awips/dataaccess/PyGeometryData.py.bak
Normal file
|
@ -0,0 +1,79 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
#
|
||||
# Implements IGeometryData for use by native Python clients to the Data Access
|
||||
# Framework.
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 06/03/13 dgilling Initial Creation.
|
||||
# 01/06/14 #2537 bsteffen Share geometry WKT.
|
||||
# 03/19/14 #2882 dgilling Raise an exception when getNumber()
|
||||
# is called for data that is not a
|
||||
# numeric Type.
|
||||
#
|
||||
#
|
||||
|
||||
from awips.dataaccess import IGeometryData
|
||||
from awips.dataaccess import PyData
|
||||
|
||||
class PyGeometryData(IGeometryData, PyData.PyData):
|
||||
|
||||
def __init__(self, geoDataRecord, geometry):
|
||||
PyData.PyData.__init__(self, geoDataRecord)
|
||||
self.__geometry = geometry
|
||||
self.__dataMap = {}
|
||||
tempDataMap = geoDataRecord.getDataMap()
|
||||
for key, value in tempDataMap.items():
|
||||
self.__dataMap[key] = (value[0], value[1], value[2])
|
||||
|
||||
def getGeometry(self):
|
||||
return self.__geometry
|
||||
|
||||
def getParameters(self):
|
||||
return self.__dataMap.keys()
|
||||
|
||||
def getString(self, param):
|
||||
value = self.__dataMap[param][0]
|
||||
return str(value)
|
||||
|
||||
def getNumber(self, param):
|
||||
value = self.__dataMap[param][0]
|
||||
t = self.getType(param)
|
||||
if t == 'INT':
|
||||
return int(value)
|
||||
elif t == 'LONG':
|
||||
return long(value)
|
||||
elif t == 'FLOAT':
|
||||
return float(value)
|
||||
elif t == 'DOUBLE':
|
||||
return float(value)
|
||||
else:
|
||||
raise TypeError("Data for parameter " + param + " is not a numeric type.")
|
||||
|
||||
def getUnit(self, param):
|
||||
return self.__dataMap[param][2]
|
||||
|
||||
def getType(self, param):
|
||||
return self.__dataMap[param][1]
|
|
@ -128,7 +128,7 @@ def __buildStringList(param):
|
|||
return [str(param)]
|
||||
|
||||
def __notStringIter(iterable):
|
||||
if not isinstance(iterable, basestring):
|
||||
if not isinstance(iterable, str):
|
||||
try:
|
||||
iter(iterable)
|
||||
return True
|
||||
|
@ -226,7 +226,7 @@ class _SoundingTimeLayer(object):
|
|||
A list containing the valid levels for this sounding in order of
|
||||
closest to surface to highest from surface.
|
||||
"""
|
||||
sortedLevels = [Level(level) for level in self._dataDict.keys()]
|
||||
sortedLevels = [Level(level) for level in list(self._dataDict.keys())]
|
||||
sortedLevels.sort()
|
||||
return [str(level) for level in sortedLevels]
|
||||
|
||||
|
|
283
awips/dataaccess/SoundingsSupport.py.bak
Normal file
283
awips/dataaccess/SoundingsSupport.py.bak
Normal file
|
@ -0,0 +1,283 @@
|
|||
# #
|
||||
# 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.
|
||||
# #
|
||||
|
||||
#
|
||||
# Classes for retrieving soundings based on gridded data from the Data Access
|
||||
# Framework
|
||||
#
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 06/24/15 #4480 dgilling Initial Creation.
|
||||
#
|
||||
|
||||
from collections import defaultdict
|
||||
from shapely.geometry import Point
|
||||
|
||||
from awips import DateTimeConverter
|
||||
from awips.dataaccess import DataAccessLayer
|
||||
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.time import DataTime
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.level import Level
|
||||
|
||||
|
||||
def getSounding(modelName, weatherElements, levels, samplePoint, refTime=None, timeRange=None):
|
||||
""""
|
||||
Performs a series of Data Access Framework requests to retrieve a sounding object
|
||||
based on the specified request parameters.
|
||||
|
||||
Args:
|
||||
modelName: the grid model datasetid to use as the basis of the sounding.
|
||||
weatherElements: a list of parameters to return in the sounding.
|
||||
levels: a list of levels to sample the given weather elements at
|
||||
samplePoint: a lat/lon pair to perform the sampling of data at.
|
||||
refTime: (optional) the grid model reference time to use for the sounding.
|
||||
If not specified, the latest ref time in the system will be used.
|
||||
timeRange: (optional) a TimeRange to specify which forecast hours to use.
|
||||
If not specified, will default to all forecast hours.
|
||||
|
||||
Returns:
|
||||
A _SoundingCube instance, which acts a 3-tiered dictionary, keyed
|
||||
by DataTime, then by level and finally by weather element. If no
|
||||
data is available for the given request parameters, None is returned.
|
||||
"""
|
||||
|
||||
(locationNames, parameters, levels, envelope, refTime, timeRange) = \
|
||||
__sanitizeInputs(modelName, weatherElements, levels, samplePoint, refTime, timeRange)
|
||||
|
||||
requestArgs = { 'datatype' : 'grid',
|
||||
'locationNames' : locationNames,
|
||||
'parameters' : parameters,
|
||||
'levels' : levels,
|
||||
'envelope' : envelope,
|
||||
}
|
||||
|
||||
req = DataAccessLayer.newDataRequest(**requestArgs)
|
||||
|
||||
forecastHours = __determineForecastHours(req, refTime, timeRange)
|
||||
if not forecastHours:
|
||||
return None
|
||||
|
||||
response = DataAccessLayer.getGeometryData(req, forecastHours)
|
||||
soundingObject = _SoundingCube(response)
|
||||
|
||||
return soundingObject
|
||||
|
||||
def setEDEXHost(host):
|
||||
"""
|
||||
Changes the EDEX host the Data Access Framework is communicating with.
|
||||
|
||||
Args:
|
||||
host: the EDEX host to connect to
|
||||
"""
|
||||
|
||||
if host:
|
||||
DataAccessLayer.changeEDEXHost(str(host))
|
||||
|
||||
def __sanitizeInputs(modelName, weatherElements, levels, samplePoint, refTime, timeRange):
|
||||
locationNames = [str(modelName)]
|
||||
parameters = __buildStringList(weatherElements)
|
||||
levels = __buildStringList(levels)
|
||||
envelope = Point(samplePoint)
|
||||
if refTime is not None:
|
||||
refTime = DataTime(refTime=DateTimeConverter.convertToDateTime(refTime))
|
||||
if timeRange is not None:
|
||||
timeRange = DateTimeConverter.constructTimeRange(*timeRange)
|
||||
return (locationNames, parameters, levels, envelope, refTime, timeRange)
|
||||
|
||||
def __determineForecastHours(request, refTime, timeRange):
|
||||
dataTimes = DataAccessLayer.getAvailableTimes(request, False)
|
||||
timesGen = [(DataTime(refTime=dataTime.getRefTime()), dataTime) for dataTime in dataTimes]
|
||||
dataTimesMap = defaultdict(list)
|
||||
for baseTime, dataTime in timesGen:
|
||||
dataTimesMap[baseTime].append(dataTime)
|
||||
|
||||
if refTime is None:
|
||||
refTime = max(dataTimesMap.keys())
|
||||
|
||||
forecastHours = dataTimesMap[refTime]
|
||||
if timeRange is None:
|
||||
return forecastHours
|
||||
else:
|
||||
return [forecastHour for forecastHour in forecastHours if timeRange.contains(forecastHour.getValidPeriod())]
|
||||
|
||||
def __buildStringList(param):
|
||||
if __notStringIter(param):
|
||||
return [str(item) for item in param]
|
||||
else:
|
||||
return [str(param)]
|
||||
|
||||
def __notStringIter(iterable):
|
||||
if not isinstance(iterable, basestring):
|
||||
try:
|
||||
iter(iterable)
|
||||
return True
|
||||
except TypeError:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
class _SoundingCube(object):
|
||||
"""
|
||||
The top-level sounding object returned when calling SoundingsSupport.getSounding.
|
||||
|
||||
This object acts as a 3-tiered dict which is keyed by time then level
|
||||
then parameter name. Calling times() will return all valid keys into this
|
||||
object.
|
||||
"""
|
||||
|
||||
def __init__(self, geometryDataObjects):
|
||||
self._dataDict = {}
|
||||
self._sortedTimes = []
|
||||
if geometryDataObjects:
|
||||
for geometryData in geometryDataObjects:
|
||||
dataTime = geometryData.getDataTime()
|
||||
level = geometryData.getLevel()
|
||||
for parameter in geometryData.getParameters():
|
||||
self.__addItem(parameter, dataTime, level, geometryData.getNumber(parameter))
|
||||
|
||||
def __addItem(self, parameter, dataTime, level, value):
|
||||
timeLayer = self._dataDict.get(dataTime, _SoundingTimeLayer(dataTime))
|
||||
self._dataDict[dataTime] = timeLayer
|
||||
timeLayer._addItem(parameter, level, value)
|
||||
if dataTime not in self._sortedTimes:
|
||||
self._sortedTimes.append(dataTime)
|
||||
self._sortedTimes.sort()
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self._dataDict[key]
|
||||
|
||||
def __len__(self):
|
||||
return len(self._dataDict)
|
||||
|
||||
def times(self):
|
||||
"""
|
||||
Returns the valid times for this sounding.
|
||||
|
||||
Returns:
|
||||
A list containing the valid DataTimes for this sounding in order.
|
||||
"""
|
||||
return self._sortedTimes
|
||||
|
||||
|
||||
class _SoundingTimeLayer(object):
|
||||
"""
|
||||
The second-level sounding object returned when calling SoundingsSupport.getSounding.
|
||||
|
||||
This object acts as a 2-tiered dict which is keyed by level then parameter
|
||||
name. Calling levels() will return all valid keys into this
|
||||
object. Calling time() will return the DataTime for this particular layer.
|
||||
"""
|
||||
|
||||
def __init__(self, dataTime):
|
||||
self._dataTime = dataTime
|
||||
self._dataDict = {}
|
||||
|
||||
def _addItem(self, parameter, level, value):
|
||||
asString = str(level)
|
||||
levelLayer = self._dataDict.get(asString, _SoundingTimeAndLevelLayer(self._dataTime, asString))
|
||||
levelLayer._addItem(parameter, value)
|
||||
self._dataDict[asString] = levelLayer
|
||||
|
||||
def __getitem__(self, key):
|
||||
asString = str(key)
|
||||
if asString in self._dataDict:
|
||||
return self._dataDict[asString]
|
||||
else:
|
||||
raise KeyError("Level " + str(key) + " is not a valid level for this sounding.")
|
||||
|
||||
def __len__(self):
|
||||
return len(self._dataDict)
|
||||
|
||||
def time(self):
|
||||
"""
|
||||
Returns the DataTime for this sounding cube layer.
|
||||
|
||||
Returns:
|
||||
The DataTime for this sounding layer.
|
||||
"""
|
||||
return self._dataTime
|
||||
|
||||
def levels(self):
|
||||
"""
|
||||
Returns the valid levels for this sounding.
|
||||
|
||||
Returns:
|
||||
A list containing the valid levels for this sounding in order of
|
||||
closest to surface to highest from surface.
|
||||
"""
|
||||
sortedLevels = [Level(level) for level in self._dataDict.keys()]
|
||||
sortedLevels.sort()
|
||||
return [str(level) for level in sortedLevels]
|
||||
|
||||
|
||||
class _SoundingTimeAndLevelLayer(object):
|
||||
"""
|
||||
The bottom-level sounding object returned when calling SoundingsSupport.getSounding.
|
||||
|
||||
This object acts as a dict which is keyed by parameter name. Calling
|
||||
parameters() will return all valid keys into this object. Calling time()
|
||||
will return the DataTime for this particular layer. Calling level() will
|
||||
return the level for this layer.
|
||||
"""
|
||||
|
||||
def __init__(self, time, level):
|
||||
self._time = time
|
||||
self._level = level
|
||||
self._parameters = {}
|
||||
|
||||
def _addItem(self, parameter, value):
|
||||
self._parameters[parameter] = value
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self._parameters[key]
|
||||
|
||||
def __len__(self):
|
||||
return len(self._parameters)
|
||||
|
||||
def level(self):
|
||||
"""
|
||||
Returns the level for this sounding cube layer.
|
||||
|
||||
Returns:
|
||||
The level for this sounding layer.
|
||||
"""
|
||||
return self._level
|
||||
|
||||
def parameters(self):
|
||||
"""
|
||||
Returns the valid parameters for this sounding.
|
||||
|
||||
Returns:
|
||||
A list containing the valid parameter names.
|
||||
"""
|
||||
return list(self._parameters.keys())
|
||||
|
||||
def time(self):
|
||||
"""
|
||||
Returns the DataTime for this sounding cube layer.
|
||||
|
||||
Returns:
|
||||
The DataTime for this sounding layer.
|
||||
"""
|
||||
return self._time
|
|
@ -83,7 +83,7 @@ class ThriftClientRouter(object):
|
|||
response = self._client.sendRequest(gridDataRequest)
|
||||
|
||||
locSpecificData = {}
|
||||
locNames = response.getSiteNxValues().keys()
|
||||
locNames = list(response.getSiteNxValues().keys())
|
||||
for location in locNames:
|
||||
nx = response.getSiteNxValues()[location]
|
||||
ny = response.getSiteNyValues()[location]
|
||||
|
@ -114,7 +114,7 @@ class ThriftClientRouter(object):
|
|||
geometries = []
|
||||
for wkb in response.getGeometryWKBs():
|
||||
# convert the wkb to a bytearray with only positive values
|
||||
byteArrWKB = bytearray(map(lambda x: x % 256,wkb.tolist()))
|
||||
byteArrWKB = bytearray([x % 256 for x in wkb.tolist()])
|
||||
# convert the bytearray to a byte string and load it.
|
||||
geometries.append(shapely.wkb.loads(str(byteArrWKB)))
|
||||
|
||||
|
|
176
awips/dataaccess/ThriftClientRouter.py.bak
Normal file
176
awips/dataaccess/ThriftClientRouter.py.bak
Normal file
|
@ -0,0 +1,176 @@
|
|||
# #
|
||||
# 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.
|
||||
# #
|
||||
|
||||
#
|
||||
# Routes requests to the Data Access Framework through Python Thrift.
|
||||
#
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 05/21/13 #2023 dgilling Initial Creation.
|
||||
# 01/06/14 #2537 bsteffen Share geometry WKT.
|
||||
# 03/03/14 #2673 bsteffen Add ability to query only ref times.
|
||||
# 07/22/14 #3185 njensen Added optional/default args to newDataRequest
|
||||
# 07/23/14 #3185 njensen Added new methods
|
||||
# 07/30/14 #3185 njensen Renamed valid identifiers to optional
|
||||
# 06/30/15 #4569 nabowle Use hex WKB for geometries.
|
||||
#
|
||||
|
||||
|
||||
import numpy
|
||||
import shapely.wkb
|
||||
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.impl import DefaultDataRequest
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetAvailableLocationNamesRequest
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetAvailableTimesRequest
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetGeometryDataRequest
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetGridDataRequest
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetAvailableParametersRequest
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetAvailableLevelsRequest
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetRequiredIdentifiersRequest
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetOptionalIdentifiersRequest
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetSupportedDatatypesRequest
|
||||
|
||||
from awips import ThriftClient
|
||||
from awips.dataaccess import PyGeometryData
|
||||
from awips.dataaccess import PyGridData
|
||||
|
||||
|
||||
class ThriftClientRouter(object):
|
||||
|
||||
def __init__(self, host='localhost'):
|
||||
self._client = ThriftClient.ThriftClient(host)
|
||||
|
||||
def getAvailableTimes(self, request, refTimeOnly):
|
||||
timesRequest = GetAvailableTimesRequest()
|
||||
timesRequest.setRequestParameters(request)
|
||||
timesRequest.setRefTimeOnly(refTimeOnly)
|
||||
response = self._client.sendRequest(timesRequest)
|
||||
return response
|
||||
|
||||
def getGridData(self, request, times):
|
||||
gridDataRequest = GetGridDataRequest()
|
||||
gridDataRequest.setRequestParameters(request)
|
||||
# if we have an iterable times instance, then the user must have asked
|
||||
# for grid data with the List of DataTime objects
|
||||
# else, we assume it was a single TimeRange that was meant for the
|
||||
# request
|
||||
try:
|
||||
iter(times)
|
||||
gridDataRequest.setRequestedTimes(times)
|
||||
except TypeError:
|
||||
gridDataRequest.setRequestedPeriod(times)
|
||||
response = self._client.sendRequest(gridDataRequest)
|
||||
|
||||
locSpecificData = {}
|
||||
locNames = response.getSiteNxValues().keys()
|
||||
for location in locNames:
|
||||
nx = response.getSiteNxValues()[location]
|
||||
ny = response.getSiteNyValues()[location]
|
||||
latData = numpy.reshape(numpy.array(response.getSiteLatGrids()[location]), (nx, ny))
|
||||
lonData = numpy.reshape(numpy.array(response.getSiteLonGrids()[location]), (nx, ny))
|
||||
locSpecificData[location] = (nx, ny, (lonData, latData))
|
||||
|
||||
retVal = []
|
||||
for gridDataRecord in response.getGridData():
|
||||
locationName = gridDataRecord.getLocationName()
|
||||
locData = locSpecificData[locationName]
|
||||
retVal.append(PyGridData.PyGridData(gridDataRecord, locData[0], locData[1], locData[2]))
|
||||
return retVal
|
||||
|
||||
def getGeometryData(self, request, times):
|
||||
geoDataRequest = GetGeometryDataRequest()
|
||||
geoDataRequest.setRequestParameters(request)
|
||||
# if we have an iterable times instance, then the user must have asked
|
||||
# for geometry data with the List of DataTime objects
|
||||
# else, we assume it was a single TimeRange that was meant for the
|
||||
# request
|
||||
try:
|
||||
iter(times)
|
||||
geoDataRequest.setRequestedTimes(times)
|
||||
except TypeError:
|
||||
geoDataRequest.setRequestedPeriod(times)
|
||||
response = self._client.sendRequest(geoDataRequest)
|
||||
geometries = []
|
||||
for wkb in response.getGeometryWKBs():
|
||||
# convert the wkb to a bytearray with only positive values
|
||||
byteArrWKB = bytearray(map(lambda x: x % 256,wkb.tolist()))
|
||||
# convert the bytearray to a byte string and load it.
|
||||
geometries.append(shapely.wkb.loads(str(byteArrWKB)))
|
||||
|
||||
retVal = []
|
||||
for geoDataRecord in response.getGeoData():
|
||||
geom = geometries[geoDataRecord.getGeometryWKBindex()]
|
||||
retVal.append(PyGeometryData.PyGeometryData(geoDataRecord, geom))
|
||||
return retVal
|
||||
|
||||
def getAvailableLocationNames(self, request):
|
||||
locNamesRequest = GetAvailableLocationNamesRequest()
|
||||
locNamesRequest.setRequestParameters(request)
|
||||
response = self._client.sendRequest(locNamesRequest)
|
||||
return response
|
||||
|
||||
def getAvailableParameters(self, request):
|
||||
paramReq = GetAvailableParametersRequest()
|
||||
paramReq.setRequestParameters(request)
|
||||
response = self._client.sendRequest(paramReq)
|
||||
return response
|
||||
|
||||
def getAvailableLevels(self, request):
|
||||
levelReq = GetAvailableLevelsRequest()
|
||||
levelReq.setRequestParameters(request)
|
||||
response = self._client.sendRequest(levelReq)
|
||||
return response
|
||||
|
||||
def getRequiredIdentifiers(self, datatype):
|
||||
idReq = GetRequiredIdentifiersRequest()
|
||||
idReq.setDatatype(datatype)
|
||||
response = self._client.sendRequest(idReq)
|
||||
return response
|
||||
|
||||
def getOptionalIdentifiers(self, datatype):
|
||||
idReq = GetOptionalIdentifiersRequest()
|
||||
idReq.setDatatype(datatype)
|
||||
response = self._client.sendRequest(idReq)
|
||||
return response
|
||||
|
||||
def newDataRequest(self, datatype, parameters=[], levels=[], locationNames = [], envelope=None, **kwargs):
|
||||
req = DefaultDataRequest()
|
||||
if datatype:
|
||||
req.setDatatype(datatype)
|
||||
if parameters:
|
||||
req.setParameters(*parameters)
|
||||
if levels:
|
||||
req.setLevels(*levels)
|
||||
if locationNames:
|
||||
req.setLocationNames(*locationNames)
|
||||
if envelope:
|
||||
req.setEnvelope(envelope)
|
||||
if kwargs:
|
||||
# any args leftover are assumed to be identifiers
|
||||
req.identifiers = kwargs
|
||||
return req
|
||||
|
||||
def getSupportedDatatypes(self):
|
||||
response = self._client.sendRequest(GetSupportedDatatypesRequest())
|
||||
return response
|
|
@ -42,11 +42,10 @@ __all__ = [
|
|||
|
||||
import abc
|
||||
|
||||
class IDataRequest(object):
|
||||
class IDataRequest(object, metaclass=abc.ABCMeta):
|
||||
"""
|
||||
An IDataRequest to be submitted to the DataAccessLayer to retrieve data.
|
||||
"""
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
@abc.abstractmethod
|
||||
def setDatatype(self, datatype):
|
||||
|
@ -164,11 +163,10 @@ class IDataRequest(object):
|
|||
|
||||
|
||||
|
||||
class IData(object):
|
||||
class IData(object, metaclass=abc.ABCMeta):
|
||||
"""
|
||||
An IData representing data returned from the DataAccessLayer.
|
||||
"""
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
@abc.abstractmethod
|
||||
def getAttribute(self, key):
|
||||
|
|
353
awips/dataaccess/__init__.py.bak
Normal file
353
awips/dataaccess/__init__.py.bak
Normal file
|
@ -0,0 +1,353 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
|
||||
#
|
||||
# __init__.py for awips.dataaccess package
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 12/10/12 njensen Initial Creation.
|
||||
# Feb 14, 2013 1614 bsteffen refactor data access framework
|
||||
# to use single request.
|
||||
# Apr 09, 2013 1871 njensen Add doc strings
|
||||
# Jun 03, 2013 2023 dgilling Add getAttributes to IData, add
|
||||
# getLatLonGrids() to IGridData.
|
||||
#
|
||||
#
|
||||
|
||||
__all__ = [
|
||||
|
||||
]
|
||||
|
||||
import abc
|
||||
|
||||
class IDataRequest(object):
|
||||
"""
|
||||
An IDataRequest to be submitted to the DataAccessLayer to retrieve data.
|
||||
"""
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
@abc.abstractmethod
|
||||
def setDatatype(self, datatype):
|
||||
"""
|
||||
Sets the datatype of the request.
|
||||
|
||||
Args:
|
||||
datatype: A string of the datatype, such as "grid", "radar", "gfe", "obs"
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def addIdentifier(self, key, value):
|
||||
"""
|
||||
Adds an identifier to the request. Identifiers are specific to the
|
||||
datatype being requested.
|
||||
|
||||
Args:
|
||||
key: the string key of the identifier
|
||||
value: the value of the identifier
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def setParameters(self, params):
|
||||
"""
|
||||
Sets the parameters of data to request.
|
||||
|
||||
Args:
|
||||
params: a list of strings of parameters to request
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def setLevels(self, levels):
|
||||
"""
|
||||
Sets the levels of data to request. Not all datatypes support levels.
|
||||
|
||||
Args:
|
||||
levels: a list of strings of level abbreviations to request
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def setEnvelope(self, env):
|
||||
"""
|
||||
Sets the envelope of the request. If supported by the datatype factory,
|
||||
the data returned for the request will be constrained to only the data
|
||||
within the envelope.
|
||||
|
||||
Args:
|
||||
env: a shapely geometry
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def setLocationNames(self, locationNames):
|
||||
"""
|
||||
Sets the location names of the request.
|
||||
|
||||
Args:
|
||||
locationNames: a list of strings of location names to request
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getDatatype(self):
|
||||
"""
|
||||
Gets the datatype of the request
|
||||
|
||||
Returns:
|
||||
the datatype set on the request
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getIdentifiers(self):
|
||||
"""
|
||||
Gets the identifiers on the request
|
||||
|
||||
Returns:
|
||||
a dictionary of the identifiers
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getLevels(self):
|
||||
"""
|
||||
Gets the levels on the request
|
||||
|
||||
Returns:
|
||||
a list of strings of the levels
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getLocationNames(self):
|
||||
"""
|
||||
Gets the location names on the request
|
||||
|
||||
Returns:
|
||||
a list of strings of the location names
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getEnvelope(self):
|
||||
"""
|
||||
Gets the envelope on the request
|
||||
|
||||
Returns:
|
||||
a rectangular shapely geometry
|
||||
"""
|
||||
return
|
||||
|
||||
|
||||
|
||||
class IData(object):
|
||||
"""
|
||||
An IData representing data returned from the DataAccessLayer.
|
||||
"""
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
@abc.abstractmethod
|
||||
def getAttribute(self, key):
|
||||
"""
|
||||
Gets an attribute of the data.
|
||||
|
||||
Args:
|
||||
key: the key of the attribute
|
||||
|
||||
Returns:
|
||||
the value of the attribute
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getAttributes(self):
|
||||
"""
|
||||
Gets the valid attributes for the data.
|
||||
|
||||
Returns:
|
||||
a list of strings of the attribute names
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getDataTime(self):
|
||||
"""
|
||||
Gets the data time of the data.
|
||||
|
||||
Returns:
|
||||
the data time of the data, or None if no time is associated
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getLevel(self):
|
||||
"""
|
||||
Gets the level of the data.
|
||||
|
||||
Returns:
|
||||
the level of the data, or None if no level is associated
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getLocationName(self, param):
|
||||
"""
|
||||
Gets the location name of the data.
|
||||
|
||||
Returns:
|
||||
the location name of the data, or None if no location name is
|
||||
associated
|
||||
"""
|
||||
return
|
||||
|
||||
|
||||
|
||||
class IGridData(IData):
|
||||
"""
|
||||
An IData representing grid data that is returned by the DataAccessLayer.
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def getParameter(self):
|
||||
"""
|
||||
Gets the parameter of the data.
|
||||
|
||||
Returns:
|
||||
the parameter of the data
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getUnit(self):
|
||||
"""
|
||||
Gets the unit of the data.
|
||||
|
||||
Returns:
|
||||
the string abbreviation of the unit, or None if no unit is associated
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getRawData(self):
|
||||
"""
|
||||
Gets the grid data as a numpy array.
|
||||
|
||||
Returns:
|
||||
a numpy array of the data
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getLatLonCoords(self):
|
||||
"""
|
||||
Gets the lat/lon coordinates of the grid data.
|
||||
|
||||
Returns:
|
||||
a tuple where the first element is a numpy array of lons, and the
|
||||
second element is a numpy array of lats
|
||||
"""
|
||||
return
|
||||
|
||||
|
||||
|
||||
class IGeometryData(IData):
|
||||
"""
|
||||
An IData representing geometry data that is returned by the DataAccessLayer.
|
||||
"""
|
||||
|
||||
@abc.abstractmethod
|
||||
def getGeometry(self):
|
||||
"""
|
||||
Gets the geometry of the data.
|
||||
|
||||
Returns:
|
||||
a shapely geometry
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getParameters(self):
|
||||
"""Gets the parameters of the data.
|
||||
|
||||
Returns:
|
||||
a list of strings of the parameter names
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getString(self, param):
|
||||
"""
|
||||
Gets the string value of the specified param.
|
||||
|
||||
Args:
|
||||
param: the string name of the param
|
||||
|
||||
Returns:
|
||||
the string value of the param
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getNumber(self, param):
|
||||
"""
|
||||
Gets the number value of the specified param.
|
||||
|
||||
Args:
|
||||
param: the string name of the param
|
||||
|
||||
Returns:
|
||||
the number value of the param
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getUnit(self, param):
|
||||
"""
|
||||
Gets the unit of the specified param.
|
||||
|
||||
Args:
|
||||
param: the string name of the param
|
||||
|
||||
Returns:
|
||||
the string abbreviation of the unit of the param
|
||||
"""
|
||||
return
|
||||
|
||||
@abc.abstractmethod
|
||||
def getType(self, param):
|
||||
"""
|
||||
Gets the type of the param.
|
||||
|
||||
Args:
|
||||
param: the string name of the param
|
||||
|
||||
Returns:
|
||||
a string of the type of the parameter, such as
|
||||
"STRING", "INT", "LONG", "FLOAT", or "DOUBLE"
|
||||
"""
|
||||
return
|
||||
|
|
@ -85,9 +85,9 @@ class IngestViaQPID:
|
|||
self.connection.start()
|
||||
self.session = self.connection.session(str(uuid4()))
|
||||
self.session.exchange_bind(exchange='amq.direct', queue='external.dropbox', binding_key='external.dropbox')
|
||||
print 'Connected to Qpid'
|
||||
print('Connected to Qpid')
|
||||
except:
|
||||
print 'Unable to connect to Qpid'
|
||||
print('Unable to connect to Qpid')
|
||||
|
||||
def sendmessage(self, filepath, header):
|
||||
'''
|
||||
|
@ -108,4 +108,4 @@ class IngestViaQPID:
|
|||
there are no threads left open
|
||||
'''
|
||||
self.session.close(timeout=10)
|
||||
print 'Connection to Qpid closed'
|
||||
print('Connection to Qpid closed')
|
||||
|
|
111
awips/qpidingest.py.bak
Normal file
111
awips/qpidingest.py.bak
Normal file
|
@ -0,0 +1,111 @@
|
|||
#===============================================================================
|
||||
# qpidingest.py
|
||||
#
|
||||
# @author: Aaron Anderson
|
||||
# @organization: NOAA/WDTB OU/CIMMS
|
||||
# @version: 1.0 02/19/2010
|
||||
# @requires: QPID Python Client available from http://qpid.apache.org/download.html
|
||||
# The Python Client is located under Single Component Package/Client
|
||||
#
|
||||
# From the README.txt Installation Instructions
|
||||
# = INSTALLATION =
|
||||
# Extract the release archive into a directory of your choice and set
|
||||
# your PYTHONPATH accordingly:
|
||||
#
|
||||
# tar -xzf qpid-python-<version>.tar.gz -C <install-prefix>
|
||||
# export PYTHONPATH=<install-prefix>/qpid-<version>/python
|
||||
#
|
||||
# ***EDEX and QPID must be running for this module to work***
|
||||
#
|
||||
# DESCRIPTION:
|
||||
# This module is used to connect to QPID and send messages to the external.dropbox queue
|
||||
# which tells EDEX to ingest a data file from a specified path. This avoids having to copy
|
||||
# a data file into an endpoint. Each message also contains a header which is used to determine
|
||||
# which plugin should be used to decode the file. Each plugin has an xml file located in
|
||||
# $EDEX_HOME/data/utility/edex_static/base/distribution that contains regular expressions
|
||||
# that the header is compared to. When the header matches one of these regular expressions
|
||||
# the file is decoded with that plugin. If you make changes to one of these xml files you
|
||||
# must restart EDEX for the changes to take effect.
|
||||
#
|
||||
# NOTE: If the message is being sent but you do not see it being ingested in the EDEX log
|
||||
# check the xml files to make sure the header you are passing matches one of the regular
|
||||
# expressions. Beware of spaces, some regular expressions require spaces while others use
|
||||
# a wildcard character so a space is optional. It seems you are better off having the space
|
||||
# as this will be matched to both patterns. For the file in the example below,
|
||||
# 20100218_185755_SAUS46KLOX.metar, I use SAUS46 KLOX as the header to make sure it matches.
|
||||
#
|
||||
#
|
||||
# EXAMPLE:
|
||||
# Simple example program:
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
# import qpidingest
|
||||
# #Tell EDEX to ingest a metar file from data_store. The filepath is
|
||||
# #/data_store/20100218/metar/00/standard/20100218_005920_SAUS46KSEW.metar
|
||||
#
|
||||
# conn=qpidingest.IngestViaQPID() #defaults to localhost port 5672
|
||||
#
|
||||
# #If EDEX is not on the local machine you can make the connection as follows
|
||||
# #conn=qpidingest.IngestViaQPID(host='<MACHINE NAME>',port=<PORT NUMBER>)
|
||||
#
|
||||
# conn.sendmessage('/data_store/20100218/metar/18/standard/20100218_185755_SAUS46KLOX.metar','SAUS46 KLOX')
|
||||
# conn.close()
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# ....
|
||||
# 06/13/2013 DR 16242 D. Friedman Add Qpid authentication info
|
||||
# 03/06/2014 DR 17907 D. Friedman Workaround for issue QPID-5569
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
import qpid
|
||||
from qpid.util import connect
|
||||
from qpid.connection import Connection
|
||||
from qpid.datatypes import Message, uuid4
|
||||
|
||||
QPID_USERNAME = 'guest'
|
||||
QPID_PASSWORD = 'guest'
|
||||
|
||||
class IngestViaQPID:
|
||||
def __init__(self, host='localhost', port=5672):
|
||||
'''
|
||||
Connect to QPID and make bindings to route message to external.dropbox queue
|
||||
@param host: string hostname of computer running EDEX and QPID (default localhost)
|
||||
@param port: integer port used to connect to QPID (default 5672)
|
||||
'''
|
||||
|
||||
try:
|
||||
#
|
||||
self.socket = connect(host, port)
|
||||
self.connection = Connection (sock=self.socket, username=QPID_USERNAME, password=QPID_PASSWORD)
|
||||
self.connection.start()
|
||||
self.session = self.connection.session(str(uuid4()))
|
||||
self.session.exchange_bind(exchange='amq.direct', queue='external.dropbox', binding_key='external.dropbox')
|
||||
print 'Connected to Qpid'
|
||||
except:
|
||||
print 'Unable to connect to Qpid'
|
||||
|
||||
def sendmessage(self, filepath, header):
|
||||
'''
|
||||
This function sends a message to the external.dropbox queue providing the path
|
||||
to the file to be ingested and a header to determine the plugin to be used to
|
||||
decode the file.
|
||||
@param filepath: string full path to file to be ingested
|
||||
@param header: string header used to determine plugin decoder to use
|
||||
'''
|
||||
props = self.session.delivery_properties(routing_key='external.dropbox')
|
||||
head = self.session.message_properties(application_headers={'header':header},
|
||||
user_id=QPID_USERNAME) # For issue QPID-5569. Fixed in Qpid 0.27
|
||||
self.session.message_transfer(destination='amq.direct', message=Message(props, head, filepath))
|
||||
|
||||
def close(self):
|
||||
'''
|
||||
After all messages are sent call this function to close connection and make sure
|
||||
there are no threads left open
|
||||
'''
|
||||
self.session.close(timeout=10)
|
||||
print 'Connection to Qpid closed'
|
|
@ -87,12 +87,13 @@ import random
|
|||
import re
|
||||
import socket
|
||||
import sys
|
||||
import thread
|
||||
import _thread
|
||||
import threading
|
||||
import time
|
||||
import types
|
||||
import xml.dom.minidom
|
||||
from cStringIO import StringIO
|
||||
from io import StringIO
|
||||
from functools import reduce
|
||||
|
||||
#
|
||||
# stomp.py version number
|
||||
|
@ -106,14 +107,14 @@ def _uuid( *args ):
|
|||
(http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/213761)
|
||||
"""
|
||||
|
||||
t = long( time.time() * 1000 )
|
||||
r = long( random.random() * 100000000000000000L )
|
||||
t = int( time.time() * 1000 )
|
||||
r = int( random.random() * 100000000000000000 )
|
||||
|
||||
try:
|
||||
a = socket.gethostbyname( socket.gethostname() )
|
||||
except:
|
||||
# if we can't get a network address, just imagine one
|
||||
a = random.random() * 100000000000000000L
|
||||
a = random.random() * 100000000000000000
|
||||
data = str(t) + ' ' + str(r) + ' ' + str(a) + ' ' + str(args)
|
||||
md5 = hashlib.md5()
|
||||
md5.update(data)
|
||||
|
@ -126,7 +127,7 @@ class DevNullLogger(object):
|
|||
dummy logging class for environments without the logging module
|
||||
"""
|
||||
def log(self, msg):
|
||||
print msg
|
||||
print(msg)
|
||||
|
||||
def devnull(self, msg):
|
||||
pass
|
||||
|
@ -371,7 +372,7 @@ class Connection(object):
|
|||
"""
|
||||
self.__running = True
|
||||
self.__attempt_connection()
|
||||
thread.start_new_thread(self.__receiver_loop, ())
|
||||
_thread.start_new_thread(self.__receiver_loop, ())
|
||||
|
||||
def stop(self):
|
||||
"""
|
||||
|
@ -434,7 +435,7 @@ class Connection(object):
|
|||
|
||||
def begin(self, headers={}, **keyword_headers):
|
||||
use_headers = self.__merge_headers([headers, keyword_headers])
|
||||
if not 'transaction' in use_headers.keys():
|
||||
if not 'transaction' in list(use_headers.keys()):
|
||||
use_headers['transaction'] = _uuid()
|
||||
self.__send_frame_helper('BEGIN', '', use_headers, [ 'transaction' ])
|
||||
return use_headers['transaction']
|
||||
|
@ -446,7 +447,7 @@ class Connection(object):
|
|||
self.__send_frame_helper('COMMIT', '', self.__merge_headers([headers, keyword_headers]), [ 'transaction' ])
|
||||
|
||||
def connect(self, headers={}, **keyword_headers):
|
||||
if keyword_headers.has_key('wait') and keyword_headers['wait']:
|
||||
if 'wait' in keyword_headers and keyword_headers['wait']:
|
||||
while not self.is_connected(): time.sleep(0.1)
|
||||
del keyword_headers['wait']
|
||||
self.__send_frame_helper('CONNECT', '', self.__merge_headers([self.__connect_headers, headers, keyword_headers]), [ ])
|
||||
|
@ -490,7 +491,7 @@ class Connection(object):
|
|||
"""
|
||||
headers = {}
|
||||
for header_map in header_map_list:
|
||||
for header_key in header_map.keys():
|
||||
for header_key in list(header_map.keys()):
|
||||
headers[header_key] = header_map[header_key]
|
||||
return headers
|
||||
|
||||
|
@ -532,11 +533,11 @@ class Connection(object):
|
|||
if type(required_header_key) == tuple:
|
||||
found_alternative = False
|
||||
for alternative in required_header_key:
|
||||
if alternative in headers.keys():
|
||||
if alternative in list(headers.keys()):
|
||||
found_alternative = True
|
||||
if not found_alternative:
|
||||
raise KeyError("Command %s requires one of the following headers: %s" % (command, str(required_header_key)))
|
||||
elif not required_header_key in headers.keys():
|
||||
elif not required_header_key in list(headers.keys()):
|
||||
raise KeyError("Command %s requires header %r" % (command, required_header_key))
|
||||
self.__send_frame(command, headers, payload)
|
||||
|
||||
|
@ -550,7 +551,7 @@ class Connection(object):
|
|||
|
||||
if self.__socket is not None:
|
||||
frame = '%s\n%s\n%s\x00' % (command,
|
||||
reduce(lambda accu, key: accu + ('%s:%s\n' % (key, headers[key])), headers.keys(), ''),
|
||||
reduce(lambda accu, key: accu + ('%s:%s\n' % (key, headers[key])), list(headers.keys()), ''),
|
||||
payload)
|
||||
self.__socket.sendall(frame)
|
||||
log.debug("Sent frame: type=%s, headers=%r, body=%r" % (command, headers, payload))
|
||||
|
@ -707,7 +708,7 @@ class Connection(object):
|
|||
assert len(pair) == 2
|
||||
entries[pair[0]] = pair[1]
|
||||
return entries
|
||||
except Exception, ex:
|
||||
except Exception as ex:
|
||||
# unable to parse message. return original
|
||||
return body
|
||||
|
||||
|
@ -762,7 +763,7 @@ class Connection(object):
|
|||
break
|
||||
except socket.error:
|
||||
self.__socket = None
|
||||
if type(sys.exc_info()[1]) == types.TupleType:
|
||||
if type(sys.exc_info()[1]) == tuple:
|
||||
exc = sys.exc_info()[1][1]
|
||||
else:
|
||||
exc = sys.exc_info()[1]
|
||||
|
@ -813,20 +814,20 @@ if __name__ == '__main__':
|
|||
self.c.start()
|
||||
|
||||
def __print_async(self, frame_type, headers, body):
|
||||
print "\r \r",
|
||||
print frame_type
|
||||
for header_key in headers.keys():
|
||||
print '%s: %s' % (header_key, headers[header_key])
|
||||
print
|
||||
print body
|
||||
print '> ',
|
||||
print("\r \r", end=' ')
|
||||
print(frame_type)
|
||||
for header_key in list(headers.keys()):
|
||||
print('%s: %s' % (header_key, headers[header_key]))
|
||||
print()
|
||||
print(body)
|
||||
print('> ', end=' ')
|
||||
sys.stdout.flush()
|
||||
|
||||
def on_connecting(self, host_and_port):
|
||||
self.c.connect(wait=True)
|
||||
|
||||
def on_disconnected(self):
|
||||
print "lost connection"
|
||||
print("lost connection")
|
||||
|
||||
def on_message(self, headers, body):
|
||||
self.__print_async("MESSAGE", headers, body)
|
||||
|
@ -850,13 +851,13 @@ if __name__ == '__main__':
|
|||
self.c.abort(transaction=args[1])
|
||||
|
||||
def begin(self, args):
|
||||
print 'transaction id: %s' % self.c.begin()
|
||||
print('transaction id: %s' % self.c.begin())
|
||||
|
||||
def commit(self, args):
|
||||
if len(args) < 2:
|
||||
print 'expecting: commit <transid>'
|
||||
print('expecting: commit <transid>')
|
||||
else:
|
||||
print 'committing %s' % args[1]
|
||||
print('committing %s' % args[1])
|
||||
self.c.commit(transaction=args[1])
|
||||
|
||||
def disconnect(self, args):
|
||||
|
@ -867,35 +868,35 @@ if __name__ == '__main__':
|
|||
|
||||
def send(self, args):
|
||||
if len(args) < 3:
|
||||
print 'expecting: send <destination> <message>'
|
||||
print('expecting: send <destination> <message>')
|
||||
else:
|
||||
self.c.send(destination=args[1], message=' '.join(args[2:]))
|
||||
|
||||
def sendtrans(self, args):
|
||||
if len(args) < 3:
|
||||
print 'expecting: sendtrans <destination> <transid> <message>'
|
||||
print('expecting: sendtrans <destination> <transid> <message>')
|
||||
else:
|
||||
self.c.send(destination=args[1], message="%s\n" % ' '.join(args[3:]), transaction=args[2])
|
||||
|
||||
def subscribe(self, args):
|
||||
if len(args) < 2:
|
||||
print 'expecting: subscribe <destination> [ack]'
|
||||
print('expecting: subscribe <destination> [ack]')
|
||||
elif len(args) > 2:
|
||||
print 'subscribing to "%s" with acknowledge set to "%s"' % (args[1], args[2])
|
||||
print('subscribing to "%s" with acknowledge set to "%s"' % (args[1], args[2]))
|
||||
self.c.subscribe(destination=args[1], ack=args[2])
|
||||
else:
|
||||
print 'subscribing to "%s" with auto acknowledge' % args[1]
|
||||
print('subscribing to "%s" with auto acknowledge' % args[1])
|
||||
self.c.subscribe(destination=args[1], ack='auto')
|
||||
|
||||
def unsubscribe(self, args):
|
||||
if len(args) < 2:
|
||||
print 'expecting: unsubscribe <destination>'
|
||||
print('expecting: unsubscribe <destination>')
|
||||
else:
|
||||
print 'unsubscribing from "%s"' % args[1]
|
||||
print('unsubscribing from "%s"' % args[1])
|
||||
self.c.unsubscribe(destination=args[1])
|
||||
|
||||
if len(sys.argv) > 5:
|
||||
print 'USAGE: stomp.py [host] [port] [user] [passcode]'
|
||||
print('USAGE: stomp.py [host] [port] [user] [passcode]')
|
||||
sys.exit(1)
|
||||
|
||||
if len(sys.argv) >= 2:
|
||||
|
@ -917,7 +918,7 @@ if __name__ == '__main__':
|
|||
st = StompTester(host, port, user, passcode)
|
||||
try:
|
||||
while True:
|
||||
line = raw_input("\r> ")
|
||||
line = input("\r> ")
|
||||
if not line or line.lstrip().rstrip() == '':
|
||||
continue
|
||||
elif 'quit' in line or 'disconnect' in line:
|
||||
|
@ -927,7 +928,7 @@ if __name__ == '__main__':
|
|||
if not command.startswith("on_") and hasattr(st, command):
|
||||
getattr(st, command)(split)
|
||||
else:
|
||||
print 'unrecognized command'
|
||||
print('unrecognized command')
|
||||
finally:
|
||||
st.disconnect(None)
|
||||
|
||||
|
|
934
awips/stomp.py.bak
Normal file
934
awips/stomp.py.bak
Normal file
|
@ -0,0 +1,934 @@
|
|||
#!/usr/bin/env 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.
|
||||
##
|
||||
"""Stomp Protocol Connectivity
|
||||
|
||||
This provides basic connectivity to a message broker supporting the 'stomp' protocol.
|
||||
At the moment ACK, SEND, SUBSCRIBE, UNSUBSCRIBE, BEGIN, ABORT, COMMIT, CONNECT and DISCONNECT operations
|
||||
are supported.
|
||||
|
||||
This changes the previous version which required a listener per subscription -- now a listener object
|
||||
just calls the 'addlistener' method and will receive all messages sent in response to all/any subscriptions.
|
||||
(The reason for the change is that the handling of an 'ack' becomes problematic unless the listener mechanism
|
||||
is decoupled from subscriptions).
|
||||
|
||||
Note that you must 'start' an instance of Connection to begin receiving messages. For example:
|
||||
|
||||
conn = stomp.Connection([('localhost', 62003)], 'myuser', 'mypass')
|
||||
conn.start()
|
||||
|
||||
Meta-Data
|
||||
---------
|
||||
Author: Jason R Briggs
|
||||
License: http://www.apache.org/licenses/LICENSE-2.0
|
||||
Start Date: 2005/12/01
|
||||
Last Revision Date: $Date: 2008/09/11 00:16 $
|
||||
|
||||
Notes/Attribution
|
||||
-----------------
|
||||
* uuid method courtesy of Carl Free Jr:
|
||||
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/213761
|
||||
* patch from Andreas Schobel
|
||||
* patches from Julian Scheid of Rising Sun Pictures (http://open.rsp.com.au)
|
||||
* patch from Fernando
|
||||
* patches from Eugene Strulyov
|
||||
|
||||
Updates
|
||||
-------
|
||||
* 2007/03/31 : (Andreas Schobel) patch to fix newlines problem in ActiveMQ 4.1
|
||||
* 2007/09 : (JRB) updated to get stomp.py working in Jython as well as Python
|
||||
* 2007/09/05 : (Julian Scheid) patch to allow sending custom headers
|
||||
* 2007/09/18 : (JRB) changed code to use logging instead of just print. added logger for jython to work
|
||||
* 2007/09/18 : (Julian Scheid) various updates, including:
|
||||
- change incoming message handling so that callbacks are invoked on the listener not only for MESSAGE, but also for
|
||||
CONNECTED, RECEIPT and ERROR frames.
|
||||
- callbacks now get not only the payload but any headers specified by the server
|
||||
- all outgoing messages now sent via a single method
|
||||
- only one connection used
|
||||
- change to use thread instead of threading
|
||||
- sends performed on the calling thread
|
||||
- receiver loop now deals with multiple messages in one received chunk of data
|
||||
- added reconnection attempts and connection fail-over
|
||||
- changed defaults for "user" and "passcode" to None instead of empty string (fixed transmission of those values)
|
||||
- added readline support
|
||||
* 2008/03/26 : (Fernando) added cStringIO for faster performance on large messages
|
||||
* 2008/09/10 : (Eugene) remove lower() on headers to support case-sensitive header names
|
||||
* 2008/09/11 : (JRB) fix incompatibilities with RabbitMQ, add wait for socket-connect
|
||||
* 2008/10/28 : (Eugene) add jms map (from stomp1.1 ideas)
|
||||
* 2008/11/25 : (Eugene) remove superfluous (incorrect) locking code
|
||||
* 2009/02/05 : (JRB) remove code to replace underscores with dashes in header names (causes a problem in rabbit-mq)
|
||||
* 2009/03/29 : (JRB) minor change to add logging config file
|
||||
(JRB) minor change to add socket timeout, suggested by Israel
|
||||
* 2009/04/01 : (Gavin) patch to change md5 to hashlib (for 2.6 compatibility)
|
||||
* 2009/04/02 : (Fernando Ciciliati) fix overflow bug when waiting too long to connect to the broker
|
||||
|
||||
"""
|
||||
|
||||
import hashlib
|
||||
import math
|
||||
import random
|
||||
import re
|
||||
import socket
|
||||
import sys
|
||||
import thread
|
||||
import threading
|
||||
import time
|
||||
import types
|
||||
import xml.dom.minidom
|
||||
from cStringIO import StringIO
|
||||
|
||||
#
|
||||
# stomp.py version number
|
||||
#
|
||||
_version = 1.8
|
||||
|
||||
|
||||
def _uuid( *args ):
|
||||
"""
|
||||
uuid courtesy of Carl Free Jr:
|
||||
(http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/213761)
|
||||
"""
|
||||
|
||||
t = long( time.time() * 1000 )
|
||||
r = long( random.random() * 100000000000000000L )
|
||||
|
||||
try:
|
||||
a = socket.gethostbyname( socket.gethostname() )
|
||||
except:
|
||||
# if we can't get a network address, just imagine one
|
||||
a = random.random() * 100000000000000000L
|
||||
data = str(t) + ' ' + str(r) + ' ' + str(a) + ' ' + str(args)
|
||||
md5 = hashlib.md5()
|
||||
md5.update(data)
|
||||
data = md5.hexdigest()
|
||||
return data
|
||||
|
||||
|
||||
class DevNullLogger(object):
|
||||
"""
|
||||
dummy logging class for environments without the logging module
|
||||
"""
|
||||
def log(self, msg):
|
||||
print msg
|
||||
|
||||
def devnull(self, msg):
|
||||
pass
|
||||
|
||||
debug = devnull
|
||||
info = devnull
|
||||
warning = log
|
||||
error = log
|
||||
critical = log
|
||||
exception = log
|
||||
|
||||
def isEnabledFor(self, lvl):
|
||||
return False
|
||||
|
||||
|
||||
#
|
||||
# add logging if available
|
||||
#
|
||||
try:
|
||||
import logging
|
||||
import logging.config
|
||||
logging.config.fileConfig("stomp.log.conf")
|
||||
log = logging.getLogger('root')
|
||||
except:
|
||||
log = DevNullLogger()
|
||||
|
||||
|
||||
class ConnectionClosedException(Exception):
|
||||
"""
|
||||
Raised in the receiver thread when the connection has been closed
|
||||
by the server.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class NotConnectedException(Exception):
|
||||
"""
|
||||
Raised by Connection.__send_frame when there is currently no server
|
||||
connection.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class ConnectionListener(object):
|
||||
"""
|
||||
This class should be used as a base class for objects registered
|
||||
using Connection.add_listener().
|
||||
"""
|
||||
def on_connecting(self, host_and_port):
|
||||
"""
|
||||
Called by the STOMP connection once a TCP/IP connection to the
|
||||
STOMP server has been established or re-established. Note that
|
||||
at this point, no connection has been established on the STOMP
|
||||
protocol level. For this, you need to invoke the "connect"
|
||||
method on the connection.
|
||||
|
||||
\param host_and_port a tuple containing the host name and port
|
||||
number to which the connection has been established.
|
||||
"""
|
||||
pass
|
||||
|
||||
def on_connected(self, headers, body):
|
||||
"""
|
||||
Called by the STOMP connection when a CONNECTED frame is
|
||||
received, that is after a connection has been established or
|
||||
re-established.
|
||||
|
||||
\param headers a dictionary containing all headers sent by the
|
||||
server as key/value pairs.
|
||||
|
||||
\param body the frame's payload. This is usually empty for
|
||||
CONNECTED frames.
|
||||
"""
|
||||
pass
|
||||
|
||||
def on_disconnected(self):
|
||||
"""
|
||||
Called by the STOMP connection when a TCP/IP connection to the
|
||||
STOMP server has been lost. No messages should be sent via
|
||||
the connection until it has been reestablished.
|
||||
"""
|
||||
pass
|
||||
|
||||
def on_message(self, headers, body):
|
||||
"""
|
||||
Called by the STOMP connection when a MESSAGE frame is
|
||||
received.
|
||||
|
||||
\param headers a dictionary containing all headers sent by the
|
||||
server as key/value pairs.
|
||||
|
||||
\param body the frame's payload - the message body.
|
||||
"""
|
||||
pass
|
||||
|
||||
def on_receipt(self, headers, body):
|
||||
"""
|
||||
Called by the STOMP connection when a RECEIPT frame is
|
||||
received, sent by the server if requested by the client using
|
||||
the 'receipt' header.
|
||||
|
||||
\param headers a dictionary containing all headers sent by the
|
||||
server as key/value pairs.
|
||||
|
||||
\param body the frame's payload. This is usually empty for
|
||||
RECEIPT frames.
|
||||
"""
|
||||
pass
|
||||
|
||||
def on_error(self, headers, body):
|
||||
"""
|
||||
Called by the STOMP connection when an ERROR frame is
|
||||
received.
|
||||
|
||||
\param headers a dictionary containing all headers sent by the
|
||||
server as key/value pairs.
|
||||
|
||||
\param body the frame's payload - usually a detailed error
|
||||
description.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
class Connection(object):
|
||||
"""
|
||||
Represents a STOMP client connection.
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
host_and_ports = [ ('localhost', 61613) ],
|
||||
user = None,
|
||||
passcode = None,
|
||||
prefer_localhost = True,
|
||||
try_loopback_connect = True,
|
||||
reconnect_sleep_initial = 0.1,
|
||||
reconnect_sleep_increase = 0.5,
|
||||
reconnect_sleep_jitter = 0.1,
|
||||
reconnect_sleep_max = 60.0):
|
||||
"""
|
||||
Initialize and start this connection.
|
||||
|
||||
\param host_and_ports
|
||||
a list of (host, port) tuples.
|
||||
|
||||
\param prefer_localhost
|
||||
if True and the local host is mentioned in the (host,
|
||||
port) tuples, try to connect to this first
|
||||
|
||||
\param try_loopback_connect
|
||||
if True and the local host is found in the host
|
||||
tuples, try connecting to it using loopback interface
|
||||
(127.0.0.1)
|
||||
|
||||
\param reconnect_sleep_initial
|
||||
|
||||
initial delay in seconds to wait before reattempting
|
||||
to establish a connection if connection to any of the
|
||||
hosts fails.
|
||||
|
||||
\param reconnect_sleep_increase
|
||||
|
||||
factor by which the sleep delay is increased after
|
||||
each connection attempt. For example, 0.5 means
|
||||
to wait 50% longer than before the previous attempt,
|
||||
1.0 means wait twice as long, and 0.0 means keep
|
||||
the delay constant.
|
||||
|
||||
\param reconnect_sleep_max
|
||||
|
||||
maximum delay between connection attempts, regardless
|
||||
of the reconnect_sleep_increase.
|
||||
|
||||
\param reconnect_sleep_jitter
|
||||
|
||||
random additional time to wait (as a percentage of
|
||||
the time determined using the previous parameters)
|
||||
between connection attempts in order to avoid
|
||||
stampeding. For example, a value of 0.1 means to wait
|
||||
an extra 0%-10% (randomly determined) of the delay
|
||||
calculated using the previous three parameters.
|
||||
"""
|
||||
|
||||
sorted_host_and_ports = []
|
||||
sorted_host_and_ports.extend(host_and_ports)
|
||||
|
||||
# If localhost is preferred, make sure all (host, port) tuples
|
||||
# that refer to the local host come first in the list
|
||||
if prefer_localhost:
|
||||
def is_local_host(host):
|
||||
return host in Connection.__localhost_names
|
||||
|
||||
sorted_host_and_ports.sort(lambda x, y: (int(is_local_host(y[0]))
|
||||
- int(is_local_host(x[0]))))
|
||||
|
||||
# If the user wishes to attempt connecting to local ports
|
||||
# using the loopback interface, for each (host, port) tuple
|
||||
# referring to a local host, add an entry with the host name
|
||||
# replaced by 127.0.0.1 if it doesn't exist already
|
||||
loopback_host_and_ports = []
|
||||
if try_loopback_connect:
|
||||
for host_and_port in sorted_host_and_ports:
|
||||
if is_local_host(host_and_port[0]):
|
||||
port = host_and_port[1]
|
||||
if (not ("127.0.0.1", port) in sorted_host_and_ports
|
||||
and not ("localhost", port) in sorted_host_and_ports):
|
||||
loopback_host_and_ports.append(("127.0.0.1", port))
|
||||
|
||||
# Assemble the final, possibly sorted list of (host, port) tuples
|
||||
self.__host_and_ports = []
|
||||
self.__host_and_ports.extend(loopback_host_and_ports)
|
||||
self.__host_and_ports.extend(sorted_host_and_ports)
|
||||
|
||||
self.__recvbuf = ''
|
||||
|
||||
self.__listeners = [ ]
|
||||
|
||||
self.__reconnect_sleep_initial = reconnect_sleep_initial
|
||||
self.__reconnect_sleep_increase = reconnect_sleep_increase
|
||||
self.__reconnect_sleep_jitter = reconnect_sleep_jitter
|
||||
self.__reconnect_sleep_max = reconnect_sleep_max
|
||||
|
||||
self.__connect_headers = {}
|
||||
if user is not None and passcode is not None:
|
||||
self.__connect_headers['login'] = user
|
||||
self.__connect_headers['passcode'] = passcode
|
||||
|
||||
self.__socket = None
|
||||
self.__current_host_and_port = None
|
||||
|
||||
self.__receiver_thread_exit_condition = threading.Condition()
|
||||
self.__receiver_thread_exited = False
|
||||
|
||||
#
|
||||
# Manage the connection
|
||||
#
|
||||
|
||||
def start(self):
|
||||
"""
|
||||
Start the connection. This should be called after all
|
||||
listeners have been registered. If this method is not called,
|
||||
no frames will be received by the connection.
|
||||
"""
|
||||
self.__running = True
|
||||
self.__attempt_connection()
|
||||
thread.start_new_thread(self.__receiver_loop, ())
|
||||
|
||||
def stop(self):
|
||||
"""
|
||||
Stop the connection. This is equivalent to calling
|
||||
disconnect() but will do a clean shutdown by waiting for the
|
||||
receiver thread to exit.
|
||||
"""
|
||||
self.disconnect()
|
||||
|
||||
self.__receiver_thread_exit_condition.acquire()
|
||||
if not self.__receiver_thread_exited:
|
||||
self.__receiver_thread_exit_condition.wait()
|
||||
self.__receiver_thread_exit_condition.release()
|
||||
|
||||
def get_host_and_port(self):
|
||||
"""
|
||||
Return a (host, port) tuple indicating which STOMP host and
|
||||
port is currently connected, or None if there is currently no
|
||||
connection.
|
||||
"""
|
||||
return self.__current_host_and_port
|
||||
|
||||
def is_connected(self):
|
||||
try:
|
||||
return self.__socket is not None and self.__socket.getsockname()[1] != 0
|
||||
except socket.error:
|
||||
return False
|
||||
|
||||
#
|
||||
# Manage objects listening to incoming frames
|
||||
#
|
||||
|
||||
def add_listener(self, listener):
|
||||
self.__listeners.append(listener)
|
||||
|
||||
def remove_listener(self, listener):
|
||||
self.__listeners.remove(listener)
|
||||
|
||||
#
|
||||
# STOMP transmissions
|
||||
#
|
||||
|
||||
def subscribe(self, headers={}, **keyword_headers):
|
||||
self.__send_frame_helper('SUBSCRIBE', '', self.__merge_headers([headers, keyword_headers]), [ 'destination' ])
|
||||
|
||||
def unsubscribe(self, headers={}, **keyword_headers):
|
||||
self.__send_frame_helper('UNSUBSCRIBE', '', self.__merge_headers([headers, keyword_headers]), [ ('destination', 'id') ])
|
||||
|
||||
def send(self, message='', headers={}, **keyword_headers):
|
||||
if '\x00' in message:
|
||||
content_length_headers = {'content-length': len(message)}
|
||||
else:
|
||||
content_length_headers = {}
|
||||
self.__send_frame_helper('SEND', message, self.__merge_headers([headers,
|
||||
keyword_headers,
|
||||
content_length_headers]), [ 'destination' ])
|
||||
|
||||
def ack(self, headers={}, **keyword_headers):
|
||||
self.__send_frame_helper('ACK', '', self.__merge_headers([headers, keyword_headers]), [ 'message-id' ])
|
||||
|
||||
def begin(self, headers={}, **keyword_headers):
|
||||
use_headers = self.__merge_headers([headers, keyword_headers])
|
||||
if not 'transaction' in use_headers.keys():
|
||||
use_headers['transaction'] = _uuid()
|
||||
self.__send_frame_helper('BEGIN', '', use_headers, [ 'transaction' ])
|
||||
return use_headers['transaction']
|
||||
|
||||
def abort(self, headers={}, **keyword_headers):
|
||||
self.__send_frame_helper('ABORT', '', self.__merge_headers([headers, keyword_headers]), [ 'transaction' ])
|
||||
|
||||
def commit(self, headers={}, **keyword_headers):
|
||||
self.__send_frame_helper('COMMIT', '', self.__merge_headers([headers, keyword_headers]), [ 'transaction' ])
|
||||
|
||||
def connect(self, headers={}, **keyword_headers):
|
||||
if keyword_headers.has_key('wait') and keyword_headers['wait']:
|
||||
while not self.is_connected(): time.sleep(0.1)
|
||||
del keyword_headers['wait']
|
||||
self.__send_frame_helper('CONNECT', '', self.__merge_headers([self.__connect_headers, headers, keyword_headers]), [ ])
|
||||
|
||||
def disconnect(self, headers={}, **keyword_headers):
|
||||
self.__send_frame_helper('DISCONNECT', '', self.__merge_headers([self.__connect_headers, headers, keyword_headers]), [ ])
|
||||
self.__running = False
|
||||
if hasattr(socket, 'SHUT_RDWR'):
|
||||
self.__socket.shutdown(socket.SHUT_RDWR)
|
||||
if self.__socket:
|
||||
self.__socket.close()
|
||||
self.__current_host_and_port = None
|
||||
|
||||
# ========= PRIVATE MEMBERS =========
|
||||
|
||||
|
||||
# List of all host names (unqualified, fully-qualified, and IP
|
||||
# addresses) that refer to the local host (both loopback interface
|
||||
# and external interfaces). This is used for determining
|
||||
# preferred targets.
|
||||
__localhost_names = [ "localhost",
|
||||
"127.0.0.1",
|
||||
socket.gethostbyname(socket.gethostname()),
|
||||
socket.gethostname(),
|
||||
socket.getfqdn(socket.gethostname()) ]
|
||||
#
|
||||
# Used to parse STOMP header lines in the format "key:value",
|
||||
#
|
||||
__header_line_re = re.compile('(?P<key>[^:]+)[:](?P<value>.*)')
|
||||
|
||||
#
|
||||
# Used to parse the STOMP "content-length" header lines,
|
||||
#
|
||||
__content_length_re = re.compile('^content-length[:]\\s*(?P<value>[0-9]+)', re.MULTILINE)
|
||||
|
||||
def __merge_headers(self, header_map_list):
|
||||
"""
|
||||
Helper function for combining multiple header maps into one.
|
||||
|
||||
Any underscores ('_') in header names (keys) will be replaced by dashes ('-').
|
||||
"""
|
||||
headers = {}
|
||||
for header_map in header_map_list:
|
||||
for header_key in header_map.keys():
|
||||
headers[header_key] = header_map[header_key]
|
||||
return headers
|
||||
|
||||
def __convert_dict(self, payload):
|
||||
"""
|
||||
Encode python dictionary as <map>...</map> structure.
|
||||
"""
|
||||
|
||||
xmlStr = "<map>\n"
|
||||
for key in payload:
|
||||
xmlStr += "<entry>\n"
|
||||
xmlStr += "<string>%s</string>" % key
|
||||
xmlStr += "<string>%s</string>" % payload[key]
|
||||
xmlStr += "</entry>\n"
|
||||
xmlStr += "</map>"
|
||||
|
||||
return xmlStr
|
||||
|
||||
def __send_frame_helper(self, command, payload, headers, required_header_keys):
|
||||
"""
|
||||
Helper function for sending a frame after verifying that a
|
||||
given set of headers are present.
|
||||
|
||||
\param command the command to send
|
||||
|
||||
\param payload the frame's payload
|
||||
|
||||
\param headers a dictionary containing the frame's headers
|
||||
|
||||
\param required_header_keys a sequence enumerating all
|
||||
required header keys. If an element in this sequence is itself
|
||||
a tuple, that tuple is taken as a list of alternatives, one of
|
||||
which must be present.
|
||||
|
||||
\throws ArgumentError if one of the required header keys is
|
||||
not present in the header map.
|
||||
"""
|
||||
for required_header_key in required_header_keys:
|
||||
if type(required_header_key) == tuple:
|
||||
found_alternative = False
|
||||
for alternative in required_header_key:
|
||||
if alternative in headers.keys():
|
||||
found_alternative = True
|
||||
if not found_alternative:
|
||||
raise KeyError("Command %s requires one of the following headers: %s" % (command, str(required_header_key)))
|
||||
elif not required_header_key in headers.keys():
|
||||
raise KeyError("Command %s requires header %r" % (command, required_header_key))
|
||||
self.__send_frame(command, headers, payload)
|
||||
|
||||
def __send_frame(self, command, headers={}, payload=''):
|
||||
"""
|
||||
Send a STOMP frame.
|
||||
"""
|
||||
if type(payload) == dict:
|
||||
headers["transformation"] = "jms-map-xml"
|
||||
payload = self.__convert_dict(payload)
|
||||
|
||||
if self.__socket is not None:
|
||||
frame = '%s\n%s\n%s\x00' % (command,
|
||||
reduce(lambda accu, key: accu + ('%s:%s\n' % (key, headers[key])), headers.keys(), ''),
|
||||
payload)
|
||||
self.__socket.sendall(frame)
|
||||
log.debug("Sent frame: type=%s, headers=%r, body=%r" % (command, headers, payload))
|
||||
else:
|
||||
raise NotConnectedException()
|
||||
|
||||
def __receiver_loop(self):
|
||||
"""
|
||||
Main loop listening for incoming data.
|
||||
"""
|
||||
try:
|
||||
try:
|
||||
threading.currentThread().setName("StompReceiver")
|
||||
while self.__running:
|
||||
log.debug('starting receiver loop')
|
||||
|
||||
if self.__socket is None:
|
||||
break
|
||||
|
||||
try:
|
||||
try:
|
||||
for listener in self.__listeners:
|
||||
if hasattr(listener, 'on_connecting'):
|
||||
listener.on_connecting(self.__current_host_and_port)
|
||||
|
||||
while self.__running:
|
||||
frames = self.__read()
|
||||
|
||||
for frame in frames:
|
||||
(frame_type, headers, body) = self.__parse_frame(frame)
|
||||
log.debug("Received frame: result=%r, headers=%r, body=%r" % (frame_type, headers, body))
|
||||
frame_type = frame_type.lower()
|
||||
if frame_type in [ 'connected',
|
||||
'message',
|
||||
'receipt',
|
||||
'error' ]:
|
||||
for listener in self.__listeners:
|
||||
if hasattr(listener, 'on_%s' % frame_type):
|
||||
eval('listener.on_%s(headers, body)' % frame_type)
|
||||
else:
|
||||
log.debug('listener %s has no such method on_%s' % (listener, frame_type))
|
||||
else:
|
||||
log.warning('Unknown response frame type: "%s" (frame length was %d)' % (frame_type, len(frame)))
|
||||
finally:
|
||||
try:
|
||||
self.__socket.close()
|
||||
except:
|
||||
pass # ignore errors when attempting to close socket
|
||||
self.__socket = None
|
||||
self.__current_host_and_port = None
|
||||
except ConnectionClosedException:
|
||||
if self.__running:
|
||||
log.error("Lost connection")
|
||||
# Notify listeners
|
||||
for listener in self.__listeners:
|
||||
if hasattr(listener, 'on_disconnected'):
|
||||
listener.on_disconnected()
|
||||
# Clear out any half-received messages after losing connection
|
||||
self.__recvbuf = ''
|
||||
continue
|
||||
else:
|
||||
break
|
||||
except:
|
||||
log.exception("An unhandled exception was encountered in the stomp receiver loop")
|
||||
|
||||
finally:
|
||||
self.__receiver_thread_exit_condition.acquire()
|
||||
self.__receiver_thread_exited = True
|
||||
self.__receiver_thread_exit_condition.notifyAll()
|
||||
self.__receiver_thread_exit_condition.release()
|
||||
|
||||
def __read(self):
|
||||
"""
|
||||
Read the next frame(s) from the socket.
|
||||
"""
|
||||
fastbuf = StringIO()
|
||||
while self.__running:
|
||||
try:
|
||||
c = self.__socket.recv(1024)
|
||||
except:
|
||||
c = ''
|
||||
if len(c) == 0:
|
||||
raise ConnectionClosedException
|
||||
fastbuf.write(c)
|
||||
if '\x00' in c:
|
||||
break
|
||||
self.__recvbuf += fastbuf.getvalue()
|
||||
fastbuf.close()
|
||||
result = []
|
||||
|
||||
if len(self.__recvbuf) > 0 and self.__running:
|
||||
while True:
|
||||
pos = self.__recvbuf.find('\x00')
|
||||
if pos >= 0:
|
||||
frame = self.__recvbuf[0:pos]
|
||||
preamble_end = frame.find('\n\n')
|
||||
if preamble_end >= 0:
|
||||
content_length_match = Connection.__content_length_re.search(frame[0:preamble_end])
|
||||
if content_length_match:
|
||||
content_length = int(content_length_match.group('value'))
|
||||
content_offset = preamble_end + 2
|
||||
frame_size = content_offset + content_length
|
||||
if frame_size > len(frame):
|
||||
# Frame contains NUL bytes, need to
|
||||
# read more
|
||||
if frame_size < len(self.__recvbuf):
|
||||
pos = frame_size
|
||||
frame = self.__recvbuf[0:pos]
|
||||
else:
|
||||
# Haven't read enough data yet,
|
||||
# exit loop and wait for more to
|
||||
# arrive
|
||||
break
|
||||
result.append(frame)
|
||||
self.__recvbuf = self.__recvbuf[pos+1:]
|
||||
else:
|
||||
break
|
||||
return result
|
||||
|
||||
|
||||
def __transform(self, body, transType):
|
||||
"""
|
||||
Perform body transformation. Currently, the only supported transformation is
|
||||
'jms-map-xml', which converts a map into python dictionary. This can be extended
|
||||
to support other transformation types.
|
||||
|
||||
The body has the following format:
|
||||
<map>
|
||||
<entry>
|
||||
<string>name</string>
|
||||
<string>Dejan</string>
|
||||
</entry>
|
||||
<entry>
|
||||
<string>city</string>
|
||||
<string>Belgrade</string>
|
||||
</entry>
|
||||
</map>
|
||||
|
||||
(see http://docs.codehaus.org/display/STOMP/Stomp+v1.1+Ideas)
|
||||
"""
|
||||
|
||||
if transType != 'jms-map-xml':
|
||||
return body
|
||||
|
||||
try:
|
||||
entries = {}
|
||||
doc = xml.dom.minidom.parseString(body)
|
||||
rootElem = doc.documentElement
|
||||
for entryElem in rootElem.getElementsByTagName("entry"):
|
||||
pair = []
|
||||
for node in entryElem.childNodes:
|
||||
if not isinstance(node, xml.dom.minidom.Element): continue
|
||||
pair.append(node.firstChild.nodeValue)
|
||||
assert len(pair) == 2
|
||||
entries[pair[0]] = pair[1]
|
||||
return entries
|
||||
except Exception, ex:
|
||||
# unable to parse message. return original
|
||||
return body
|
||||
|
||||
|
||||
def __parse_frame(self, frame):
|
||||
"""
|
||||
Parse a STOMP frame into a (frame_type, headers, body) tuple,
|
||||
where frame_type is the frame type as a string (e.g. MESSAGE),
|
||||
headers is a map containing all header key/value pairs, and
|
||||
body is a string containing the frame's payload.
|
||||
"""
|
||||
preamble_end = frame.find('\n\n')
|
||||
preamble = frame[0:preamble_end]
|
||||
preamble_lines = preamble.split('\n')
|
||||
body = frame[preamble_end+2:]
|
||||
|
||||
# Skip any leading newlines
|
||||
first_line = 0
|
||||
while first_line < len(preamble_lines) and len(preamble_lines[first_line]) == 0:
|
||||
first_line += 1
|
||||
|
||||
# Extract frame type
|
||||
frame_type = preamble_lines[first_line]
|
||||
|
||||
# Put headers into a key/value map
|
||||
headers = {}
|
||||
for header_line in preamble_lines[first_line+1:]:
|
||||
header_match = Connection.__header_line_re.match(header_line)
|
||||
if header_match:
|
||||
headers[header_match.group('key')] = header_match.group('value')
|
||||
|
||||
if 'transformation' in headers:
|
||||
body = self.__transform(body, headers['transformation'])
|
||||
|
||||
return (frame_type, headers, body)
|
||||
|
||||
def __attempt_connection(self):
|
||||
"""
|
||||
Try connecting to the (host, port) tuples specified at construction time.
|
||||
"""
|
||||
|
||||
sleep_exp = 1
|
||||
while self.__running and self.__socket is None:
|
||||
for host_and_port in self.__host_and_ports:
|
||||
try:
|
||||
log.debug("Attempting connection to host %s, port %s" % host_and_port)
|
||||
self.__socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.__socket.settimeout(None)
|
||||
self.__socket.connect(host_and_port)
|
||||
self.__current_host_and_port = host_and_port
|
||||
log.info("Established connection to host %s, port %s" % host_and_port)
|
||||
break
|
||||
except socket.error:
|
||||
self.__socket = None
|
||||
if type(sys.exc_info()[1]) == types.TupleType:
|
||||
exc = sys.exc_info()[1][1]
|
||||
else:
|
||||
exc = sys.exc_info()[1]
|
||||
log.warning("Could not connect to host %s, port %s: %s" % (host_and_port[0], host_and_port[1], exc))
|
||||
|
||||
if self.__socket is None:
|
||||
sleep_duration = (min(self.__reconnect_sleep_max,
|
||||
((self.__reconnect_sleep_initial / (1.0 + self.__reconnect_sleep_increase))
|
||||
* math.pow(1.0 + self.__reconnect_sleep_increase, sleep_exp)))
|
||||
* (1.0 + random.random() * self.__reconnect_sleep_jitter))
|
||||
sleep_end = time.time() + sleep_duration
|
||||
log.debug("Sleeping for %.1f seconds before attempting reconnect" % sleep_duration)
|
||||
while self.__running and time.time() < sleep_end:
|
||||
time.sleep(0.2)
|
||||
|
||||
if sleep_duration < self.__reconnect_sleep_max:
|
||||
sleep_exp += 1
|
||||
|
||||
#
|
||||
# command line testing
|
||||
#
|
||||
if __name__ == '__main__':
|
||||
|
||||
# If the readline module is available, make command input easier
|
||||
try:
|
||||
import readline
|
||||
def stomp_completer(text, state):
|
||||
commands = [ 'subscribe', 'unsubscribe',
|
||||
'send', 'ack',
|
||||
'begin', 'abort', 'commit',
|
||||
'connect', 'disconnect'
|
||||
]
|
||||
for command in commands[state:]:
|
||||
if command.startswith(text):
|
||||
return "%s " % command
|
||||
return None
|
||||
|
||||
readline.parse_and_bind("tab: complete")
|
||||
readline.set_completer(stomp_completer)
|
||||
readline.set_completer_delims("")
|
||||
except ImportError:
|
||||
pass # ignore unavailable readline module
|
||||
|
||||
class StompTester(object):
|
||||
def __init__(self, host='localhost', port=61613, user='', passcode=''):
|
||||
self.c = Connection([(host, port)], user, passcode)
|
||||
self.c.add_listener(self)
|
||||
self.c.start()
|
||||
|
||||
def __print_async(self, frame_type, headers, body):
|
||||
print "\r \r",
|
||||
print frame_type
|
||||
for header_key in headers.keys():
|
||||
print '%s: %s' % (header_key, headers[header_key])
|
||||
print
|
||||
print body
|
||||
print '> ',
|
||||
sys.stdout.flush()
|
||||
|
||||
def on_connecting(self, host_and_port):
|
||||
self.c.connect(wait=True)
|
||||
|
||||
def on_disconnected(self):
|
||||
print "lost connection"
|
||||
|
||||
def on_message(self, headers, body):
|
||||
self.__print_async("MESSAGE", headers, body)
|
||||
|
||||
def on_error(self, headers, body):
|
||||
self.__print_async("ERROR", headers, body)
|
||||
|
||||
def on_receipt(self, headers, body):
|
||||
self.__print_async("RECEIPT", headers, body)
|
||||
|
||||
def on_connected(self, headers, body):
|
||||
self.__print_async("CONNECTED", headers, body)
|
||||
|
||||
def ack(self, args):
|
||||
if len(args) < 3:
|
||||
self.c.ack(message_id=args[1])
|
||||
else:
|
||||
self.c.ack(message_id=args[1], transaction=args[2])
|
||||
|
||||
def abort(self, args):
|
||||
self.c.abort(transaction=args[1])
|
||||
|
||||
def begin(self, args):
|
||||
print 'transaction id: %s' % self.c.begin()
|
||||
|
||||
def commit(self, args):
|
||||
if len(args) < 2:
|
||||
print 'expecting: commit <transid>'
|
||||
else:
|
||||
print 'committing %s' % args[1]
|
||||
self.c.commit(transaction=args[1])
|
||||
|
||||
def disconnect(self, args):
|
||||
try:
|
||||
self.c.disconnect()
|
||||
except NotConnectedException:
|
||||
pass # ignore if no longer connected
|
||||
|
||||
def send(self, args):
|
||||
if len(args) < 3:
|
||||
print 'expecting: send <destination> <message>'
|
||||
else:
|
||||
self.c.send(destination=args[1], message=' '.join(args[2:]))
|
||||
|
||||
def sendtrans(self, args):
|
||||
if len(args) < 3:
|
||||
print 'expecting: sendtrans <destination> <transid> <message>'
|
||||
else:
|
||||
self.c.send(destination=args[1], message="%s\n" % ' '.join(args[3:]), transaction=args[2])
|
||||
|
||||
def subscribe(self, args):
|
||||
if len(args) < 2:
|
||||
print 'expecting: subscribe <destination> [ack]'
|
||||
elif len(args) > 2:
|
||||
print 'subscribing to "%s" with acknowledge set to "%s"' % (args[1], args[2])
|
||||
self.c.subscribe(destination=args[1], ack=args[2])
|
||||
else:
|
||||
print 'subscribing to "%s" with auto acknowledge' % args[1]
|
||||
self.c.subscribe(destination=args[1], ack='auto')
|
||||
|
||||
def unsubscribe(self, args):
|
||||
if len(args) < 2:
|
||||
print 'expecting: unsubscribe <destination>'
|
||||
else:
|
||||
print 'unsubscribing from "%s"' % args[1]
|
||||
self.c.unsubscribe(destination=args[1])
|
||||
|
||||
if len(sys.argv) > 5:
|
||||
print 'USAGE: stomp.py [host] [port] [user] [passcode]'
|
||||
sys.exit(1)
|
||||
|
||||
if len(sys.argv) >= 2:
|
||||
host = sys.argv[1]
|
||||
else:
|
||||
host = "localhost"
|
||||
if len(sys.argv) >= 3:
|
||||
port = int(sys.argv[2])
|
||||
else:
|
||||
port = 61613
|
||||
|
||||
if len(sys.argv) >= 5:
|
||||
user = sys.argv[3]
|
||||
passcode = sys.argv[4]
|
||||
else:
|
||||
user = None
|
||||
passcode = None
|
||||
|
||||
st = StompTester(host, port, user, passcode)
|
||||
try:
|
||||
while True:
|
||||
line = raw_input("\r> ")
|
||||
if not line or line.lstrip().rstrip() == '':
|
||||
continue
|
||||
elif 'quit' in line or 'disconnect' in line:
|
||||
break
|
||||
split = line.split()
|
||||
command = split[0]
|
||||
if not command.startswith("on_") and hasattr(st, command):
|
||||
getattr(st, command)(split)
|
||||
else:
|
||||
print 'unrecognized command'
|
||||
finally:
|
||||
st.disconnect(None)
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ class ListenThread(threading.Thread):
|
|||
self.qs.topicSubscribe(self.topicName, self.receivedMessage)
|
||||
|
||||
def receivedMessage(self, msg):
|
||||
print "Received message"
|
||||
print("Received message")
|
||||
self.nMessagesReceived += 1
|
||||
if self.waitSecond == 0:
|
||||
fmsg = open('/tmp/rawMessage', 'w')
|
||||
|
@ -66,20 +66,20 @@ class ListenThread(threading.Thread):
|
|||
|
||||
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"
|
||||
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"
|
||||
print(time.strftime('%H:%M:%S'), "Received", self.nMessagesReceived, "messages")
|
||||
|
||||
def stop(self):
|
||||
print "Stopping"
|
||||
print("Stopping")
|
||||
self.stopped = True
|
||||
self.qs.close()
|
||||
|
||||
|
||||
def main():
|
||||
print "Starting up at", time.strftime('%H:%M:%S')
|
||||
print("Starting up at", time.strftime('%H:%M:%S'))
|
||||
|
||||
topic = 'edex.alerts'
|
||||
host = 'localhost'
|
||||
|
|
99
awips/test/testQpidTimeToLive.py.bak
Normal file
99
awips/test/testQpidTimeToLive.py.bak
Normal file
|
@ -0,0 +1,99 @@
|
|||
##
|
||||
# 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
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 03/09/11 njensen Initial Creation.
|
||||
# 08/15/13 2169 bkowal Decompress data read from the queue
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
import time, sys
|
||||
import threading
|
||||
|
||||
import dynamicserialize
|
||||
|
||||
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(self.hostname, self.portNumber, True)
|
||||
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()
|
|
@ -56,16 +56,16 @@ source_suffix = '.rst'
|
|||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'python-awips'
|
||||
copyright = u'2016, Unidata'
|
||||
author = u'Unidata'
|
||||
project = 'python-awips'
|
||||
copyright = '2016, Unidata'
|
||||
author = 'Unidata'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = u'0.9.3'
|
||||
version = '0.9.3'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
|
@ -231,8 +231,8 @@ latex_elements = {
|
|||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'python-awips.tex', u'python-awips Documentation',
|
||||
u'Unidata', 'manual'),
|
||||
(master_doc, 'python-awips.tex', 'python-awips Documentation',
|
||||
'Unidata', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
@ -261,7 +261,7 @@ latex_documents = [
|
|||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'python-awips', u'python-awips Documentation',
|
||||
(master_doc, 'python-awips', 'python-awips Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
|
@ -275,7 +275,7 @@ man_pages = [
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'python-awips', u'python-awips Documentation',
|
||||
(master_doc, 'python-awips', 'python-awips Documentation',
|
||||
author, 'python-awips', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
|
303
docs/source/conf.py.bak
Normal file
303
docs/source/conf.py.bak
Normal file
|
@ -0,0 +1,303 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# python-awips documentation build configuration file, created by
|
||||
# sphinx-quickstart on Tue Mar 15 15:59:23 2016.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its
|
||||
# containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
sys.path.insert(0, os.path.abspath('.'))
|
||||
sys.path.insert(0, os.path.abspath('../..'))
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.intersphinx',
|
||||
'sphinx.ext.viewcode'
|
||||
# 'notebook_gen_sphinxext'
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'python-awips'
|
||||
copyright = u'2016, Unidata'
|
||||
author = u'Unidata'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = u'0.9.3'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#
|
||||
# This is also used if you do content translation via gettext catalogs.
|
||||
# Usually you set "language" from the command line for these cases.
|
||||
language = None
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = []
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all
|
||||
# documents.
|
||||
#default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
|
||||
# If true, keep warnings as "system message" paragraphs in the built documents.
|
||||
#keep_warnings = False
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = False
|
||||
|
||||
|
||||
# -- Options for HTML output ----------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#html_theme = 'alabaster'
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
|
||||
# The name of an image file (relative to this directory) to use as a favicon of
|
||||
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
# Add any extra paths that contain custom files (such as robots.txt or
|
||||
# .htaccess) here, relative to this directory. These files are copied
|
||||
# directly to the root of the documentation.
|
||||
#html_extra_path = []
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
|
||||
# Language to be used for generating the HTML full-text search index.
|
||||
# Sphinx supports the following languages:
|
||||
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
|
||||
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
|
||||
#html_search_language = 'en'
|
||||
|
||||
# A dictionary with options for the search language support, empty by default.
|
||||
# Now only 'ja' uses this config value
|
||||
#html_search_options = {'type': 'default'}
|
||||
|
||||
# The name of a javascript file (relative to the configuration directory) that
|
||||
# implements a search results scorer. If empty, the default will be used.
|
||||
#html_search_scorer = 'scorer.js'
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'python-awipsdoc'
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
#'figure_align': 'htbp',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'python-awips.tex', u'python-awips Documentation',
|
||||
u'Unidata', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'python-awips', u'python-awips Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'python-awips', u'python-awips Documentation',
|
||||
author, 'python-awips', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
|
||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||
#texinfo_no_detailmenu = False
|
||||
|
||||
# Set up mapping for other projects' docs
|
||||
intersphinx_mapping = {
|
||||
'matplotlib': ('http://matplotlib.org/', None),
|
||||
'metpy': ('http://docs.scipy.org/doc/metpy/', None),
|
||||
'numpy': ('http://docs.scipy.org/doc/numpy/', None),
|
||||
'scipy': ('http://docs.scipy.org/doc/scipy/reference/', None),
|
||||
'pint': ('http://pint.readthedocs.org/en/stable/', None),
|
||||
'python': ('http://docs.python.org', None)
|
||||
}
|
|
@ -36,7 +36,7 @@
|
|||
#
|
||||
|
||||
from thrift.transport import TTransport
|
||||
import SelfDescribingBinaryProtocol, ThriftSerializationContext
|
||||
from . import SelfDescribingBinaryProtocol, ThriftSerializationContext
|
||||
|
||||
class DynamicSerializationManager:
|
||||
|
||||
|
|
69
dynamicserialize/DynamicSerializationManager.py.bak
Normal file
69
dynamicserialize/DynamicSerializationManager.py.bak
Normal file
|
@ -0,0 +1,69 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
|
||||
#
|
||||
# A port of the Java DynamicSerializeManager. Should be used to read/write
|
||||
# DynamicSerialize binary data.
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 06/09/10 njensen Initial Creation.
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
from thrift.transport import TTransport
|
||||
import SelfDescribingBinaryProtocol, ThriftSerializationContext
|
||||
|
||||
class DynamicSerializationManager:
|
||||
|
||||
def __init__(self):
|
||||
self.transport = None
|
||||
|
||||
def _deserialize(self, ctx):
|
||||
return ctx.deserializeMessage()
|
||||
|
||||
def deserializeBytes(self, bytes):
|
||||
ctx = self._buildSerializationContext(bytes)
|
||||
ctx.readMessageStart()
|
||||
obj = self._deserialize(ctx)
|
||||
ctx.readMessageEnd()
|
||||
return obj
|
||||
|
||||
def _buildSerializationContext(self, bytes=None):
|
||||
self.transport = TTransport.TMemoryBuffer(bytes)
|
||||
protocol = SelfDescribingBinaryProtocol.SelfDescribingBinaryProtocol(self.transport)
|
||||
return ThriftSerializationContext.ThriftSerializationContext(self, protocol)
|
||||
|
||||
def serializeObject(self, obj):
|
||||
ctx = self._buildSerializationContext()
|
||||
ctx.writeMessageStart("dynamicSerialize")
|
||||
self._serialize(ctx, obj)
|
||||
ctx.writeMessageEnd()
|
||||
return self.transport.getvalue()
|
||||
|
||||
def _serialize(self, ctx, obj):
|
||||
ctx.serializeMessage(obj)
|
|
@ -44,13 +44,14 @@ from thrift.Thrift import TType
|
|||
import inspect, sys, types
|
||||
import dynamicserialize
|
||||
from dynamicserialize import dstypes, adapters
|
||||
import SelfDescribingBinaryProtocol
|
||||
from . import SelfDescribingBinaryProtocol
|
||||
import numpy
|
||||
import collections
|
||||
|
||||
dsObjTypes = {}
|
||||
|
||||
def buildObjMap(module):
|
||||
if module.__dict__.has_key('__all__'):
|
||||
if '__all__' in module.__dict__:
|
||||
for i in module.__all__:
|
||||
name = module.__name__ + '.' + i
|
||||
__import__(name)
|
||||
|
@ -65,17 +66,17 @@ def buildObjMap(module):
|
|||
buildObjMap(dstypes)
|
||||
|
||||
pythonToThriftMap = {
|
||||
types.StringType: TType.STRING,
|
||||
types.IntType: TType.I32,
|
||||
types.LongType: TType.I64,
|
||||
types.ListType: TType.LIST,
|
||||
types.DictionaryType: TType.MAP,
|
||||
bytes: TType.STRING,
|
||||
int: TType.I32,
|
||||
int: TType.I64,
|
||||
list: TType.LIST,
|
||||
dict: TType.MAP,
|
||||
type(set([])): TType.SET,
|
||||
types.FloatType: SelfDescribingBinaryProtocol.FLOAT,
|
||||
float: SelfDescribingBinaryProtocol.FLOAT,
|
||||
#types.FloatType: TType.DOUBLE,
|
||||
types.BooleanType: TType.BOOL,
|
||||
bool: TType.BOOL,
|
||||
types.InstanceType: TType.STRUCT,
|
||||
types.NoneType: TType.VOID,
|
||||
type(None): TType.VOID,
|
||||
numpy.float32: SelfDescribingBinaryProtocol.FLOAT,
|
||||
numpy.int32: TType.I32,
|
||||
numpy.ndarray: TType.LIST,
|
||||
|
@ -155,7 +156,7 @@ class ThriftSerializationContext(object):
|
|||
if name.isdigit():
|
||||
obj = self._deserializeType(int(name))
|
||||
return obj
|
||||
elif adapters.classAdapterRegistry.has_key(name):
|
||||
elif name in adapters.classAdapterRegistry:
|
||||
return adapters.classAdapterRegistry[name].deserialize(self)
|
||||
elif name.find('$') > -1:
|
||||
# it's an inner class, we're going to hope it's an enum, treat it special
|
||||
|
@ -176,7 +177,7 @@ class ThriftSerializationContext(object):
|
|||
return obj
|
||||
|
||||
def _deserializeType(self, b):
|
||||
if self.typeDeserializationMethod.has_key(b):
|
||||
if b in self.typeDeserializationMethod:
|
||||
return self.typeDeserializationMethod[b]()
|
||||
else:
|
||||
raise dynamicserialize.SerializationException("Unsupported type value " + str(b))
|
||||
|
@ -196,7 +197,7 @@ class ThriftSerializationContext(object):
|
|||
try:
|
||||
setMethod = getattr(obj, lookingFor)
|
||||
|
||||
if callable(setMethod):
|
||||
if isinstance(setMethod, collections.Callable):
|
||||
setMethod(result)
|
||||
else:
|
||||
raise dynamicserialize.SerializationException("Couldn't find setter method " + lookingFor)
|
||||
|
@ -213,7 +214,7 @@ class ThriftSerializationContext(object):
|
|||
if size:
|
||||
if listType not in primitiveSupport:
|
||||
m = self.typeDeserializationMethod[listType]
|
||||
result = [m() for n in xrange(size)]
|
||||
result = [m() for n in range(size)]
|
||||
else:
|
||||
result = self.listDeserializationMethod[listType](size)
|
||||
self.protocol.readListEnd()
|
||||
|
@ -222,7 +223,7 @@ class ThriftSerializationContext(object):
|
|||
def _deserializeMap(self):
|
||||
keyType, valueType, size = self.protocol.readMapBegin()
|
||||
result = {}
|
||||
for n in xrange(size):
|
||||
for n in range(size):
|
||||
# can't go off the type, due to java generics limitations dynamic serialize is
|
||||
# serializing keys and values as void
|
||||
key = self.typeDeserializationMethod[TType.STRUCT]()
|
||||
|
@ -234,14 +235,14 @@ class ThriftSerializationContext(object):
|
|||
def _deserializeSet(self):
|
||||
setType, setSize = self.protocol.readSetBegin()
|
||||
result = set([])
|
||||
for n in xrange(setSize):
|
||||
for n in range(setSize):
|
||||
result.add(self.typeDeserializationMethod[TType.STRUCT]())
|
||||
self.protocol.readSetEnd()
|
||||
return result
|
||||
|
||||
def _lookupType(self, obj):
|
||||
pyt = type(obj)
|
||||
if pythonToThriftMap.has_key(pyt):
|
||||
if pyt in pythonToThriftMap:
|
||||
return pythonToThriftMap[pyt]
|
||||
elif pyt.__module__.startswith('dynamicserialize.dstypes'):
|
||||
return pythonToThriftMap[types.InstanceType]
|
||||
|
@ -253,7 +254,7 @@ class ThriftSerializationContext(object):
|
|||
|
||||
if tt == TType.STRUCT:
|
||||
fqn = obj.__module__.replace('dynamicserialize.dstypes.', '')
|
||||
if adapters.classAdapterRegistry.has_key(fqn):
|
||||
if fqn in adapters.classAdapterRegistry:
|
||||
# get proper class name when writing class name to serialization stream
|
||||
# in case we have a special inner-class case
|
||||
m = sys.modules[adapters.classAdapterRegistry[fqn].__name__]
|
||||
|
@ -293,7 +294,7 @@ class ThriftSerializationContext(object):
|
|||
self.protocol.writeFieldEnd()
|
||||
|
||||
def _serializeType(self, fieldValue, fieldType):
|
||||
if self.typeSerializationMethod.has_key(fieldType):
|
||||
if fieldType in self.typeSerializationMethod:
|
||||
return self.typeSerializationMethod[fieldType](fieldValue)
|
||||
else:
|
||||
raise dynamicserialize.SerializationException("Unsupported type value " + str(fieldType))
|
||||
|
@ -335,7 +336,7 @@ class ThriftSerializationContext(object):
|
|||
def _serializeMap(self, obj):
|
||||
size = len(obj)
|
||||
self.protocol.writeMapBegin(TType.VOID, TType.VOID, size)
|
||||
for k in obj.keys():
|
||||
for k in list(obj.keys()):
|
||||
self.typeSerializationMethod[TType.STRUCT](k)
|
||||
self.typeSerializationMethod[TType.STRUCT](obj[k])
|
||||
self.protocol.writeMapEnd()
|
||||
|
|
420
dynamicserialize/ThriftSerializationContext.py.bak
Normal file
420
dynamicserialize/ThriftSerializationContext.py.bak
Normal file
|
@ -0,0 +1,420 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
|
||||
#
|
||||
# A port of the Java ThriftSerializationContext, used for reading/writing
|
||||
# DynamicSerialize objects to/from thrift.
|
||||
#
|
||||
# For serialization, it has no knowledge of the expected types in other
|
||||
# languages, it is instead all based on inspecting the types of the objects
|
||||
# passed to it. Therefore, ensure the types of python objects and primitives
|
||||
# match what they should be in the destination language.
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 06/09/10 njensen Initial Creation.
|
||||
# 06/12/13 #2099 dgilling Implement readObject() and
|
||||
# writeObject().
|
||||
# Apr 24, 2015 4425 nabowle Add Double support
|
||||
#
|
||||
#
|
||||
|
||||
from thrift.Thrift import TType
|
||||
import inspect, sys, types
|
||||
import dynamicserialize
|
||||
from dynamicserialize import dstypes, adapters
|
||||
import SelfDescribingBinaryProtocol
|
||||
import numpy
|
||||
|
||||
dsObjTypes = {}
|
||||
|
||||
def buildObjMap(module):
|
||||
if module.__dict__.has_key('__all__'):
|
||||
for i in module.__all__:
|
||||
name = module.__name__ + '.' + i
|
||||
__import__(name)
|
||||
buildObjMap(sys.modules[name])
|
||||
else:
|
||||
clzName = module.__name__[module.__name__.rfind('.') + 1:]
|
||||
clz = module.__dict__[clzName]
|
||||
tname = module.__name__
|
||||
tname = tname.replace('dynamicserialize.dstypes.', '')
|
||||
dsObjTypes[tname] = clz
|
||||
|
||||
buildObjMap(dstypes)
|
||||
|
||||
pythonToThriftMap = {
|
||||
types.StringType: TType.STRING,
|
||||
types.IntType: TType.I32,
|
||||
types.LongType: TType.I64,
|
||||
types.ListType: TType.LIST,
|
||||
types.DictionaryType: TType.MAP,
|
||||
type(set([])): TType.SET,
|
||||
types.FloatType: SelfDescribingBinaryProtocol.FLOAT,
|
||||
#types.FloatType: TType.DOUBLE,
|
||||
types.BooleanType: TType.BOOL,
|
||||
types.InstanceType: TType.STRUCT,
|
||||
types.NoneType: TType.VOID,
|
||||
numpy.float32: SelfDescribingBinaryProtocol.FLOAT,
|
||||
numpy.int32: TType.I32,
|
||||
numpy.ndarray: TType.LIST,
|
||||
numpy.object_: TType.STRING, # making an assumption here
|
||||
numpy.string_: TType.STRING,
|
||||
numpy.float64: TType.DOUBLE,
|
||||
numpy.int16: TType.I16,
|
||||
numpy.int8: TType.BYTE,
|
||||
numpy.int64: TType.I64
|
||||
}
|
||||
|
||||
primitiveSupport = (TType.BYTE, TType.I16, TType.I32, TType.I64, SelfDescribingBinaryProtocol.FLOAT, TType.DOUBLE)
|
||||
|
||||
class ThriftSerializationContext(object):
|
||||
|
||||
def __init__(self, serializationManager, selfDescribingBinaryProtocol):
|
||||
self.serializationManager = serializationManager
|
||||
self.protocol = selfDescribingBinaryProtocol
|
||||
self.typeDeserializationMethod = {
|
||||
TType.STRING: self.protocol.readString,
|
||||
TType.I16: self.protocol.readI16,
|
||||
TType.I32: self.protocol.readI32,
|
||||
TType.LIST: self._deserializeArray,
|
||||
TType.MAP: self._deserializeMap,
|
||||
TType.SET: self._deserializeSet,
|
||||
SelfDescribingBinaryProtocol.FLOAT: self.protocol.readFloat,
|
||||
TType.BYTE: self.protocol.readByte,
|
||||
TType.I64: self.protocol.readI64,
|
||||
TType.DOUBLE: self.protocol.readDouble,
|
||||
TType.BOOL: self.protocol.readBool,
|
||||
TType.STRUCT: self.deserializeMessage,
|
||||
TType.VOID: lambda: None
|
||||
}
|
||||
self.typeSerializationMethod = {
|
||||
TType.STRING: self.protocol.writeString,
|
||||
TType.I16: self.protocol.writeI16,
|
||||
TType.I32: self.protocol.writeI32,
|
||||
TType.LIST: self._serializeArray,
|
||||
TType.MAP: self._serializeMap,
|
||||
TType.SET: self._serializeSet,
|
||||
SelfDescribingBinaryProtocol.FLOAT: self.protocol.writeFloat,
|
||||
TType.BYTE: self.protocol.writeByte,
|
||||
TType.I64: self.protocol.writeI64,
|
||||
TType.DOUBLE: self.protocol.writeDouble,
|
||||
TType.BOOL: self.protocol.writeBool,
|
||||
TType.STRUCT: self.serializeMessage,
|
||||
TType.VOID: lambda x: None
|
||||
}
|
||||
self.listDeserializationMethod = {
|
||||
TType.BYTE: self.protocol.readI8List,
|
||||
TType.I16: self.protocol.readI16List,
|
||||
TType.I32: self.protocol.readI32List,
|
||||
TType.I64: self.protocol.readI64List,
|
||||
SelfDescribingBinaryProtocol.FLOAT: self.protocol.readF32List,
|
||||
TType.DOUBLE: self.protocol.readF64List
|
||||
}
|
||||
self.listSerializationMethod = {
|
||||
TType.BYTE: self.protocol.writeI8List,
|
||||
TType.I16: self.protocol.writeI16List,
|
||||
TType.I32: self.protocol.writeI32List,
|
||||
TType.I64: self.protocol.writeI64List,
|
||||
SelfDescribingBinaryProtocol.FLOAT: self.protocol.writeF32List,
|
||||
TType.DOUBLE: self.protocol.writeF64List
|
||||
}
|
||||
|
||||
|
||||
def readMessageStart(self):
|
||||
msg = self.protocol.readMessageBegin()
|
||||
return msg[0]
|
||||
|
||||
def readMessageEnd(self):
|
||||
self.protocol.readMessageEnd()
|
||||
|
||||
def deserializeMessage(self):
|
||||
name = self.protocol.readStructBegin()
|
||||
name = name.replace('_', '.')
|
||||
if name.isdigit():
|
||||
obj = self._deserializeType(int(name))
|
||||
return obj
|
||||
elif adapters.classAdapterRegistry.has_key(name):
|
||||
return adapters.classAdapterRegistry[name].deserialize(self)
|
||||
elif name.find('$') > -1:
|
||||
# it's an inner class, we're going to hope it's an enum, treat it special
|
||||
fieldName, fieldType, fieldId = self.protocol.readFieldBegin()
|
||||
if fieldName != '__enumValue__':
|
||||
raise dynamiceserialize.SerializationException("Expected to find enum payload. Found: " + fieldName)
|
||||
obj = self.protocol.readString()
|
||||
self.protocol.readFieldEnd()
|
||||
return obj
|
||||
else:
|
||||
clz = dsObjTypes[name]
|
||||
obj = clz()
|
||||
|
||||
while self._deserializeField(name, obj):
|
||||
pass
|
||||
|
||||
self.protocol.readStructEnd()
|
||||
return obj
|
||||
|
||||
def _deserializeType(self, b):
|
||||
if self.typeDeserializationMethod.has_key(b):
|
||||
return self.typeDeserializationMethod[b]()
|
||||
else:
|
||||
raise dynamicserialize.SerializationException("Unsupported type value " + str(b))
|
||||
|
||||
|
||||
def _deserializeField(self, structname, obj):
|
||||
fieldName, fieldType, fieldId = self.protocol.readFieldBegin()
|
||||
if fieldType == TType.STOP:
|
||||
return False
|
||||
elif fieldType != TType.VOID:
|
||||
# if adapters.fieldAdapterRegistry.has_key(structname) and adapters.fieldAdapterRegistry[structname].has_key(fieldName):
|
||||
# result = adapters.fieldAdapterRegistry[structname][fieldName].deserialize(self)
|
||||
# else:
|
||||
result = self._deserializeType(fieldType)
|
||||
lookingFor = "set" + fieldName[0].upper() + fieldName[1:]
|
||||
|
||||
try:
|
||||
setMethod = getattr(obj, lookingFor)
|
||||
|
||||
if callable(setMethod):
|
||||
setMethod(result)
|
||||
else:
|
||||
raise dynamicserialize.SerializationException("Couldn't find setter method " + lookingFor)
|
||||
except:
|
||||
raise dynamicserialize.SerializationException("Couldn't find setter method " + lookingFor)
|
||||
|
||||
self.protocol.readFieldEnd()
|
||||
return True
|
||||
|
||||
|
||||
def _deserializeArray(self):
|
||||
listType, size = self.protocol.readListBegin()
|
||||
result = []
|
||||
if size:
|
||||
if listType not in primitiveSupport:
|
||||
m = self.typeDeserializationMethod[listType]
|
||||
result = [m() for n in xrange(size)]
|
||||
else:
|
||||
result = self.listDeserializationMethod[listType](size)
|
||||
self.protocol.readListEnd()
|
||||
return result
|
||||
|
||||
def _deserializeMap(self):
|
||||
keyType, valueType, size = self.protocol.readMapBegin()
|
||||
result = {}
|
||||
for n in xrange(size):
|
||||
# can't go off the type, due to java generics limitations dynamic serialize is
|
||||
# serializing keys and values as void
|
||||
key = self.typeDeserializationMethod[TType.STRUCT]()
|
||||
value = self.typeDeserializationMethod[TType.STRUCT]()
|
||||
result[key] = value
|
||||
self.protocol.readMapEnd()
|
||||
return result
|
||||
|
||||
def _deserializeSet(self):
|
||||
setType, setSize = self.protocol.readSetBegin()
|
||||
result = set([])
|
||||
for n in xrange(setSize):
|
||||
result.add(self.typeDeserializationMethod[TType.STRUCT]())
|
||||
self.protocol.readSetEnd()
|
||||
return result
|
||||
|
||||
def _lookupType(self, obj):
|
||||
pyt = type(obj)
|
||||
if pythonToThriftMap.has_key(pyt):
|
||||
return pythonToThriftMap[pyt]
|
||||
elif pyt.__module__.startswith('dynamicserialize.dstypes'):
|
||||
return pythonToThriftMap[types.InstanceType]
|
||||
else:
|
||||
raise dynamicserialize.SerializationException("Don't know how to serialize object of type: " + str(pyt))
|
||||
|
||||
def serializeMessage(self, obj):
|
||||
tt = self._lookupType(obj)
|
||||
|
||||
if tt == TType.STRUCT:
|
||||
fqn = obj.__module__.replace('dynamicserialize.dstypes.', '')
|
||||
if adapters.classAdapterRegistry.has_key(fqn):
|
||||
# get proper class name when writing class name to serialization stream
|
||||
# in case we have a special inner-class case
|
||||
m = sys.modules[adapters.classAdapterRegistry[fqn].__name__]
|
||||
if isinstance(m.ClassAdapter, list):
|
||||
fqn = m.ClassAdapter[0]
|
||||
self.protocol.writeStructBegin(fqn)
|
||||
adapters.classAdapterRegistry[fqn].serialize(self, obj)
|
||||
return
|
||||
else:
|
||||
self.protocol.writeStructBegin(fqn)
|
||||
methods = inspect.getmembers(obj, inspect.ismethod)
|
||||
fid = 1
|
||||
for m in methods:
|
||||
methodName = m[0]
|
||||
if methodName.startswith('get'):
|
||||
fieldname = methodName[3].lower() + methodName[4:]
|
||||
val = m[1]()
|
||||
ft = self._lookupType(val)
|
||||
if ft == TType.STRUCT:
|
||||
fc = val.__module__.replace('dynamicserialize.dstypes.', '')
|
||||
self._serializeField(fieldname, ft, fid, val)
|
||||
else:
|
||||
self._serializeField(fieldname, ft, fid, val)
|
||||
fid += 1
|
||||
self.protocol.writeFieldStop()
|
||||
|
||||
self.protocol.writeStructEnd()
|
||||
else:
|
||||
# basic types
|
||||
self.protocol.writeStructBegin(str(tt))
|
||||
self._serializeType(obj, tt)
|
||||
self.protocol.writeStructEnd()
|
||||
|
||||
def _serializeField(self, fieldName, fieldType, fieldId, fieldValue):
|
||||
self.protocol.writeFieldBegin(fieldName, fieldType, fieldId)
|
||||
self._serializeType(fieldValue, fieldType)
|
||||
self.protocol.writeFieldEnd()
|
||||
|
||||
def _serializeType(self, fieldValue, fieldType):
|
||||
if self.typeSerializationMethod.has_key(fieldType):
|
||||
return self.typeSerializationMethod[fieldType](fieldValue)
|
||||
else:
|
||||
raise dynamicserialize.SerializationException("Unsupported type value " + str(fieldType))
|
||||
|
||||
def _serializeArray(self, obj):
|
||||
size = len(obj)
|
||||
if size:
|
||||
if type(obj) is numpy.ndarray:
|
||||
t = pythonToThriftMap[obj.dtype.type]
|
||||
size = obj.size
|
||||
else:
|
||||
t = self._lookupType(obj[0])
|
||||
else:
|
||||
t = TType.STRUCT
|
||||
self.protocol.writeListBegin(t, size)
|
||||
if t == TType.STRING:
|
||||
if type(obj) is numpy.ndarray:
|
||||
if len(obj.shape) == 1:
|
||||
for x in obj:
|
||||
s = str(x).strip()
|
||||
self.typeSerializationMethod[t](s)
|
||||
else:
|
||||
for x in obj:
|
||||
for y in x:
|
||||
s = str(y).strip()
|
||||
self.typeSerializationMethod[t](s)
|
||||
else:
|
||||
for x in obj:
|
||||
s = str(x)
|
||||
self.typeSerializationMethod[t](s)
|
||||
elif t not in primitiveSupport:
|
||||
for x in obj:
|
||||
self.typeSerializationMethod[t](x)
|
||||
else:
|
||||
self.listSerializationMethod[t](obj)
|
||||
self.protocol.writeListEnd()
|
||||
|
||||
|
||||
def _serializeMap(self, obj):
|
||||
size = len(obj)
|
||||
self.protocol.writeMapBegin(TType.VOID, TType.VOID, size)
|
||||
for k in obj.keys():
|
||||
self.typeSerializationMethod[TType.STRUCT](k)
|
||||
self.typeSerializationMethod[TType.STRUCT](obj[k])
|
||||
self.protocol.writeMapEnd()
|
||||
|
||||
def _serializeSet(self, obj):
|
||||
size = len(obj)
|
||||
self.protocol.writeSetBegin(TType.VOID, size)
|
||||
for x in obj:
|
||||
self.typeSerializationMethod[TType.STRUCT](x)
|
||||
self.protocol.writeSetEnd()
|
||||
|
||||
def writeMessageStart(self, name):
|
||||
self.protocol.writeMessageBegin(name, TType.VOID, 0)
|
||||
|
||||
def writeMessageEnd(self):
|
||||
self.protocol.writeMessageEnd()
|
||||
|
||||
def readBool(self):
|
||||
return self.protocol.readBool()
|
||||
|
||||
def writeBool(self, b):
|
||||
self.protocol.writeBool(b)
|
||||
|
||||
def readByte(self):
|
||||
return self.protocol.readByte()
|
||||
|
||||
def writeByte(self, b):
|
||||
self.protocol.writeByte(b)
|
||||
|
||||
def readDouble(self):
|
||||
return self.protocol.readDouble()
|
||||
|
||||
def writeDouble(self, d):
|
||||
self.protocol.writeDouble(d)
|
||||
|
||||
def readFloat(self):
|
||||
return self.protocol.readFloat()
|
||||
|
||||
def writeFloat(self, f):
|
||||
self.protocol.writeFloat(f)
|
||||
|
||||
def readI16(self):
|
||||
return self.protocol.readI16()
|
||||
|
||||
def writeI16(self, i):
|
||||
self.protocol.writeI16(i)
|
||||
|
||||
def readI32(self):
|
||||
return self.protocol.readI32()
|
||||
|
||||
def writeI32(self, i):
|
||||
self.protocol.writeI32(i)
|
||||
|
||||
def readI64(self):
|
||||
return self.protocol.readI64()
|
||||
|
||||
def writeI64(self, i):
|
||||
self.protocol.writeI64(i)
|
||||
|
||||
def readString(self):
|
||||
return self.protocol.readString()
|
||||
|
||||
def writeString(self, s):
|
||||
self.protocol.writeString(s)
|
||||
|
||||
def readBinary(self):
|
||||
numBytes = self.protocol.readI32()
|
||||
return self.protocol.readI8List(numBytes)
|
||||
|
||||
def readFloatArray(self):
|
||||
size = self.protocol.readI32()
|
||||
return self.protocol.readF32List(size)
|
||||
|
||||
def writeFloatArray(self, floats):
|
||||
self.protocol.writeI32(len(floats))
|
||||
self.protocol.writeF32List(floats)
|
||||
|
||||
def readObject(self):
|
||||
return self.deserializeMessage()
|
||||
|
||||
def writeObject(self, obj):
|
||||
self.serializeMessage(obj)
|
|
@ -35,8 +35,8 @@
|
|||
__all__ = [
|
||||
]
|
||||
|
||||
import dstypes, adapters
|
||||
import DynamicSerializationManager
|
||||
from . import dstypes, adapters
|
||||
from . import DynamicSerializationManager
|
||||
|
||||
class SerializationException(Exception):
|
||||
|
||||
|
|
58
dynamicserialize/__init__.py.bak
Normal file
58
dynamicserialize/__init__.py.bak
Normal file
|
@ -0,0 +1,58 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
|
||||
#
|
||||
# TODO
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 08/20/10 njensen Initial Creation.
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
__all__ = [
|
||||
]
|
||||
|
||||
import dstypes, adapters
|
||||
import DynamicSerializationManager
|
||||
|
||||
class SerializationException(Exception):
|
||||
|
||||
def __init__(self, message=None):
|
||||
self.message = message
|
||||
|
||||
def __str__(self):
|
||||
if self.message:
|
||||
return self.message
|
||||
else:
|
||||
return ""
|
||||
|
||||
def serialize(obj):
|
||||
dsm = DynamicSerializationManager.DynamicSerializationManager()
|
||||
return dsm.serializeObject(obj)
|
||||
|
||||
def deserialize(bytes):
|
||||
dsm = DynamicSerializationManager.DynamicSerializationManager()
|
||||
return dsm.deserializeBytes(bytes)
|
|
@ -52,6 +52,6 @@ def deserialize(context):
|
|||
setSize = context.readI32()
|
||||
enumClassName = context.readString()
|
||||
valList = []
|
||||
for i in xrange(setSize):
|
||||
for i in range(setSize):
|
||||
valList.append(context.readString())
|
||||
return EnumSet(enumClassName, valList)
|
||||
|
|
57
dynamicserialize/adapters/EnumSetAdapter.py.bak
Normal file
57
dynamicserialize/adapters/EnumSetAdapter.py.bak
Normal file
|
@ -0,0 +1,57 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
|
||||
#
|
||||
# Adapter for java.util.EnumSet
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 07/28/11 dgilling Initial Creation.
|
||||
# 12/02/13 2537 bsteffen Serialize empty enum sets.
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
|
||||
from dynamicserialize.dstypes.java.util import EnumSet
|
||||
|
||||
ClassAdapter = ['java.util.EnumSet', 'java.util.RegularEnumSet']
|
||||
|
||||
|
||||
def serialize(context, set):
|
||||
setSize = len(set)
|
||||
context.writeI32(setSize)
|
||||
context.writeString(set.getEnumClass())
|
||||
for val in set:
|
||||
context.writeString(val)
|
||||
|
||||
|
||||
def deserialize(context):
|
||||
setSize = context.readI32()
|
||||
enumClassName = context.readString()
|
||||
valList = []
|
||||
for i in xrange(setSize):
|
||||
valList.append(context.readString())
|
||||
return EnumSet(enumClassName, valList)
|
|
@ -45,7 +45,7 @@ def serialize(context, lockTable):
|
|||
for lock in locks:
|
||||
wsIdString = lock.getWsId().toString()
|
||||
|
||||
if wsIds.has_key(wsIdString):
|
||||
if wsIdString in wsIds:
|
||||
lockWsIdIndex.append(wsIds[wsIdString])
|
||||
else:
|
||||
lockWsIdIndex.append(index)
|
||||
|
@ -68,12 +68,12 @@ def deserialize(context):
|
|||
parmId = context.readObject()
|
||||
numWsIds = context.readI32()
|
||||
wsIds = []
|
||||
for x in xrange(numWsIds):
|
||||
for x in range(numWsIds):
|
||||
wsIds.append(context.readObject())
|
||||
|
||||
numLocks = context.readI32()
|
||||
locks = []
|
||||
for x in xrange(numLocks):
|
||||
for x in range(numLocks):
|
||||
startTime = context.readI64()
|
||||
endTime = context.readI64()
|
||||
wsId = wsIds[context.readI32()]
|
||||
|
|
88
dynamicserialize/adapters/LockTableAdapter.py.bak
Normal file
88
dynamicserialize/adapters/LockTableAdapter.py.bak
Normal file
|
@ -0,0 +1,88 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
#
|
||||
# Adapter for com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 04/22/13 rjpeter Initial Creation.
|
||||
# 06/12/13 #2099 dgilling Use new Lock constructor.
|
||||
#
|
||||
#
|
||||
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.lock import LockTable
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.lock import Lock
|
||||
|
||||
ClassAdapter = 'com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable'
|
||||
|
||||
def serialize(context, lockTable):
|
||||
index=0
|
||||
wsIds = {lockTable.getWsId().toString() : index}
|
||||
index += 1
|
||||
locks = lockTable.getLocks()
|
||||
lockWsIdIndex = []
|
||||
for lock in locks:
|
||||
wsIdString = lock.getWsId().toString()
|
||||
|
||||
if wsIds.has_key(wsIdString):
|
||||
lockWsIdIndex.append(wsIds[wsIdString])
|
||||
else:
|
||||
lockWsIdIndex.append(index)
|
||||
wsIds[wsIdString] = index
|
||||
index += 1
|
||||
|
||||
context.writeObject(lockTable.getParmId())
|
||||
|
||||
context.writeI32(index)
|
||||
for wsId in sorted(wsIds, key=wsIds.get):
|
||||
context.writeObject(wsId)
|
||||
|
||||
context.writeI32(len(locks))
|
||||
for lock, wsIndex in zip(locks, lockWsIdIndex):
|
||||
serializer.writeI64(lock.getStartTime())
|
||||
serializer.writeI64(lock.getEndTime())
|
||||
serializer.writeI32(wsIndex)
|
||||
|
||||
def deserialize(context):
|
||||
parmId = context.readObject()
|
||||
numWsIds = context.readI32()
|
||||
wsIds = []
|
||||
for x in xrange(numWsIds):
|
||||
wsIds.append(context.readObject())
|
||||
|
||||
numLocks = context.readI32()
|
||||
locks = []
|
||||
for x in xrange(numLocks):
|
||||
startTime = context.readI64()
|
||||
endTime = context.readI64()
|
||||
wsId = wsIds[context.readI32()]
|
||||
lock = Lock(parmId, wsId, startTime, endTime)
|
||||
locks.append(lock)
|
||||
|
||||
lockTable = LockTable()
|
||||
lockTable.setParmId(parmId)
|
||||
lockTable.setWsId(wsIds[0])
|
||||
lockTable.setLocks(locks)
|
||||
|
||||
return lockTable
|
|
@ -52,7 +52,7 @@ def deserialize(context):
|
|||
wsId.setUserName(wsIdParts[1])
|
||||
wsId.setProgName(wsIdParts[2])
|
||||
wsId.setPid(wsIdParts[3])
|
||||
wsId.setThreadId(long(wsIdParts[4]))
|
||||
wsId.setThreadId(int(wsIdParts[4]))
|
||||
|
||||
return wsId
|
||||
|
||||
|
|
58
dynamicserialize/adapters/WsIdAdapter.py.bak
Normal file
58
dynamicserialize/adapters/WsIdAdapter.py.bak
Normal file
|
@ -0,0 +1,58 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
|
||||
#
|
||||
# Adapter for com.raytheon.uf.common.message.WsId
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 09/16/10 dgilling Initial Creation.
|
||||
# 04/25/12 545 randerso Repurposed the lockKey field as threadId
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.message import WsId
|
||||
|
||||
ClassAdapter = 'com.raytheon.uf.common.message.WsId'
|
||||
|
||||
|
||||
def serialize(context, wsId):
|
||||
context.writeString(wsId.toString())
|
||||
|
||||
def deserialize(context):
|
||||
wsIdString = context.readString()
|
||||
wsIdParts = wsIdString.split(":", 5)
|
||||
|
||||
wsId = WsId()
|
||||
wsId.setNetworkId(wsIdParts[0])
|
||||
wsId.setUserName(wsIdParts[1])
|
||||
wsId.setProgName(wsIdParts[2])
|
||||
wsId.setPid(wsIdParts[3])
|
||||
wsId.setThreadId(long(wsIdParts[4]))
|
||||
|
||||
return wsId
|
||||
|
|
@ -66,10 +66,10 @@ classAdapterRegistry = {}
|
|||
def getAdapterRegistry():
|
||||
import sys
|
||||
for x in __all__:
|
||||
exec 'import ' + x
|
||||
exec('import ' + x)
|
||||
m = sys.modules['dynamicserialize.adapters.' + x]
|
||||
d = m.__dict__
|
||||
if d.has_key('ClassAdapter'):
|
||||
if 'ClassAdapter' in d:
|
||||
if isinstance(m.ClassAdapter, list):
|
||||
for clz in m.ClassAdapter:
|
||||
classAdapterRegistry[clz] = m
|
||||
|
|
85
dynamicserialize/adapters/__init__.py.bak
Normal file
85
dynamicserialize/adapters/__init__.py.bak
Normal file
|
@ -0,0 +1,85 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
|
||||
#
|
||||
# __init__.py for Dynamic Serialize adapters.
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 08/31/10 njensen Initial Creation.
|
||||
# 03/20/13 #1774 randerso Added TimeConstraintsAdapter
|
||||
# 04/22/13 #1949 rjpeter Added LockTableAdapter
|
||||
# 02/06/14 #2672 bsteffen Added JTSEnvelopeAdapter
|
||||
# 06/22/2015 #4573 randerso Added JobProgressAdapter
|
||||
#
|
||||
#
|
||||
|
||||
__all__ = [
|
||||
'PointAdapter',
|
||||
'StackTraceElementAdapter',
|
||||
'WsIdAdapter',
|
||||
'CalendarAdapter',
|
||||
'GregorianCalendarAdapter',
|
||||
'ActiveTableModeAdapter',
|
||||
'DateAdapter',
|
||||
'LocalizationLevelSerializationAdapter',
|
||||
'LocalizationTypeSerializationAdapter',
|
||||
'GeometryTypeAdapter',
|
||||
'CoordAdapter',
|
||||
'TimeRangeTypeAdapter',
|
||||
'ParmIDAdapter',
|
||||
'DatabaseIDAdapter',
|
||||
'TimestampAdapter',
|
||||
'EnumSetAdapter',
|
||||
'FloatBufferAdapter',
|
||||
'ByteBufferAdapter',
|
||||
'TimeConstraintsAdapter',
|
||||
'LockTableAdapter',
|
||||
'JTSEnvelopeAdapter',
|
||||
'JobProgressAdapter',
|
||||
]
|
||||
|
||||
classAdapterRegistry = {}
|
||||
|
||||
|
||||
def getAdapterRegistry():
|
||||
import sys
|
||||
for x in __all__:
|
||||
exec 'import ' + x
|
||||
m = sys.modules['dynamicserialize.adapters.' + x]
|
||||
d = m.__dict__
|
||||
if d.has_key('ClassAdapter'):
|
||||
if isinstance(m.ClassAdapter, list):
|
||||
for clz in m.ClassAdapter:
|
||||
classAdapterRegistry[clz] = m
|
||||
else:
|
||||
clzName = m.ClassAdapter
|
||||
classAdapterRegistry[clzName] = m
|
||||
else:
|
||||
raise LookupError('Adapter class ' + x + ' has no ClassAdapter field ' + \
|
||||
'and cannot be registered.')
|
||||
|
||||
|
||||
getAdapterRegistry()
|
||||
|
|
@ -26,12 +26,10 @@
|
|||
#
|
||||
##
|
||||
|
||||
import ActiveTableKey
|
||||
from . import ActiveTableKey
|
||||
import abc
|
||||
|
||||
class ActiveTableRecord(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
class ActiveTableRecord(object, metaclass=abc.ABCMeta):
|
||||
@abc.abstractmethod
|
||||
def __init__(self):
|
||||
self.key = ActiveTableKey.ActiveTableKey()
|
||||
|
|
|
@ -0,0 +1,291 @@
|
|||
##
|
||||
# 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
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 05/22/2015 4522 randerso Initial creation (hand generated)
|
||||
#
|
||||
##
|
||||
|
||||
import ActiveTableKey
|
||||
import abc
|
||||
|
||||
class ActiveTableRecord(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
@abc.abstractmethod
|
||||
def __init__(self):
|
||||
self.key = ActiveTableKey.ActiveTableKey()
|
||||
self.wmoid = None
|
||||
self.pil = None
|
||||
self.xxxid = None
|
||||
self.countyheader = None
|
||||
self.vtecstr = None
|
||||
self.productClass = None
|
||||
self.act = None
|
||||
self.startTime = None
|
||||
self.endTime = None
|
||||
self.issueTime = None
|
||||
self.purgeTime = None
|
||||
self.ufn = None
|
||||
self.geometry = None
|
||||
self.forecaster = None
|
||||
self.motdir = None
|
||||
self.motspd = None
|
||||
self.loc = None
|
||||
self.rawmessage = None
|
||||
self.seg = None
|
||||
self.phensig = None
|
||||
self.region = None
|
||||
self.overviewText = None
|
||||
self.segText = None
|
||||
self.locationID = None
|
||||
self.floodSeverity = None
|
||||
self.immediateCause = None
|
||||
self.floodRecordStatus = None
|
||||
self.floodBegin = None
|
||||
self.floodCrest = None
|
||||
self.floodEnd = None
|
||||
self.identifier = None
|
||||
|
||||
def getKey(self):
|
||||
return self.key
|
||||
|
||||
def setKey(self, key):
|
||||
self.key = key
|
||||
|
||||
def getWmoid(self):
|
||||
return self.wmoid
|
||||
|
||||
def setWmoid(self, wmoid):
|
||||
self.wmoid = wmoid
|
||||
|
||||
def getPil(self):
|
||||
return self.pil
|
||||
|
||||
def setPil(self, pil):
|
||||
self.pil = pil
|
||||
|
||||
def getXxxid(self):
|
||||
return self.xxxid
|
||||
|
||||
def setXxxid(self, xxxid):
|
||||
self.xxxid = xxxid
|
||||
|
||||
def getCountyheader(self):
|
||||
return self.countyheader
|
||||
|
||||
def setCountyheader(self, countyheader):
|
||||
self.countyheader = countyheader
|
||||
|
||||
def getUgcZone(self):
|
||||
return self.key.getUgcZone()
|
||||
|
||||
def setUgcZone(self, ugcZone):
|
||||
self.key.setUgcZone(ugcZone)
|
||||
|
||||
def getVtecstr(self):
|
||||
return self.vtecstr
|
||||
|
||||
def setVtecstr(self, vtecstr):
|
||||
self.vtecstr = vtecstr
|
||||
|
||||
def getProductClass(self):
|
||||
return self.productClass
|
||||
|
||||
def setProductClass(self, productClass):
|
||||
self.productClass = productClass
|
||||
|
||||
def getAct(self):
|
||||
return self.act
|
||||
|
||||
def setAct(self, act):
|
||||
self.act = act
|
||||
|
||||
def getOfficeid(self):
|
||||
return self.key.getOfficeid()
|
||||
|
||||
def setOfficeid(self, officeid):
|
||||
self.key.setOfficeid(officeid)
|
||||
|
||||
def getPhen(self):
|
||||
return self.key.getPhen()
|
||||
|
||||
def setPhen(self, phen):
|
||||
self.key.setPhen(phen)
|
||||
|
||||
def getSig(self):
|
||||
return self.key.getSig()
|
||||
|
||||
def setSig(self, sig):
|
||||
self.key.setSig(sig)
|
||||
|
||||
def getEtn(self):
|
||||
return self.key.getEtn()
|
||||
|
||||
def setEtn(self, etn):
|
||||
self.key.setEtn(etn)
|
||||
|
||||
def getStartTime(self):
|
||||
return self.startTime
|
||||
|
||||
def setStartTime(self, startTime):
|
||||
self.startTime = startTime
|
||||
|
||||
def getEndTime(self):
|
||||
return self.endTime
|
||||
|
||||
def setEndTime(self, endTime):
|
||||
self.endTime = endTime
|
||||
|
||||
def getIssueTime(self):
|
||||
return self.issueTime
|
||||
|
||||
def setIssueTime(self, issueTime):
|
||||
self.issueTime = issueTime
|
||||
|
||||
def getPurgeTime(self):
|
||||
return self.purgeTime
|
||||
|
||||
def setPurgeTime(self, purgeTime):
|
||||
self.purgeTime = purgeTime
|
||||
|
||||
def isUfn(self):
|
||||
return self.ufn
|
||||
|
||||
def setUfn(self, ufn):
|
||||
self.ufn = ufn
|
||||
|
||||
def getGeometry(self):
|
||||
return self.geometry
|
||||
|
||||
def setGeometry(self, geometry):
|
||||
self.geometry = geometry
|
||||
|
||||
def getForecaster(self):
|
||||
return self.forecaster
|
||||
|
||||
def setForecaster(self, forecaster):
|
||||
self.forecaster = forecaster
|
||||
|
||||
def getMotdir(self):
|
||||
return self.motdir
|
||||
|
||||
def setMotdir(self, motdir):
|
||||
self.motdir = motdir
|
||||
|
||||
def getMotspd(self):
|
||||
return self.motspd
|
||||
|
||||
def setMotspd(self, motspd):
|
||||
self.motspd = motspd
|
||||
|
||||
def getLoc(self):
|
||||
return self.loc
|
||||
|
||||
def setLoc(self, loc):
|
||||
self.loc = loc
|
||||
|
||||
def getRawmessage(self):
|
||||
return self.rawmessage
|
||||
|
||||
def setRawmessage(self, rawmessage):
|
||||
self.rawmessage = rawmessage
|
||||
|
||||
def getSeg(self):
|
||||
return self.seg
|
||||
|
||||
def setSeg(self, seg):
|
||||
self.seg = seg
|
||||
|
||||
def getPhensig(self):
|
||||
return self.phensig
|
||||
|
||||
def setPhensig(self, phensig):
|
||||
self.phensig = phensig
|
||||
|
||||
def getRegion(self):
|
||||
return self.region
|
||||
|
||||
def setRegion(self, region):
|
||||
self.region = region
|
||||
|
||||
def getOverviewText(self):
|
||||
return self.overviewText
|
||||
|
||||
def setOverviewText(self, overviewText):
|
||||
self.overviewText = overviewText
|
||||
|
||||
def getSegText(self):
|
||||
return self.segText
|
||||
|
||||
def setSegText(self, segText):
|
||||
self.segText = segText
|
||||
|
||||
def getLocationID(self):
|
||||
return self.locationID
|
||||
|
||||
def setLocationID(self, locationID):
|
||||
self.locationID = locationID
|
||||
|
||||
def getFloodSeverity(self):
|
||||
return self.floodSeverity
|
||||
|
||||
def setFloodSeverity(self, floodSeverity):
|
||||
self.floodSeverity = floodSeverity
|
||||
|
||||
def getImmediateCause(self):
|
||||
return self.immediateCause
|
||||
|
||||
def setImmediateCause(self, immediateCause):
|
||||
self.immediateCause = immediateCause
|
||||
|
||||
def getFloodRecordStatus(self):
|
||||
return self.floodRecordStatus
|
||||
|
||||
def setFloodRecordStatus(self, floodRecordStatus):
|
||||
self.floodRecordStatus = floodRecordStatus
|
||||
|
||||
def getFloodBegin(self):
|
||||
return self.floodBegin
|
||||
|
||||
def setFloodBegin(self, floodBegin):
|
||||
self.floodBegin = floodBegin
|
||||
|
||||
def getFloodCrest(self):
|
||||
return self.floodCrest
|
||||
|
||||
def setFloodCrest(self, floodCrest):
|
||||
self.floodCrest = floodCrest
|
||||
|
||||
def getFloodEnd(self):
|
||||
return self.floodEnd
|
||||
|
||||
def setFloodEnd(self, floodEnd):
|
||||
self.floodEnd = floodEnd
|
||||
|
||||
def getIdentifier(self):
|
||||
return self.identifier
|
||||
|
||||
def setIdentifier(self, identifier):
|
||||
self.identifier = identifier
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
#
|
||||
##
|
||||
|
||||
import ActiveTableRecord
|
||||
from . import ActiveTableRecord
|
||||
|
||||
class OperationalActiveTableRecord(ActiveTableRecord.ActiveTableRecord):
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
##
|
||||
# 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
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 05/22/2015 4522 randerso Changed to inherit from ActiveTableRecord
|
||||
#
|
||||
##
|
||||
|
||||
import ActiveTableRecord
|
||||
|
||||
class OperationalActiveTableRecord(ActiveTableRecord.ActiveTableRecord):
|
||||
|
||||
def __init__(self):
|
||||
super(OperationalActiveTableRecord, self).__init__()
|
|
@ -26,7 +26,7 @@
|
|||
#
|
||||
##
|
||||
|
||||
import ActiveTableRecord
|
||||
from . import ActiveTableRecord
|
||||
|
||||
class PracticeActiveTableRecord(ActiveTableRecord.ActiveTableRecord):
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
##
|
||||
# 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
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 05/22/2015 4522 randerso Changed to inherit from ActiveTableRecord
|
||||
#
|
||||
##
|
||||
|
||||
import ActiveTableRecord
|
||||
|
||||
class PracticeActiveTableRecord(ActiveTableRecord.ActiveTableRecord):
|
||||
|
||||
def __init__(self):
|
||||
super(PracticeActiveTableRecord, self).__init__()
|
|
@ -41,20 +41,20 @@ __all__ = [
|
|||
'response'
|
||||
]
|
||||
|
||||
from ActiveTableKey import ActiveTableKey
|
||||
from ActiveTableRecord import ActiveTableRecord
|
||||
from ActiveTableMode import ActiveTableMode
|
||||
from DumpActiveTableRequest import DumpActiveTableRequest
|
||||
from DumpActiveTableResponse import DumpActiveTableResponse
|
||||
from GetActiveTableDictRequest import GetActiveTableDictRequest
|
||||
from GetActiveTableDictResponse import GetActiveTableDictResponse
|
||||
from GetFourCharSitesRequest import GetFourCharSitesRequest
|
||||
from GetFourCharSitesResponse import GetFourCharSitesResponse
|
||||
from GetVtecAttributeRequest import GetVtecAttributeRequest
|
||||
from GetVtecAttributeResponse import GetVtecAttributeResponse
|
||||
from OperationalActiveTableRecord import OperationalActiveTableRecord
|
||||
from PracticeActiveTableRecord import PracticeActiveTableRecord
|
||||
from SendPracticeProductRequest import SendPracticeProductRequest
|
||||
from VTECChange import VTECChange
|
||||
from VTECTableChangeNotification import VTECTableChangeNotification
|
||||
from .ActiveTableKey import ActiveTableKey
|
||||
from .ActiveTableRecord import ActiveTableRecord
|
||||
from .ActiveTableMode import ActiveTableMode
|
||||
from .DumpActiveTableRequest import DumpActiveTableRequest
|
||||
from .DumpActiveTableResponse import DumpActiveTableResponse
|
||||
from .GetActiveTableDictRequest import GetActiveTableDictRequest
|
||||
from .GetActiveTableDictResponse import GetActiveTableDictResponse
|
||||
from .GetFourCharSitesRequest import GetFourCharSitesRequest
|
||||
from .GetFourCharSitesResponse import GetFourCharSitesResponse
|
||||
from .GetVtecAttributeRequest import GetVtecAttributeRequest
|
||||
from .GetVtecAttributeResponse import GetVtecAttributeResponse
|
||||
from .OperationalActiveTableRecord import OperationalActiveTableRecord
|
||||
from .PracticeActiveTableRecord import PracticeActiveTableRecord
|
||||
from .SendPracticeProductRequest import SendPracticeProductRequest
|
||||
from .VTECChange import VTECChange
|
||||
from .VTECTableChangeNotification import VTECTableChangeNotification
|
||||
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'ActiveTableKey',
|
||||
'ActiveTableRecord',
|
||||
'ActiveTableMode',
|
||||
'DumpActiveTableRequest',
|
||||
'DumpActiveTableResponse',
|
||||
'GetActiveTableDictRequest',
|
||||
'GetActiveTableDictResponse',
|
||||
'GetFourCharSitesRequest',
|
||||
'GetFourCharSitesResponse',
|
||||
'GetVtecAttributeRequest',
|
||||
'GetVtecAttributeResponse',
|
||||
'OperationalActiveTableRecord',
|
||||
'PracticeActiveTableRecord',
|
||||
'SendPracticeProductRequest',
|
||||
'VTECChange',
|
||||
'VTECTableChangeNotification',
|
||||
'request',
|
||||
'response'
|
||||
]
|
||||
|
||||
from ActiveTableKey import ActiveTableKey
|
||||
from ActiveTableRecord import ActiveTableRecord
|
||||
from ActiveTableMode import ActiveTableMode
|
||||
from DumpActiveTableRequest import DumpActiveTableRequest
|
||||
from DumpActiveTableResponse import DumpActiveTableResponse
|
||||
from GetActiveTableDictRequest import GetActiveTableDictRequest
|
||||
from GetActiveTableDictResponse import GetActiveTableDictResponse
|
||||
from GetFourCharSitesRequest import GetFourCharSitesRequest
|
||||
from GetFourCharSitesResponse import GetFourCharSitesResponse
|
||||
from GetVtecAttributeRequest import GetVtecAttributeRequest
|
||||
from GetVtecAttributeResponse import GetVtecAttributeResponse
|
||||
from OperationalActiveTableRecord import OperationalActiveTableRecord
|
||||
from PracticeActiveTableRecord import PracticeActiveTableRecord
|
||||
from SendPracticeProductRequest import SendPracticeProductRequest
|
||||
from VTECChange import VTECChange
|
||||
from VTECTableChangeNotification import VTECTableChangeNotification
|
||||
|
|
@ -27,8 +27,8 @@ __all__ = [
|
|||
'SendActiveTableRequest'
|
||||
]
|
||||
|
||||
from ClearPracticeVTECTableRequest import ClearPracticeVTECTableRequest
|
||||
from MergeActiveTableRequest import MergeActiveTableRequest
|
||||
from RetrieveRemoteActiveTableRequest import RetrieveRemoteActiveTableRequest
|
||||
from SendActiveTableRequest import SendActiveTableRequest
|
||||
from .ClearPracticeVTECTableRequest import ClearPracticeVTECTableRequest
|
||||
from .MergeActiveTableRequest import MergeActiveTableRequest
|
||||
from .RetrieveRemoteActiveTableRequest import RetrieveRemoteActiveTableRequest
|
||||
from .SendActiveTableRequest import SendActiveTableRequest
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'ClearPracticeVTECTableRequest',
|
||||
'MergeActiveTableRequest',
|
||||
'RetrieveRemoteActiveTableRequest',
|
||||
'SendActiveTableRequest'
|
||||
]
|
||||
|
||||
from ClearPracticeVTECTableRequest import ClearPracticeVTECTableRequest
|
||||
from MergeActiveTableRequest import MergeActiveTableRequest
|
||||
from RetrieveRemoteActiveTableRequest import RetrieveRemoteActiveTableRequest
|
||||
from SendActiveTableRequest import SendActiveTableRequest
|
||||
|
|
@ -24,5 +24,5 @@ __all__ = [
|
|||
'ActiveTableSharingResponse'
|
||||
]
|
||||
|
||||
from ActiveTableSharingResponse import ActiveTableSharingResponse
|
||||
from .ActiveTableSharingResponse import ActiveTableSharingResponse
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'ActiveTableSharingResponse'
|
||||
]
|
||||
|
||||
from ActiveTableSharingResponse import ActiveTableSharingResponse
|
||||
|
|
@ -24,5 +24,5 @@ __all__ = [
|
|||
'AlertVizRequest'
|
||||
]
|
||||
|
||||
from AlertVizRequest import AlertVizRequest
|
||||
from .AlertVizRequest import AlertVizRequest
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'AlertVizRequest'
|
||||
]
|
||||
|
||||
from AlertVizRequest import AlertVizRequest
|
||||
|
|
@ -23,9 +23,7 @@
|
|||
import abc
|
||||
|
||||
|
||||
class AbstractFailedResponse(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
class AbstractFailedResponse(object, metaclass=abc.ABCMeta):
|
||||
@abc.abstractmethod
|
||||
def __init__(self):
|
||||
self.request = None
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated against equivalent DynamicSerialize Java class
|
||||
|
||||
import abc
|
||||
|
||||
|
||||
class AbstractFailedResponse(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
@abc.abstractmethod
|
||||
def __init__(self):
|
||||
self.request = None
|
||||
|
||||
def getRequest(self):
|
||||
return self.request
|
||||
|
||||
def setRequest(self, request):
|
||||
self.request = request
|
||||
|
|
@ -27,8 +27,8 @@ __all__ = [
|
|||
'UserNotAuthorized'
|
||||
]
|
||||
|
||||
from AbstractFailedResponse import AbstractFailedResponse
|
||||
from AuthServerErrorResponse import AuthServerErrorResponse
|
||||
from SuccessfulExecution import SuccessfulExecution
|
||||
from UserNotAuthorized import UserNotAuthorized
|
||||
from .AbstractFailedResponse import AbstractFailedResponse
|
||||
from .AuthServerErrorResponse import AuthServerErrorResponse
|
||||
from .SuccessfulExecution import SuccessfulExecution
|
||||
from .UserNotAuthorized import UserNotAuthorized
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'AbstractFailedResponse',
|
||||
'AuthServerErrorResponse',
|
||||
'SuccessfulExecution',
|
||||
'UserNotAuthorized'
|
||||
]
|
||||
|
||||
from AbstractFailedResponse import AbstractFailedResponse
|
||||
from AuthServerErrorResponse import AuthServerErrorResponse
|
||||
from SuccessfulExecution import SuccessfulExecution
|
||||
from UserNotAuthorized import UserNotAuthorized
|
||||
|
|
@ -24,4 +24,4 @@ __all__ = [
|
|||
'AuthenticationData'
|
||||
]
|
||||
|
||||
from AuthenticationData import AuthenticationData
|
||||
from .AuthenticationData import AuthenticationData
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'AuthenticationData'
|
||||
]
|
||||
|
||||
from AuthenticationData import AuthenticationData
|
|
@ -56,10 +56,10 @@ class DefaultDataRequest(IDataRequest):
|
|||
del self.identifiers[key]
|
||||
|
||||
def setParameters(self, *params):
|
||||
self.parameters = map(str, params)
|
||||
self.parameters = list(map(str, params))
|
||||
|
||||
def setLevels(self, *levels):
|
||||
self.levels = map(self.__makeLevel, levels)
|
||||
self.levels = list(map(self.__makeLevel, levels))
|
||||
|
||||
def __makeLevel(self, level):
|
||||
if type(level) is Level:
|
||||
|
@ -73,7 +73,7 @@ class DefaultDataRequest(IDataRequest):
|
|||
self.envelope = Envelope(env.envelope)
|
||||
|
||||
def setLocationNames(self, *locationNames):
|
||||
self.locationNames = map(str, locationNames)
|
||||
self.locationNames = list(map(str, locationNames))
|
||||
|
||||
def getDatatype(self):
|
||||
return self.datatype
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated against equivalent DynamicSerialize Java class
|
||||
# and then modified post-generation to sub-class IDataRequest.
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 05/28/13 2023 dgilling Initial Creation.
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
from awips.dataaccess import IDataRequest
|
||||
|
||||
from dynamicserialize.dstypes.com.vividsolutions.jts.geom import Envelope
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.level import Level
|
||||
|
||||
|
||||
class DefaultDataRequest(IDataRequest):
|
||||
|
||||
def __init__(self):
|
||||
self.datatype = None
|
||||
self.identifiers = {}
|
||||
self.parameters = []
|
||||
self.levels = []
|
||||
self.locationNames = []
|
||||
self.envelope = None
|
||||
|
||||
def setDatatype(self, datatype):
|
||||
self.datatype = str(datatype)
|
||||
|
||||
def addIdentifier(self, key, value):
|
||||
self.identifiers[key] = value
|
||||
|
||||
def removeIdentifier(self, key):
|
||||
del self.identifiers[key]
|
||||
|
||||
def setParameters(self, *params):
|
||||
self.parameters = map(str, params)
|
||||
|
||||
def setLevels(self, *levels):
|
||||
self.levels = map(self.__makeLevel, levels)
|
||||
|
||||
def __makeLevel(self, level):
|
||||
if type(level) is Level:
|
||||
return level
|
||||
elif type(level) is str:
|
||||
return Level(level)
|
||||
else:
|
||||
raise TypeError("Invalid object type specified for level.")
|
||||
|
||||
def setEnvelope(self, env):
|
||||
self.envelope = Envelope(env.envelope)
|
||||
|
||||
def setLocationNames(self, *locationNames):
|
||||
self.locationNames = map(str, locationNames)
|
||||
|
||||
def getDatatype(self):
|
||||
return self.datatype
|
||||
|
||||
def getIdentifiers(self):
|
||||
return self.identifiers
|
||||
|
||||
def getParameters(self):
|
||||
return self.parameters
|
||||
|
||||
def getLevels(self):
|
||||
return self.levels
|
||||
|
||||
def getEnvelope(self):
|
||||
return self.envelope
|
||||
|
||||
def getLocationNames(self):
|
||||
return self.locationNames
|
|
@ -24,5 +24,5 @@ __all__ = [
|
|||
'DefaultDataRequest'
|
||||
]
|
||||
|
||||
from DefaultDataRequest import DefaultDataRequest
|
||||
from .DefaultDataRequest import DefaultDataRequest
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'DefaultDataRequest'
|
||||
]
|
||||
|
||||
from DefaultDataRequest import DefaultDataRequest
|
||||
|
|
@ -32,9 +32,7 @@
|
|||
import abc
|
||||
|
||||
|
||||
class AbstractDataAccessRequest(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
class AbstractDataAccessRequest(object, metaclass=abc.ABCMeta):
|
||||
def __init__(self):
|
||||
self.requestParameters = None
|
||||
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated against equivalent DynamicSerialize Java class
|
||||
# and then modified post-generation to make it a abstract base class.
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 05/28/13 #2023 dgilling Initial Creation.
|
||||
#
|
||||
#
|
||||
|
||||
import abc
|
||||
|
||||
|
||||
class AbstractDataAccessRequest(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
def __init__(self):
|
||||
self.requestParameters = None
|
||||
|
||||
def getRequestParameters(self):
|
||||
return self.requestParameters
|
||||
|
||||
def setRequestParameters(self, requestParameters):
|
||||
self.requestParameters = requestParameters
|
||||
|
|
@ -31,9 +31,7 @@
|
|||
|
||||
import abc
|
||||
|
||||
class AbstractIdentifierRequest(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
class AbstractIdentifierRequest(object, metaclass=abc.ABCMeta):
|
||||
def __init__(self):
|
||||
self.datatype = None
|
||||
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated against equivalent DynamicSerialize Java class
|
||||
# and then modified post-generation to make it a abstract base class.
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 07/23/14 #3185 njensen Initial Creation.
|
||||
#
|
||||
#
|
||||
|
||||
import abc
|
||||
|
||||
class AbstractIdentifierRequest(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
def __init__(self):
|
||||
self.datatype = None
|
||||
|
||||
def getDatatype(self):
|
||||
return self.datatype
|
||||
|
||||
def setDatatype(self, datatype):
|
||||
self.datatype = datatype
|
||||
|
|
@ -34,15 +34,15 @@ __all__ = [
|
|||
'GetOptionalIdentifiersRequest'
|
||||
]
|
||||
|
||||
from AbstractDataAccessRequest import AbstractDataAccessRequest
|
||||
from AbstractIdentifierRequest import AbstractIdentifierRequest
|
||||
from GetAvailableLevelsRequest import GetAvailableLevelsRequest
|
||||
from GetAvailableLocationNamesRequest import GetAvailableLocationNamesRequest
|
||||
from GetAvailableParametersRequest import GetAvailableParametersRequest
|
||||
from GetAvailableTimesRequest import GetAvailableTimesRequest
|
||||
from GetGeometryDataRequest import GetGeometryDataRequest
|
||||
from GetGridDataRequest import GetGridDataRequest
|
||||
from GetRequiredIdentifiersRequest import GetRequiredIdentifiersRequest
|
||||
from GetSupportedDatatypesRequest import GetSupportedDatatypesRequest
|
||||
from GetOptionalIdentifiersRequest import GetOptionalIdentifiersRequest
|
||||
from .AbstractDataAccessRequest import AbstractDataAccessRequest
|
||||
from .AbstractIdentifierRequest import AbstractIdentifierRequest
|
||||
from .GetAvailableLevelsRequest import GetAvailableLevelsRequest
|
||||
from .GetAvailableLocationNamesRequest import GetAvailableLocationNamesRequest
|
||||
from .GetAvailableParametersRequest import GetAvailableParametersRequest
|
||||
from .GetAvailableTimesRequest import GetAvailableTimesRequest
|
||||
from .GetGeometryDataRequest import GetGeometryDataRequest
|
||||
from .GetGridDataRequest import GetGridDataRequest
|
||||
from .GetRequiredIdentifiersRequest import GetRequiredIdentifiersRequest
|
||||
from .GetSupportedDatatypesRequest import GetSupportedDatatypesRequest
|
||||
from .GetOptionalIdentifiersRequest import GetOptionalIdentifiersRequest
|
||||
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'AbstractDataAccessRequest',
|
||||
'AbstractIdentifierRequest',
|
||||
'GetAvailableLevelsRequest',
|
||||
'GetAvailableLocationNamesRequest',
|
||||
'GetAvailableParametersRequest',
|
||||
'GetAvailableTimesRequest',
|
||||
'GetGeometryDataRequest',
|
||||
'GetGridDataRequest',
|
||||
'GetRequiredIdentifiersRequest',
|
||||
'GetSupportedDatatypesRequest',
|
||||
'GetOptionalIdentifiersRequest'
|
||||
]
|
||||
|
||||
from AbstractDataAccessRequest import AbstractDataAccessRequest
|
||||
from AbstractIdentifierRequest import AbstractIdentifierRequest
|
||||
from GetAvailableLevelsRequest import GetAvailableLevelsRequest
|
||||
from GetAvailableLocationNamesRequest import GetAvailableLocationNamesRequest
|
||||
from GetAvailableParametersRequest import GetAvailableParametersRequest
|
||||
from GetAvailableTimesRequest import GetAvailableTimesRequest
|
||||
from GetGeometryDataRequest import GetGeometryDataRequest
|
||||
from GetGridDataRequest import GetGridDataRequest
|
||||
from GetRequiredIdentifiersRequest import GetRequiredIdentifiersRequest
|
||||
from GetSupportedDatatypesRequest import GetSupportedDatatypesRequest
|
||||
from GetOptionalIdentifiersRequest import GetOptionalIdentifiersRequest
|
||||
|
|
@ -23,9 +23,7 @@
|
|||
import abc
|
||||
|
||||
|
||||
class AbstractResponseData(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
class AbstractResponseData(object, metaclass=abc.ABCMeta):
|
||||
@abc.abstractmethod
|
||||
def __init__(self):
|
||||
self.time = None
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated against equivalent DynamicSerialize Java class
|
||||
|
||||
import abc
|
||||
|
||||
|
||||
class AbstractResponseData(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
@abc.abstractmethod
|
||||
def __init__(self):
|
||||
self.time = None
|
||||
self.level = None
|
||||
self.locationName = None
|
||||
self.attributes = None
|
||||
|
||||
def getTime(self):
|
||||
return self.time
|
||||
|
||||
def setTime(self, time):
|
||||
self.time = time
|
||||
|
||||
def getLevel(self):
|
||||
return self.level
|
||||
|
||||
def setLevel(self, level):
|
||||
self.level = level
|
||||
|
||||
def getLocationName(self):
|
||||
return self.locationName
|
||||
|
||||
def setLocationName(self, locationName):
|
||||
self.locationName = locationName
|
||||
|
||||
def getAttributes(self):
|
||||
return self.attributes
|
||||
|
||||
def setAttributes(self, attributes):
|
||||
self.attributes = attributes
|
||||
|
|
@ -28,9 +28,9 @@ __all__ = [
|
|||
'GridResponseData'
|
||||
]
|
||||
|
||||
from AbstractResponseData import AbstractResponseData
|
||||
from GeometryResponseData import GeometryResponseData
|
||||
from GetGeometryDataResponse import GetGeometryDataResponse
|
||||
from GetGridDataResponse import GetGridDataResponse
|
||||
from GridResponseData import GridResponseData
|
||||
from .AbstractResponseData import AbstractResponseData
|
||||
from .GeometryResponseData import GeometryResponseData
|
||||
from .GetGeometryDataResponse import GetGeometryDataResponse
|
||||
from .GetGridDataResponse import GetGridDataResponse
|
||||
from .GridResponseData import GridResponseData
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'AbstractResponseData',
|
||||
'GeometryResponseData',
|
||||
'GetGeometryDataResponse',
|
||||
'GetGridDataResponse',
|
||||
'GridResponseData'
|
||||
]
|
||||
|
||||
from AbstractResponseData import AbstractResponseData
|
||||
from GeometryResponseData import GeometryResponseData
|
||||
from GetGeometryDataResponse import GetGeometryDataResponse
|
||||
from GetGridDataResponse import GetGridDataResponse
|
||||
from GridResponseData import GridResponseData
|
||||
|
|
@ -24,5 +24,5 @@ __all__ = [
|
|||
'RegionLookupRequest'
|
||||
]
|
||||
|
||||
from RegionLookupRequest import RegionLookupRequest
|
||||
from .RegionLookupRequest import RegionLookupRequest
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'RegionLookupRequest'
|
||||
]
|
||||
|
||||
from RegionLookupRequest import RegionLookupRequest
|
||||
|
|
@ -39,5 +39,5 @@ __all__ = [
|
|||
'weather'
|
||||
]
|
||||
|
||||
from GridDataHistory import GridDataHistory
|
||||
from .GridDataHistory import GridDataHistory
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
##
|
||||
# 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
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 06/22/2015 4573 randerso Added svcbu package
|
||||
#
|
||||
##
|
||||
|
||||
__all__ = [
|
||||
'GridDataHistory',
|
||||
'config',
|
||||
'db',
|
||||
'discrete',
|
||||
'grid',
|
||||
'request',
|
||||
'server',
|
||||
'slice',
|
||||
'svcbu',
|
||||
'weather'
|
||||
]
|
||||
|
||||
from GridDataHistory import GridDataHistory
|
||||
|
|
@ -24,5 +24,5 @@ __all__ = [
|
|||
'ProjectionData'
|
||||
]
|
||||
|
||||
from ProjectionData import ProjectionData
|
||||
from .ProjectionData import ProjectionData
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'ProjectionData'
|
||||
]
|
||||
|
||||
from ProjectionData import ProjectionData
|
||||
|
|
@ -29,10 +29,10 @@ __all__ = [
|
|||
'TimeConstraints'
|
||||
]
|
||||
|
||||
from DatabaseID import DatabaseID
|
||||
from GFERecord import GFERecord
|
||||
from GridLocation import GridLocation
|
||||
from GridParmInfo import GridParmInfo
|
||||
from ParmID import ParmID
|
||||
from TimeConstraints import TimeConstraints
|
||||
from .DatabaseID import DatabaseID
|
||||
from .GFERecord import GFERecord
|
||||
from .GridLocation import GridLocation
|
||||
from .GridParmInfo import GridParmInfo
|
||||
from .ParmID import ParmID
|
||||
from .TimeConstraints import TimeConstraints
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'DatabaseID',
|
||||
'GFERecord',
|
||||
'GridLocation',
|
||||
'GridParmInfo',
|
||||
'ParmID',
|
||||
'TimeConstraints'
|
||||
]
|
||||
|
||||
from DatabaseID import DatabaseID
|
||||
from GFERecord import GFERecord
|
||||
from GridLocation import GridLocation
|
||||
from GridParmInfo import GridParmInfo
|
||||
from ParmID import ParmID
|
||||
from TimeConstraints import TimeConstraints
|
||||
|
|
@ -24,5 +24,5 @@ __all__ = [
|
|||
'DiscreteKey'
|
||||
]
|
||||
|
||||
from DiscreteKey import DiscreteKey
|
||||
from .DiscreteKey import DiscreteKey
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'DiscreteKey'
|
||||
]
|
||||
|
||||
from DiscreteKey import DiscreteKey
|
||||
|
|
@ -25,6 +25,6 @@ __all__ = [
|
|||
'Grid2DFloat'
|
||||
]
|
||||
|
||||
from Grid2DByte import Grid2DByte
|
||||
from Grid2DFloat import Grid2DFloat
|
||||
from .Grid2DByte import Grid2DByte
|
||||
from .Grid2DFloat import Grid2DFloat
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'Grid2DByte',
|
||||
'Grid2DFloat'
|
||||
]
|
||||
|
||||
from Grid2DByte import Grid2DByte
|
||||
from Grid2DFloat import Grid2DFloat
|
||||
|
|
@ -23,9 +23,7 @@
|
|||
import abc
|
||||
|
||||
|
||||
class AbstractGfeRequest(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
class AbstractGfeRequest(object, metaclass=abc.ABCMeta):
|
||||
@abc.abstractmethod
|
||||
def __init__(self):
|
||||
self.siteID = None
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated against equivalent DynamicSerialize Java class
|
||||
|
||||
import abc
|
||||
|
||||
|
||||
class AbstractGfeRequest(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
@abc.abstractmethod
|
||||
def __init__(self):
|
||||
self.siteID = None
|
||||
self.workstationID = None
|
||||
|
||||
def getSiteID(self):
|
||||
return self.siteID
|
||||
|
||||
def setSiteID(self, siteID):
|
||||
self.siteID = siteID
|
||||
|
||||
def getWorkstationID(self):
|
||||
return self.workstationID
|
||||
|
||||
def setWorkstationID(self, workstationID):
|
||||
self.workstationID = workstationID
|
|
@ -25,9 +25,7 @@ import abc
|
|||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.request import GetGridRequest
|
||||
|
||||
|
||||
class GetGridDataRequest(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
class GetGridDataRequest(object, metaclass=abc.ABCMeta):
|
||||
@abc.abstractmethod
|
||||
def __init__(self):
|
||||
self.requests = []
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated against equivalent DynamicSerialize Java class
|
||||
|
||||
import abc
|
||||
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.request import GetGridRequest
|
||||
|
||||
|
||||
class GetGridDataRequest(object):
|
||||
__metaclass__ = abc.ABCMeta
|
||||
|
||||
@abc.abstractmethod
|
||||
def __init__(self):
|
||||
self.requests = []
|
||||
self.workstationID = None
|
||||
self.siteID = None
|
||||
|
||||
def addRequest(self, gridDataReq):
|
||||
if not isinstance(gridDataReq, GetGridRequest):
|
||||
raise TypeError("Invalid request specified: " + str(type(gridDataReq)) + \
|
||||
". Only GetGridRequests are supported.")
|
||||
else:
|
||||
self.requests.append(gridDataReq)
|
||||
|
||||
def getRequests(self):
|
||||
return self.requests
|
||||
|
||||
def setRequests(self, requests):
|
||||
del self.requests[:]
|
||||
for req in requests:
|
||||
self.addRequest(req)
|
||||
|
||||
def getWorkstationID(self):
|
||||
return self.workstationID
|
||||
|
||||
def setWorkstationID(self, workstationID):
|
||||
self.workstationID = workstationID
|
||||
|
||||
def getSiteID(self):
|
||||
return self.siteID
|
||||
|
||||
def setSiteID(self, siteID):
|
||||
self.siteID = siteID
|
||||
|
|
@ -54,30 +54,30 @@ __all__ = [
|
|||
'RsyncGridsToCWFRequest',
|
||||
]
|
||||
|
||||
from AbstractGfeRequest import AbstractGfeRequest
|
||||
from CommitGridsRequest import CommitGridsRequest
|
||||
from ConfigureTextProductsRequest import ConfigureTextProductsRequest
|
||||
from ExecuteIfpNetCDFGridRequest import ExecuteIfpNetCDFGridRequest
|
||||
from ExecuteIscMosaicRequest import ExecuteIscMosaicRequest
|
||||
from ExportGridsRequest import ExportGridsRequest
|
||||
from GetASCIIGridsRequest import GetASCIIGridsRequest
|
||||
from GetGridDataRequest import GetGridDataRequest
|
||||
from GetGridInventoryRequest import GetGridInventoryRequest
|
||||
from GetLatestDbTimeRequest import GetLatestDbTimeRequest
|
||||
from GetLatestModelDbIdRequest import GetLatestModelDbIdRequest
|
||||
from GetLockTablesRequest import GetLockTablesRequest
|
||||
from GetOfficialDbNameRequest import GetOfficialDbNameRequest
|
||||
from GetParmListRequest import GetParmListRequest
|
||||
from GetSelectTimeRangeRequest import GetSelectTimeRangeRequest
|
||||
from GetSingletonDbIdsRequest import GetSingletonDbIdsRequest
|
||||
from GetSiteTimeZoneInfoRequest import GetSiteTimeZoneInfoRequest
|
||||
from GridLocRequest import GridLocRequest
|
||||
from IscDataRecRequest import IscDataRecRequest
|
||||
from LockChangeRequest import LockChangeRequest
|
||||
from ProcessReceivedConfRequest import ProcessReceivedConfRequest
|
||||
from ProcessReceivedDigitalDataRequest import ProcessReceivedDigitalDataRequest
|
||||
from PurgeGfeGridsRequest import PurgeGfeGridsRequest
|
||||
from SaveASCIIGridsRequest import SaveASCIIGridsRequest
|
||||
from SmartInitRequest import SmartInitRequest
|
||||
from RsyncGridsToCWFRequest import RsyncGridsToCWFRequest
|
||||
from .AbstractGfeRequest import AbstractGfeRequest
|
||||
from .CommitGridsRequest import CommitGridsRequest
|
||||
from .ConfigureTextProductsRequest import ConfigureTextProductsRequest
|
||||
from .ExecuteIfpNetCDFGridRequest import ExecuteIfpNetCDFGridRequest
|
||||
from .ExecuteIscMosaicRequest import ExecuteIscMosaicRequest
|
||||
from .ExportGridsRequest import ExportGridsRequest
|
||||
from .GetASCIIGridsRequest import GetASCIIGridsRequest
|
||||
from .GetGridDataRequest import GetGridDataRequest
|
||||
from .GetGridInventoryRequest import GetGridInventoryRequest
|
||||
from .GetLatestDbTimeRequest import GetLatestDbTimeRequest
|
||||
from .GetLatestModelDbIdRequest import GetLatestModelDbIdRequest
|
||||
from .GetLockTablesRequest import GetLockTablesRequest
|
||||
from .GetOfficialDbNameRequest import GetOfficialDbNameRequest
|
||||
from .GetParmListRequest import GetParmListRequest
|
||||
from .GetSelectTimeRangeRequest import GetSelectTimeRangeRequest
|
||||
from .GetSingletonDbIdsRequest import GetSingletonDbIdsRequest
|
||||
from .GetSiteTimeZoneInfoRequest import GetSiteTimeZoneInfoRequest
|
||||
from .GridLocRequest import GridLocRequest
|
||||
from .IscDataRecRequest import IscDataRecRequest
|
||||
from .LockChangeRequest import LockChangeRequest
|
||||
from .ProcessReceivedConfRequest import ProcessReceivedConfRequest
|
||||
from .ProcessReceivedDigitalDataRequest import ProcessReceivedDigitalDataRequest
|
||||
from .PurgeGfeGridsRequest import PurgeGfeGridsRequest
|
||||
from .SaveASCIIGridsRequest import SaveASCIIGridsRequest
|
||||
from .SmartInitRequest import SmartInitRequest
|
||||
from .RsyncGridsToCWFRequest import RsyncGridsToCWFRequest
|
||||
|
||||
|
|
|
@ -0,0 +1,83 @@
|
|||
##
|
||||
# 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
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# Jul 15, 2015 #4013 randerso Added RsyncGridsToCWFRequest
|
||||
#
|
||||
|
||||
__all__ = [
|
||||
'AbstractGfeRequest',
|
||||
'CommitGridsRequest',
|
||||
'ConfigureTextProductsRequest',
|
||||
'ExecuteIfpNetCDFGridRequest',
|
||||
'ExecuteIscMosaicRequest',
|
||||
'ExportGridsRequest',
|
||||
'GetASCIIGridsRequest',
|
||||
'GetGridDataRequest',
|
||||
'GetGridInventoryRequest',
|
||||
'GetLatestDbTimeRequest',
|
||||
'GetLatestModelDbIdRequest',
|
||||
'GetLockTablesRequest',
|
||||
'GetOfficialDbNameRequest',
|
||||
'GetParmListRequest',
|
||||
'GetSelectTimeRangeRequest',
|
||||
'GetSingletonDbIdsRequest',
|
||||
'GetSiteTimeZoneInfoRequest',
|
||||
'GridLocRequest',
|
||||
'IscDataRecRequest',
|
||||
'LockChangeRequest',
|
||||
'ProcessReceivedConfRequest',
|
||||
'ProcessReceivedDigitalDataRequest',
|
||||
'PurgeGfeGridsRequest',
|
||||
'SaveASCIIGridsRequest',
|
||||
'SmartInitRequest',
|
||||
'RsyncGridsToCWFRequest',
|
||||
]
|
||||
|
||||
from AbstractGfeRequest import AbstractGfeRequest
|
||||
from CommitGridsRequest import CommitGridsRequest
|
||||
from ConfigureTextProductsRequest import ConfigureTextProductsRequest
|
||||
from ExecuteIfpNetCDFGridRequest import ExecuteIfpNetCDFGridRequest
|
||||
from ExecuteIscMosaicRequest import ExecuteIscMosaicRequest
|
||||
from ExportGridsRequest import ExportGridsRequest
|
||||
from GetASCIIGridsRequest import GetASCIIGridsRequest
|
||||
from GetGridDataRequest import GetGridDataRequest
|
||||
from GetGridInventoryRequest import GetGridInventoryRequest
|
||||
from GetLatestDbTimeRequest import GetLatestDbTimeRequest
|
||||
from GetLatestModelDbIdRequest import GetLatestModelDbIdRequest
|
||||
from GetLockTablesRequest import GetLockTablesRequest
|
||||
from GetOfficialDbNameRequest import GetOfficialDbNameRequest
|
||||
from GetParmListRequest import GetParmListRequest
|
||||
from GetSelectTimeRangeRequest import GetSelectTimeRangeRequest
|
||||
from GetSingletonDbIdsRequest import GetSingletonDbIdsRequest
|
||||
from GetSiteTimeZoneInfoRequest import GetSiteTimeZoneInfoRequest
|
||||
from GridLocRequest import GridLocRequest
|
||||
from IscDataRecRequest import IscDataRecRequest
|
||||
from LockChangeRequest import LockChangeRequest
|
||||
from ProcessReceivedConfRequest import ProcessReceivedConfRequest
|
||||
from ProcessReceivedDigitalDataRequest import ProcessReceivedDigitalDataRequest
|
||||
from PurgeGfeGridsRequest import PurgeGfeGridsRequest
|
||||
from SaveASCIIGridsRequest import SaveASCIIGridsRequest
|
||||
from SmartInitRequest import SmartInitRequest
|
||||
from RsyncGridsToCWFRequest import RsyncGridsToCWFRequest
|
||||
|
|
@ -25,6 +25,6 @@ __all__ = [
|
|||
'LockTable'
|
||||
]
|
||||
|
||||
from Lock import Lock
|
||||
from LockTable import LockTable
|
||||
from .Lock import Lock
|
||||
from .LockTable import LockTable
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'Lock',
|
||||
'LockTable'
|
||||
]
|
||||
|
||||
from Lock import Lock
|
||||
from LockTable import LockTable
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue