mirror of
https://github.com/Unidata/python-awips.git
synced 2025-02-23 14:57:56 -05:00
PEP 8 coding standards
This commit is contained in:
parent
d2b34d09bb
commit
1b68f8800c
234 changed files with 272 additions and 536 deletions
|
@ -56,6 +56,7 @@ def convertToDateTime(timeArg):
|
||||||
objType = str(type(timeArg))
|
objType = str(type(timeArg))
|
||||||
raise TypeError("Cannot convert object of type " + objType + " to datetime.")
|
raise TypeError("Cannot convert object of type " + objType + " to datetime.")
|
||||||
|
|
||||||
|
|
||||||
def _convertSecsAndMicros(seconds, micros):
|
def _convertSecsAndMicros(seconds, micros):
|
||||||
if seconds < MAX_TIME:
|
if seconds < MAX_TIME:
|
||||||
rval = datetime.datetime.utcfromtimestamp(seconds)
|
rval = datetime.datetime.utcfromtimestamp(seconds)
|
||||||
|
@ -64,6 +65,7 @@ def _convertSecsAndMicros(seconds, micros):
|
||||||
rval = datetime.datetime.utcfromtimestamp(MAX_TIME) + extraTime
|
rval = datetime.datetime.utcfromtimestamp(MAX_TIME) + extraTime
|
||||||
return rval.replace(microsecond=micros)
|
return rval.replace(microsecond=micros)
|
||||||
|
|
||||||
|
|
||||||
def constructTimeRange(*args):
|
def constructTimeRange(*args):
|
||||||
"""
|
"""
|
||||||
Builds a python dynamicserialize TimeRange object from the given
|
Builds a python dynamicserialize TimeRange object from the given
|
||||||
|
|
|
@ -53,12 +53,13 @@ class QpidSubscriber:
|
||||||
def topicSubscribe(self, topicName, callback):
|
def topicSubscribe(self, topicName, callback):
|
||||||
# if the queue is edex.alerts, set decompress to true always for now to
|
# if the queue is edex.alerts, set decompress to true always for now to
|
||||||
# maintain compatibility with existing python scripts.
|
# maintain compatibility with existing python scripts.
|
||||||
if (topicName == 'edex.alerts'):
|
if topicName == 'edex.alerts':
|
||||||
self.decompress = True
|
self.decompress = True
|
||||||
|
|
||||||
print("Establishing connection to broker on", self.host)
|
print("Establishing connection to broker on", self.host)
|
||||||
queueName = topicName + self.__session.name
|
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.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.__session.exchange_bind(exchange='amq.topic', queue=queueName, binding_key=topicName)
|
||||||
self.__innerSubscribe(queueName, callback)
|
self.__innerSubscribe(queueName, callback)
|
||||||
|
|
||||||
|
@ -75,12 +76,12 @@ class QpidSubscriber:
|
||||||
message = queue.get(timeout=10)
|
message = queue.get(timeout=10)
|
||||||
content = message.body
|
content = message.body
|
||||||
self.__session.message_accept(qpid.datatypes.RangedSet(message.id))
|
self.__session.message_accept(qpid.datatypes.RangedSet(message.id))
|
||||||
if (self.decompress):
|
if self.decompress:
|
||||||
try:
|
try:
|
||||||
# http://stackoverflow.com/questions/2423866/python-decompressing-gzip-chunk-by-chunk
|
# http://stackoverflow.com/questions/2423866/python-decompressing-gzip-chunk-by-chunk
|
||||||
d = zlib.decompressobj(16+zlib.MAX_WBITS)
|
d = zlib.decompressobj(16+zlib.MAX_WBITS)
|
||||||
content = d.decompress(content)
|
content = d.decompress(content)
|
||||||
except Exception:
|
except ValueError:
|
||||||
# decompression failed, return the original content
|
# decompression failed, return the original content
|
||||||
pass
|
pass
|
||||||
callback(content)
|
callback(content)
|
||||||
|
@ -94,10 +95,9 @@ class QpidSubscriber:
|
||||||
self.subscribed = False
|
self.subscribed = False
|
||||||
try:
|
try:
|
||||||
self.__session.close(timeout=10)
|
self.__session.close(timeout=10)
|
||||||
except Exception:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def queueStarted(self):
|
def queueStarted(self):
|
||||||
return self.__queueStarted
|
return self.__queueStarted
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ def get_datetime_str(record):
|
||||||
Returns:
|
Returns:
|
||||||
datetime string.
|
datetime string.
|
||||||
"""
|
"""
|
||||||
return str(record.getDataTime())[0:19].replace(" ","_") + ".0"
|
return str(record.getDataTime())[0:19].replace(" ", "_") + ".0"
|
||||||
|
|
||||||
|
|
||||||
def get_data_type(azdat):
|
def get_data_type(azdat):
|
||||||
|
@ -59,7 +59,7 @@ def get_hdf5_data(idra):
|
||||||
elif idra[ii].getName() == "Thresholds":
|
elif idra[ii].getName() == "Thresholds":
|
||||||
threshVals = idra[ii].getShortData()
|
threshVals = idra[ii].getShortData()
|
||||||
|
|
||||||
return rdat,azdat,depVals,threshVals
|
return rdat, azdat, depVals, threshVals
|
||||||
|
|
||||||
|
|
||||||
def get_header(record, headerFormat, xLen, yLen, azdat, description):
|
def get_header(record, headerFormat, xLen, yLen, azdat, description):
|
||||||
|
@ -90,7 +90,7 @@ def encode_thresh_vals(threshVals):
|
||||||
nnn = len(threshVals)
|
nnn = len(threshVals)
|
||||||
j = 0
|
j = 0
|
||||||
msg = ""
|
msg = ""
|
||||||
while j<nnn:
|
while j < nnn:
|
||||||
lo = threshVals[j] % 256
|
lo = threshVals[j] % 256
|
||||||
hi = threshVals[j] / 256
|
hi = threshVals[j] / 256
|
||||||
msg += " "
|
msg += " "
|
||||||
|
|
|
@ -1,9 +1,3 @@
|
||||||
try:
|
|
||||||
import http.client as httpcl
|
|
||||||
except ImportError:
|
|
||||||
import httplib as httpcl
|
|
||||||
from dynamicserialize import DynamicSerializationManager
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Provides a Python-based interface for executing Thrift requests.
|
# Provides a Python-based interface for executing Thrift requests.
|
||||||
#
|
#
|
||||||
|
@ -17,6 +11,12 @@ from dynamicserialize import DynamicSerializationManager
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
try:
|
||||||
|
import http.client as httpcl
|
||||||
|
except ImportError:
|
||||||
|
import httplib as httpcl
|
||||||
|
from dynamicserialize import DynamicSerializationManager
|
||||||
|
|
||||||
|
|
||||||
class ThriftClient:
|
class ThriftClient:
|
||||||
|
|
||||||
|
@ -32,12 +32,12 @@ class ThriftClient:
|
||||||
# will return a Thrift client pointed at http://localhost:9581/services.
|
# will return a Thrift client pointed at http://localhost:9581/services.
|
||||||
def __init__(self, host, port=9581, uri="/services"):
|
def __init__(self, host, port=9581, uri="/services"):
|
||||||
hostParts = host.split("/", 1)
|
hostParts = host.split("/", 1)
|
||||||
if (len(hostParts) > 1):
|
if len(hostParts) > 1:
|
||||||
hostString = hostParts[0]
|
hostString = hostParts[0]
|
||||||
self.__uri = "/" + hostParts[1]
|
self.__uri = "/" + hostParts[1]
|
||||||
self.__httpConn = httpcl.HTTPConnection(hostString)
|
self.__httpConn = httpcl.HTTPConnection(hostString)
|
||||||
else:
|
else:
|
||||||
if (port is None):
|
if port is None:
|
||||||
self.__httpConn = httpcl.HTTPConnection(host)
|
self.__httpConn = httpcl.HTTPConnection(host)
|
||||||
else:
|
else:
|
||||||
self.__httpConn = httpcl.HTTPConnection(host, port)
|
self.__httpConn = httpcl.HTTPConnection(host, port)
|
||||||
|
@ -53,7 +53,7 @@ class ThriftClient:
|
||||||
self.__httpConn.request("POST", self.__uri + uri, message)
|
self.__httpConn.request("POST", self.__uri + uri, message)
|
||||||
|
|
||||||
response = self.__httpConn.getresponse()
|
response = self.__httpConn.getresponse()
|
||||||
if (response.status != 200):
|
if response.status != 200:
|
||||||
raise ThriftRequestException("Unable to post request to server")
|
raise ThriftRequestException("Unable to post request to server")
|
||||||
|
|
||||||
rval = self.__dsm.deserializeBytes(response.read())
|
rval = self.__dsm.deserializeBytes(response.read())
|
||||||
|
@ -64,8 +64,8 @@ class ThriftClient:
|
||||||
# with the original Java stack trace
|
# with the original Java stack trace
|
||||||
# ELSE: we have a valid response and pass it back
|
# ELSE: we have a valid response and pass it back
|
||||||
try:
|
try:
|
||||||
forceError = rval.getException()
|
forceError = rval.getException()
|
||||||
raise ThriftRequestException(forceError)
|
raise ThriftRequestException(forceError)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -78,4 +78,3 @@ class ThriftRequestException(Exception):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return repr(self.parameter)
|
return repr(self.parameter)
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ import time
|
||||||
def determineDrtOffset(timeStr):
|
def determineDrtOffset(timeStr):
|
||||||
launchStr = timeStr
|
launchStr = timeStr
|
||||||
# Check for time difference
|
# Check for time difference
|
||||||
if timeStr.find(",") >=0:
|
if timeStr.find(",") >= 0:
|
||||||
times = timeStr.split(",")
|
times = timeStr.split(",")
|
||||||
t1 = makeTime(times[0])
|
t1 = makeTime(times[0])
|
||||||
t2 = makeTime(times[1])
|
t2 = makeTime(times[1])
|
||||||
|
@ -67,8 +67,9 @@ def determineDrtOffset(timeStr):
|
||||||
# i.e. "truncate" cur_t to most recent hour.
|
# i.e. "truncate" cur_t to most recent hour.
|
||||||
if synch:
|
if synch:
|
||||||
cur_t = time.mktime((gm[0], gm[1], gm[2], gm[3], 0, 0, 0, 0, 0))
|
cur_t = time.mktime((gm[0], gm[1], gm[2], gm[3], 0, 0, 0, 0, 0))
|
||||||
curStr = '%4s%2s%2s_%2s00\n' % (repr(gm[0]),repr(gm[1]),repr(gm[2]),repr(gm[3]))
|
curStr = '%4s%2s%2s_%2s00\n' % (repr(gm[0]), repr(gm[1]),
|
||||||
curStr = curStr.replace(' ','0')
|
repr(gm[2]), repr(gm[3]))
|
||||||
|
curStr = curStr.replace(' ', '0')
|
||||||
launchStr = timeStr + "," + curStr
|
launchStr = timeStr + "," + curStr
|
||||||
|
|
||||||
offset = drt_t - cur_t
|
offset = drt_t - cur_t
|
||||||
|
|
|
@ -27,7 +27,7 @@ class UsageArgumentParser(argparse.ArgumentParser):
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
|
|
||||||
## Custom actions for ArgumentParser objects ##
|
# Custom actions for ArgumentParser objects
|
||||||
class StoreDatabaseIDAction(argparse.Action):
|
class StoreDatabaseIDAction(argparse.Action):
|
||||||
def __call__(self, parser, namespace, values, option_string=None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
did = DatabaseID(values)
|
did = DatabaseID(values)
|
||||||
|
@ -41,8 +41,7 @@ class AppendParmNameAndLevelAction(argparse.Action):
|
||||||
def __call__(self, parser, namespace, values, option_string=None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
tx = ParmID.parmNameAndLevel(values)
|
tx = ParmID.parmNameAndLevel(values)
|
||||||
comp = tx[0] + '_' + tx[1]
|
comp = tx[0] + '_' + tx[1]
|
||||||
if (hasattr(namespace, self.dest)) and \
|
if (hasattr(namespace, self.dest)) and (getattr(namespace, self.dest) is not None):
|
||||||
(getattr(namespace, self.dest) is not None):
|
|
||||||
currentValues = getattr(namespace, self.dest)
|
currentValues = getattr(namespace, self.dest)
|
||||||
currentValues.append(comp)
|
currentValues.append(comp)
|
||||||
setattr(namespace, self.dest, currentValues)
|
setattr(namespace, self.dest, currentValues)
|
||||||
|
@ -58,8 +57,6 @@ class StoreTimeAction(argparse.Action):
|
||||||
def __call__(self, parser, namespace, values, option_string=None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
try:
|
try:
|
||||||
timeStruct = time.strptime(values, TIME_FORMAT)
|
timeStruct = time.strptime(values, TIME_FORMAT)
|
||||||
|
setattr(namespace, self.dest, timeStruct)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
parser.error(str(values) + " is not a valid time string of the format YYYYMMDD_hhmm")
|
parser.error(str(values) + " is not a valid time string of the format YYYYMMDD_hhmm")
|
||||||
|
|
||||||
setattr(namespace, self.dest, timeStruct)
|
|
||||||
|
|
||||||
|
|
|
@ -76,9 +76,9 @@ def __getAvailableTimesForEachLocation(request, refTimeOnly=False):
|
||||||
|
|
||||||
|
|
||||||
def __cloneRequest(request):
|
def __cloneRequest(request):
|
||||||
return DataAccessLayer.newDataRequest(datatype = request.getDatatype(),
|
return DataAccessLayer.newDataRequest(datatype=request.getDatatype(),
|
||||||
parameters = request.getParameters(),
|
parameters=request.getParameters(),
|
||||||
levels = request.getLevels(),
|
levels=request.getLevels(),
|
||||||
locationNames = request.getLocationNames(),
|
locationNames=request.getLocationNames(),
|
||||||
envelope = request.getEnvelope(),
|
envelope=request.getEnvelope(),
|
||||||
**request.getIdentifiers())
|
**request.getIdentifiers())
|
||||||
|
|
|
@ -4,24 +4,21 @@
|
||||||
#
|
#
|
||||||
# SOFTWARE HISTORY
|
# SOFTWARE HISTORY
|
||||||
#
|
#
|
||||||
# Date Ticket# Engineer Description
|
# Date Ticket# Engineer Description
|
||||||
# ------------ ---------- ----------- --------------------------
|
# ------------ ------- ---------- -------------------------
|
||||||
# 12/10/12 njensen Initial Creation.
|
# 12/10/12 njensen Initial Creation.
|
||||||
# Feb 14, 2013 1614 bsteffen refactor data access framework
|
# Feb 14, 2013 1614 bsteffen refactor data access framework to use single request.
|
||||||
# to use single request.
|
# 04/10/13 1871 mnash move getLatLonCoords to JGridData and add default args
|
||||||
# 04/10/13 1871 mnash move getLatLonCoords to JGridData and add default args
|
# 05/29/13 2023 dgilling Hook up ThriftClientRouter.
|
||||||
# 05/29/13 2023 dgilling Hook up ThriftClientRouter.
|
# 03/03/14 2673 bsteffen Add ability to query only ref times.
|
||||||
# 03/03/14 2673 bsteffen Add ability to query only ref times.
|
# 07/22/14 3185 njensen Added optional/default args to newDataRequest
|
||||||
# 07/22/14 3185 njensen Added optional/default args to newDataRequest
|
# 07/30/14 3185 njensen Renamed valid identifiers to optional
|
||||||
# 07/30/14 3185 njensen Renamed valid identifiers to optional
|
# Apr 26, 2015 4259 njensen Updated for new JEP API
|
||||||
# Apr 26, 2015 4259 njensen Updated for new JEP API
|
# Apr 13, 2016 5379 tgurney Add getIdentifierValues(), getRequiredIdentifiers(),
|
||||||
# Apr 13, 2016 5379 tgurney Add getIdentifierValues()
|
# and getOptionalIdentifiers()
|
||||||
# Jun 01, 2016 5587 tgurney Add new signatures for
|
# Oct 07, 2016 ---- mjames@ucar Added getForecastRun
|
||||||
# getRequiredIdentifiers() and
|
# Oct 18, 2016 5916 bsteffen Add setLazyLoadGridLatLon
|
||||||
# getOptionalIdentifiers()
|
# Oct 11, 2018 ---- mjames@ucar Added getMetarObs() getSynopticObs()
|
||||||
# Oct 07, 2016 ---- mjames@ucar Added getForecastRun
|
|
||||||
# Oct 18, 2016 5916 bsteffen Add setLazyLoadGridLatLon
|
|
||||||
# Oct 11, 2018 mjames@ucar Added getMetarObs() getSynopticObs()
|
|
||||||
#
|
#
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
@ -145,6 +142,7 @@ def getForecastRun(cycle, times):
|
||||||
fcstRun.append(t)
|
fcstRun.append(t)
|
||||||
return fcstRun
|
return fcstRun
|
||||||
|
|
||||||
|
|
||||||
def getAvailableTimes(request, refTimeOnly=False):
|
def getAvailableTimes(request, refTimeOnly=False):
|
||||||
"""
|
"""
|
||||||
Get the times of available data to the request.
|
Get the times of available data to the request.
|
||||||
|
@ -152,7 +150,7 @@ def getAvailableTimes(request, refTimeOnly=False):
|
||||||
Args:
|
Args:
|
||||||
request: the IDataRequest to get data for
|
request: the IDataRequest to get data for
|
||||||
refTimeOnly: optional, use True if only unique refTimes should be
|
refTimeOnly: optional, use True if only unique refTimes should be
|
||||||
returned (without a forecastHr)
|
returned (without a forecastHr)
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
a list of DataTimes
|
a list of DataTimes
|
||||||
|
@ -169,7 +167,7 @@ def getGridData(request, times=[]):
|
||||||
Args:
|
Args:
|
||||||
request: the IDataRequest to get data for
|
request: the IDataRequest to get data for
|
||||||
times: a list of DataTimes, a TimeRange, or None if the data is time
|
times: a list of DataTimes, a TimeRange, or None if the data is time
|
||||||
agnostic
|
agnostic
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
a list of IGridData
|
a list of IGridData
|
||||||
|
@ -186,7 +184,7 @@ def getGeometryData(request, times=[]):
|
||||||
Args:
|
Args:
|
||||||
request: the IDataRequest to get data for
|
request: the IDataRequest to get data for
|
||||||
times: a list of DataTimes, a TimeRange, or None if the data is time
|
times: a list of DataTimes, a TimeRange, or None if the data is time
|
||||||
agnostic
|
agnostic
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
a list of IGeometryData
|
a list of IGeometryData
|
||||||
|
@ -282,6 +280,7 @@ def getIdentifierValues(request, identifierKey):
|
||||||
"""
|
"""
|
||||||
return router.getIdentifierValues(request, identifierKey)
|
return router.getIdentifierValues(request, identifierKey)
|
||||||
|
|
||||||
|
|
||||||
def newDataRequest(datatype=None, **kwargs):
|
def newDataRequest(datatype=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Creates a new instance of IDataRequest suitable for the runtime environment.
|
Creates a new instance of IDataRequest suitable for the runtime environment.
|
||||||
|
@ -300,6 +299,7 @@ def newDataRequest(datatype=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
return router.newDataRequest(datatype, **kwargs)
|
return router.newDataRequest(datatype, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def getSupportedDatatypes():
|
def getSupportedDatatypes():
|
||||||
"""
|
"""
|
||||||
Gets the datatypes that are supported by the framework
|
Gets the datatypes that are supported by the framework
|
||||||
|
@ -317,7 +317,7 @@ def changeEDEXHost(newHostName):
|
||||||
method will throw a TypeError.
|
method will throw a TypeError.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
newHostHame: the EDEX host to connect to
|
newHostName: the EDEX host to connect to
|
||||||
"""
|
"""
|
||||||
if USING_NATIVE_THRIFT:
|
if USING_NATIVE_THRIFT:
|
||||||
global THRIFT_HOST
|
global THRIFT_HOST
|
||||||
|
@ -327,6 +327,7 @@ def changeEDEXHost(newHostName):
|
||||||
else:
|
else:
|
||||||
raise TypeError("Cannot call changeEDEXHost when using JepRouter.")
|
raise TypeError("Cannot call changeEDEXHost when using JepRouter.")
|
||||||
|
|
||||||
|
|
||||||
def setLazyLoadGridLatLon(lazyLoadGridLatLon):
|
def setLazyLoadGridLatLon(lazyLoadGridLatLon):
|
||||||
"""
|
"""
|
||||||
Provide a hint to the Data Access Framework indicating whether to load the
|
Provide a hint to the Data Access Framework indicating whether to load the
|
||||||
|
|
|
@ -56,7 +56,7 @@ THRIFT_HOST = "edex"
|
||||||
|
|
||||||
USING_NATIVE_THRIFT = False
|
USING_NATIVE_THRIFT = False
|
||||||
|
|
||||||
JMS_HOST_PATTERN=re.compile('tcp://([^:]+):([0-9]+)')
|
JMS_HOST_PATTERN = re.compile('tcp://([^:]+):([0-9]+)')
|
||||||
|
|
||||||
if 'jep' in sys.modules:
|
if 'jep' in sys.modules:
|
||||||
# intentionally do not catch if this fails to import, we want it to
|
# intentionally do not catch if this fails to import, we want it to
|
||||||
|
@ -124,7 +124,7 @@ def changeEDEXHost(newHostName):
|
||||||
method will throw a TypeError.
|
method will throw a TypeError.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
newHostHame: the EDEX host to connect to
|
newHostName: the EDEX host to connect to
|
||||||
"""
|
"""
|
||||||
if USING_NATIVE_THRIFT:
|
if USING_NATIVE_THRIFT:
|
||||||
global THRIFT_HOST
|
global THRIFT_HOST
|
||||||
|
|
|
@ -22,18 +22,15 @@ import sys
|
||||||
|
|
||||||
if sys.version_info.major == 2:
|
if sys.version_info.major == 2:
|
||||||
from Queue import Queue, Empty
|
from Queue import Queue, Empty
|
||||||
else: # Python 3 module renamed to 'queue'
|
else: # Python 3 module renamed to 'queue'
|
||||||
from queue import Queue, Empty
|
from queue import Queue, Empty
|
||||||
|
|
||||||
|
|
||||||
# Used to indicate a DataQueue that will produce geometry data.
|
# Used to indicate a DataQueue that will produce geometry data.
|
||||||
GEOMETRY = object()
|
GEOMETRY = object()
|
||||||
|
|
||||||
|
|
||||||
# Used to indicate a DataQueue that will produce grid data.
|
# Used to indicate a DataQueue that will produce grid data.
|
||||||
GRID = object()
|
GRID = object()
|
||||||
|
|
||||||
|
|
||||||
# Default maximum queue size.
|
# Default maximum queue size.
|
||||||
_DEFAULT_MAXSIZE = 100
|
_DEFAULT_MAXSIZE = 100
|
||||||
|
|
||||||
|
|
|
@ -39,12 +39,8 @@ def getSounding(modelName, weatherElements, levels, samplePoint, timeRange=None)
|
||||||
(locationNames, parameters, levels, envelope, timeRange) = \
|
(locationNames, parameters, levels, envelope, timeRange) = \
|
||||||
__sanitizeInputs(modelName, weatherElements, levels, samplePoint, timeRange)
|
__sanitizeInputs(modelName, weatherElements, levels, samplePoint, timeRange)
|
||||||
|
|
||||||
requestArgs = { 'datatype' : 'grid',
|
requestArgs = {'datatype': 'grid', 'locationNames': locationNames,
|
||||||
'locationNames' : locationNames,
|
'parameters': parameters, 'levels': levels, 'envelope': envelope}
|
||||||
'parameters' : parameters,
|
|
||||||
'levels' : levels,
|
|
||||||
'envelope' : envelope
|
|
||||||
}
|
|
||||||
|
|
||||||
req = DataAccessLayer.newDataRequest(**requestArgs)
|
req = DataAccessLayer.newDataRequest(**requestArgs)
|
||||||
response = DataAccessLayer.getGeometryData(req, timeRange)
|
response = DataAccessLayer.getGeometryData(req, timeRange)
|
||||||
|
|
|
@ -28,7 +28,7 @@ The ability to unit convert grid data is not currently available in this version
|
||||||
|
|
||||||
class PyGridData(IGridData, PyData.PyData):
|
class PyGridData(IGridData, PyData.PyData):
|
||||||
|
|
||||||
def __init__(self, gridDataRecord, nx, ny, latLonGrid = None, latLonDelegate = None):
|
def __init__(self, gridDataRecord, nx, ny, latLonGrid=None, latLonDelegate=None):
|
||||||
PyData.PyData.__init__(self, gridDataRecord)
|
PyData.PyData.__init__(self, gridDataRecord)
|
||||||
nx = nx
|
nx = nx
|
||||||
ny = ny
|
ny = ny
|
||||||
|
@ -38,7 +38,6 @@ class PyGridData(IGridData, PyData.PyData):
|
||||||
self.__latLonGrid = latLonGrid
|
self.__latLonGrid = latLonGrid
|
||||||
self.__latLonDelegate = latLonDelegate
|
self.__latLonDelegate = latLonDelegate
|
||||||
|
|
||||||
|
|
||||||
def getParameter(self):
|
def getParameter(self):
|
||||||
return self.__parameter
|
return self.__parameter
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ class PyGridNotification(PyNotification):
|
||||||
newReq.setParameters(self.request.getParameters())
|
newReq.setParameters(self.request.getParameters())
|
||||||
data = self.getData(newReq, [])
|
data = self.getData(newReq, [])
|
||||||
self.callback(data)
|
self.callback(data)
|
||||||
except Exception:
|
except ValueError:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
def getData(self, request, dataTimes):
|
def getData(self, request, dataTimes):
|
||||||
|
|
|
@ -224,7 +224,8 @@ class ThriftClientRouter(object):
|
||||||
return [x.decode('utf-8') for x in response]
|
return [x.decode('utf-8') for x in response]
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def newDataRequest(self, datatype, parameters=[], levels=[], locationNames=[], envelope=None, **kwargs):
|
def newDataRequest(self, datatype, parameters=[], levels=[], locationNames=[],
|
||||||
|
envelope=None, **kwargs):
|
||||||
req = DefaultDataRequest()
|
req = DefaultDataRequest()
|
||||||
if datatype:
|
if datatype:
|
||||||
req.setDatatype(datatype)
|
req.setDatatype(datatype)
|
||||||
|
|
|
@ -91,7 +91,7 @@ class IFPClient(object):
|
||||||
sr.setPayload(inventoryList)
|
sr.setPayload(inventoryList)
|
||||||
return sr
|
return sr
|
||||||
elif self.__isHomogenousIterable(parmID, ParmID):
|
elif self.__isHomogenousIterable(parmID, ParmID):
|
||||||
return self.__getGridInventory([id for id in parmID])
|
return self.__getGridInventory([pid for pid in parmID])
|
||||||
raise TypeError("Invalid type: " + str(type(parmID)) +
|
raise TypeError("Invalid type: " + str(type(parmID)) +
|
||||||
" specified to getGridInventory(). Accepts ParmID or lists of ParmID.")
|
" specified to getGridInventory(). Accepts ParmID or lists of ParmID.")
|
||||||
|
|
||||||
|
|
|
@ -77,12 +77,13 @@ QPID_PASSWORD = 'guest'
|
||||||
|
|
||||||
class IngestViaQPID:
|
class IngestViaQPID:
|
||||||
def __init__(self, host='localhost', port=5672, ssl=None):
|
def __init__(self, host='localhost', port=5672, ssl=None):
|
||||||
'''
|
"""
|
||||||
Connect to QPID and make bindings to route message to external.dropbox queue
|
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 host: string hostname of computer running EDEX and QPID (default localhost)
|
||||||
@param port: integer port used to connect to QPID (default 5672)
|
@param port: integer port used to connect to QPID (default 5672)
|
||||||
@param ssl: boolean to determine whether ssl is used, default value of None will use ssl only if a client certificate is found.
|
@param ssl: boolean to determine whether ssl is used, default value of None will use
|
||||||
'''
|
ssl only if a client certificate is found.
|
||||||
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
#
|
#
|
||||||
|
@ -100,31 +101,31 @@ class IngestViaQPID:
|
||||||
keyfile = os.path.join(certdb, certname + ".key")
|
keyfile = os.path.join(certdb, certname + ".key")
|
||||||
trustfile = os.path.join(certdb, "root.crt")
|
trustfile = os.path.join(certdb, "root.crt")
|
||||||
socket = qpid.util.ssl(socket, keyfile=keyfile, certfile=certfile, ca_certs=trustfile)
|
socket = qpid.util.ssl(socket, keyfile=keyfile, certfile=certfile, ca_certs=trustfile)
|
||||||
self.connection = Connection (sock=socket, username=QPID_USERNAME, password=QPID_PASSWORD)
|
self.connection = Connection(sock=socket, username=QPID_USERNAME, password=QPID_PASSWORD)
|
||||||
self.connection.start()
|
self.connection.start()
|
||||||
self.session = self.connection.session(str(uuid4()))
|
self.session = self.connection.session(str(uuid4()))
|
||||||
self.session.exchange_bind(exchange='amq.direct', queue='external.dropbox', binding_key='external.dropbox')
|
self.session.exchange_bind(exchange='amq.direct', queue='external.dropbox', binding_key='external.dropbox')
|
||||||
print('Connected to Qpid')
|
print('Connected to Qpid')
|
||||||
except:
|
except ValueError:
|
||||||
print('Unable to connect to Qpid')
|
print('Unable to connect to Qpid')
|
||||||
|
|
||||||
def sendmessage(self, filepath, header):
|
def sendmessage(self, filepath, header):
|
||||||
'''
|
"""
|
||||||
This function sends a message to the external.dropbox queue providing the path
|
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
|
to the file to be ingested and a header to determine the plugin to be used to
|
||||||
decode the file.
|
decode the file.
|
||||||
@param filepath: string full path to file to be ingested
|
@param filepath: string full path to file to be ingested
|
||||||
@param header: string header used to determine plugin decoder to use
|
@param header: string header used to determine plugin decoder to use
|
||||||
'''
|
"""
|
||||||
props = self.session.delivery_properties(routing_key='external.dropbox')
|
props = self.session.delivery_properties(routing_key='external.dropbox')
|
||||||
head = self.session.message_properties(application_headers={'header':header},
|
head = self.session.message_properties(application_headers={'header': header},
|
||||||
user_id=QPID_USERNAME) # For issue QPID-5569. Fixed in Qpid 0.27
|
user_id=QPID_USERNAME)
|
||||||
self.session.message_transfer(destination='amq.direct', message=Message(props, head, filepath))
|
self.session.message_transfer(destination='amq.direct', message=Message(props, head, filepath))
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
'''
|
"""
|
||||||
After all messages are sent call this function to close connection and make sure
|
After all messages are sent call this function to close connection and make sure
|
||||||
there are no threads left open
|
there are no threads left open
|
||||||
'''
|
"""
|
||||||
self.session.close(timeout=10)
|
self.session.close(timeout=10)
|
||||||
print('Connection to Qpid closed')
|
print('Connection to Qpid closed')
|
||||||
|
|
|
@ -89,11 +89,11 @@ class DafTestCase(unittest.TestCase):
|
||||||
print("Optional identifiers:", optional)
|
print("Optional identifiers:", optional)
|
||||||
|
|
||||||
def runGetIdValuesTest(self, identifiers):
|
def runGetIdValuesTest(self, identifiers):
|
||||||
for id in identifiers:
|
for identifier in identifiers:
|
||||||
if id.lower() == 'datauri':
|
if identifier.lower() == 'datauri':
|
||||||
continue
|
continue
|
||||||
req = DAL.newDataRequest(self.datatype)
|
req = DAL.newDataRequest(self.datatype)
|
||||||
idValues = DAL.getIdentifierValues(req, id)
|
idValues = DAL.getIdentifierValues(req, identifier)
|
||||||
self.assertTrue(hasattr(idValues, '__iter__'))
|
self.assertTrue(hasattr(idValues, '__iter__'))
|
||||||
|
|
||||||
def runInvalidIdValuesTest(self):
|
def runInvalidIdValuesTest(self):
|
||||||
|
@ -145,20 +145,9 @@ class DafTestCase(unittest.TestCase):
|
||||||
times = DafTestCase.getTimesIfSupported(req)
|
times = DafTestCase.getTimesIfSupported(req)
|
||||||
geomData = DAL.getGeometryData(req, times[:self.numTimesToLimit])
|
geomData = DAL.getGeometryData(req, times[:self.numTimesToLimit])
|
||||||
self.assertIsNotNone(geomData)
|
self.assertIsNotNone(geomData)
|
||||||
#if times:
|
|
||||||
# self.assertNotEqual(len(geomData), 0)
|
|
||||||
if not geomData:
|
if not geomData:
|
||||||
raise unittest.SkipTest("No data available")
|
raise unittest.SkipTest("No data available")
|
||||||
print("Number of geometry records: " + str(len(geomData)))
|
print("Number of geometry records: " + str(len(geomData)))
|
||||||
#print("Sample geometry data:")
|
|
||||||
#for record in geomData[:self.sampleDataLimit]:
|
|
||||||
# if (checkDataTimes and times and
|
|
||||||
# "PERIOD_USED" not in record.getDataTime().getUtilityFlags()):
|
|
||||||
# self.assertIn(record.getDataTime(), times[:self.numTimesToLimit])
|
|
||||||
# #print("geometry=" + str(record.getGeometry()), end="")
|
|
||||||
# for p in req.getParameters():
|
|
||||||
# print(" " + p + "=" + str(record.getString(p)), end="")
|
|
||||||
# print()
|
|
||||||
return geomData
|
return geomData
|
||||||
|
|
||||||
def runGeometryDataTestWithTimeRange(self, req, timeRange):
|
def runGeometryDataTestWithTimeRange(self, req, timeRange):
|
||||||
|
@ -171,14 +160,6 @@ class DafTestCase(unittest.TestCase):
|
||||||
if not geomData:
|
if not geomData:
|
||||||
raise unittest.SkipTest("No data available")
|
raise unittest.SkipTest("No data available")
|
||||||
print("Number of geometry records: " + str(len(geomData)))
|
print("Number of geometry records: " + str(len(geomData)))
|
||||||
#print("Sample geometry data:")
|
|
||||||
#for record in geomData[:self.sampleDataLimit]:
|
|
||||||
# self.assertGreaterEqual(record.getDataTime().getRefTime().getTime(), timeRange.getStartInMillis())
|
|
||||||
# self.assertLessEqual(record.getDataTime().getRefTime().getTime(), timeRange.getEndInMillis())
|
|
||||||
# print("geometry=" + str(record.getGeometry()), end="")
|
|
||||||
# for p in req.getParameters():
|
|
||||||
# print(" " + p + "=" + record.getString(p), end="")
|
|
||||||
# print()
|
|
||||||
return geomData
|
return geomData
|
||||||
|
|
||||||
def runGridDataTest(self, req, testSameShape=True):
|
def runGridDataTest(self, req, testSameShape=True):
|
||||||
|
@ -187,6 +168,7 @@ class DafTestCase(unittest.TestCase):
|
||||||
request.
|
request.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
req: the grid request
|
||||||
testSameShape: whether or not to verify that all the retrieved data
|
testSameShape: whether or not to verify that all the retrieved data
|
||||||
have the same shape (most data don't change shape)
|
have the same shape (most data don't change shape)
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -32,8 +32,8 @@ class CombinedTimeQueryTestCase(unittest.TestCase):
|
||||||
def testSuccessfulQuery(self):
|
def testSuccessfulQuery(self):
|
||||||
req = DAL.newDataRequest('grid')
|
req = DAL.newDataRequest('grid')
|
||||||
req.setLocationNames(self.modelName)
|
req.setLocationNames(self.modelName)
|
||||||
req.setParameters('T','GH')
|
req.setParameters('T', 'GH')
|
||||||
req.setLevels('300MB', '500MB','700MB')
|
req.setLevels('300MB', '500MB', '700MB')
|
||||||
times = CTQ.getAvailableTimes(req)
|
times = CTQ.getAvailableTimes(req)
|
||||||
self.assertNotEqual(len(times), 0)
|
self.assertNotEqual(len(times), 0)
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class CombinedTimeQueryTestCase(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
req = DAL.newDataRequest('grid')
|
req = DAL.newDataRequest('grid')
|
||||||
req.setLocationNames(self.modelName)
|
req.setLocationNames(self.modelName)
|
||||||
req.setParameters('T','GH', 'LgSP1hr')
|
req.setParameters('T', 'GH', 'LgSP1hr')
|
||||||
req.setLevels('300MB', '500MB','700MB','0.0SFC')
|
req.setLevels('300MB', '500MB', '700MB', '0.0SFC')
|
||||||
times = CTQ.getAvailableTimes(req)
|
times = CTQ.getAvailableTimes(req)
|
||||||
self.assertEqual(len(times), 0)
|
self.assertEqual(len(times), 0)
|
||||||
|
|
|
@ -78,7 +78,7 @@ class GfeTestCase(baseDafTestCase.DafTestCase):
|
||||||
# Ensure all points are within one degree of the original box
|
# Ensure all points are within one degree of the original box
|
||||||
# to allow slight margin of error for reprojection distortion.
|
# to allow slight margin of error for reprojection distortion.
|
||||||
testEnv = box(params.ENVELOPE.bounds[0] - 1, params.ENVELOPE.bounds[1] - 1,
|
testEnv = box(params.ENVELOPE.bounds[0] - 1, params.ENVELOPE.bounds[1] - 1,
|
||||||
params.ENVELOPE.bounds[2] + 1, params.ENVELOPE.bounds[3] + 1 )
|
params.ENVELOPE.bounds[2] + 1, params.ENVELOPE.bounds[3] + 1)
|
||||||
|
|
||||||
for i in range(len(lons)):
|
for i in range(len(lons)):
|
||||||
self.assertTrue(testEnv.contains(Point(lons[i], lats[i])))
|
self.assertTrue(testEnv.contains(Point(lons[i], lats[i])))
|
||||||
|
@ -89,17 +89,17 @@ class GfeTestCase(baseDafTestCase.DafTestCase):
|
||||||
req.addIdentifier('parmId.dbId.siteId', params.SITE_ID)
|
req.addIdentifier('parmId.dbId.siteId', params.SITE_ID)
|
||||||
req.setParameters('Wind')
|
req.setParameters('Wind')
|
||||||
times = DAL.getAvailableTimes(req)
|
times = DAL.getAvailableTimes(req)
|
||||||
if not(times):
|
if not times:
|
||||||
raise unittest.SkipTest('No Wind Data available for testing')
|
raise unittest.SkipTest('No Wind Data available for testing')
|
||||||
gridData = DAL.getGridData(req, [times[0]])
|
gridData = DAL.getGridData(req, [times[0]])
|
||||||
rawWind = None
|
rawWind = None
|
||||||
rawDir = None
|
rawDir = None
|
||||||
for grid in gridData:
|
for grid in gridData:
|
||||||
if grid.getParameter() == 'Wind':
|
if grid.getParameter() == 'Wind':
|
||||||
self.assertEqual(grid.getUnit(),'kts')
|
self.assertEqual(grid.getUnit(), 'kts')
|
||||||
rawWind = grid.getRawData()
|
rawWind = grid.getRawData()
|
||||||
elif grid.getParameter() == 'WindDirection':
|
elif grid.getParameter() == 'WindDirection':
|
||||||
self.assertEqual(grid.getUnit(),'deg')
|
self.assertEqual(grid.getUnit(), 'deg')
|
||||||
rawDir = grid.getRawData()
|
rawDir = grid.getRawData()
|
||||||
self.assertIsNotNone(rawWind, 'Wind Magnitude grid is not present')
|
self.assertIsNotNone(rawWind, 'Wind Magnitude grid is not present')
|
||||||
self.assertIsNotNone(rawDir, 'Wind Direction grid is not present')
|
self.assertIsNotNone(rawDir, 'Wind Direction grid is not present')
|
||||||
|
@ -192,4 +192,3 @@ class GfeTestCase(baseDafTestCase.DafTestCase):
|
||||||
def testGetDataWithEmptyInConstraintThrowsException(self):
|
def testGetDataWithEmptyInConstraintThrowsException(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
self._runConstraintTest('parmId.dbId.modelName', 'in', [])
|
self._runConstraintTest('parmId.dbId.modelName', 'in', [])
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,6 @@ class GridTestCase(baseDafTestCase.DafTestCase):
|
||||||
def testGetNonexistentIdentifierValuesThrowsException(self):
|
def testGetNonexistentIdentifierValuesThrowsException(self):
|
||||||
self.runNonexistentIdValuesTest()
|
self.runNonexistentIdValuesTest()
|
||||||
|
|
||||||
|
|
||||||
def testGetDataWithEnvelope(self):
|
def testGetDataWithEnvelope(self):
|
||||||
req = DAL.newDataRequest(self.datatype)
|
req = DAL.newDataRequest(self.datatype)
|
||||||
req.addIdentifier('info.datasetId', self.model)
|
req.addIdentifier('info.datasetId', self.model)
|
||||||
|
@ -103,12 +102,11 @@ class GridTestCase(baseDafTestCase.DafTestCase):
|
||||||
# Ensure all points are within one degree of the original box
|
# Ensure all points are within one degree of the original box
|
||||||
# to allow slight margin of error for reprojection distortion.
|
# to allow slight margin of error for reprojection distortion.
|
||||||
testEnv = box(params.ENVELOPE.bounds[0] - 1, params.ENVELOPE.bounds[1] - 1,
|
testEnv = box(params.ENVELOPE.bounds[0] - 1, params.ENVELOPE.bounds[1] - 1,
|
||||||
params.ENVELOPE.bounds[2] + 1, params.ENVELOPE.bounds[3] + 1 )
|
params.ENVELOPE.bounds[2] + 1, params.ENVELOPE.bounds[3] + 1)
|
||||||
|
|
||||||
for i in range(len(lons)):
|
for i in range(len(lons)):
|
||||||
self.assertTrue(testEnv.contains(Point(lons[i], lats[i])))
|
self.assertTrue(testEnv.contains(Point(lons[i], lats[i])))
|
||||||
|
|
||||||
|
|
||||||
def _runConstraintTest(self, key, operator, value):
|
def _runConstraintTest(self, key, operator, value):
|
||||||
req = DAL.newDataRequest(self.datatype)
|
req = DAL.newDataRequest(self.datatype)
|
||||||
constraint = RequestConstraint.new(operator, value)
|
constraint = RequestConstraint.new(operator, value)
|
||||||
|
|
|
@ -124,7 +124,7 @@ class ModelSoundingTestCase(baseDafTestCase.DafTestCase):
|
||||||
# No numeric tests since no numeric identifiers are available.
|
# No numeric tests since no numeric identifiers are available.
|
||||||
|
|
||||||
def testGetDataWithEqualsNone(self):
|
def testGetDataWithEqualsNone(self):
|
||||||
geometryData = self._runConstraintTest('reportType', '=', None)
|
self._runConstraintTest('reportType', '=', None)
|
||||||
|
|
||||||
def testGetDataWithNotEquals(self):
|
def testGetDataWithNotEquals(self):
|
||||||
geometryData = self._runConstraintTest('reportType', '!=', 'ETA')
|
geometryData = self._runConstraintTest('reportType', '!=', 'ETA')
|
||||||
|
@ -132,19 +132,19 @@ class ModelSoundingTestCase(baseDafTestCase.DafTestCase):
|
||||||
self.assertNotIn('/ETA/', record.getString('dataURI'))
|
self.assertNotIn('/ETA/', record.getString('dataURI'))
|
||||||
|
|
||||||
def testGetDataWithNotEqualsNone(self):
|
def testGetDataWithNotEqualsNone(self):
|
||||||
geometryData = self._runConstraintTest('reportType', '!=', None)
|
self._runConstraintTest('reportType', '!=', None)
|
||||||
|
|
||||||
def testGetDataWithGreaterThan(self):
|
def testGetDataWithGreaterThan(self):
|
||||||
geometryData = self._runConstraintTest('reportType', '>', 'ETA')
|
self._runConstraintTest('reportType', '>', 'ETA')
|
||||||
|
|
||||||
def testGetDataWithLessThan(self):
|
def testGetDataWithLessThan(self):
|
||||||
geometryData = self._runConstraintTest('reportType', '<', 'ETA')
|
self._runConstraintTest('reportType', '<', 'ETA')
|
||||||
|
|
||||||
def testGetDataWithGreaterThanEquals(self):
|
def testGetDataWithGreaterThanEquals(self):
|
||||||
geometryData = self._runConstraintTest('reportType', '>=', 'ETA')
|
self._runConstraintTest('reportType', '>=', 'ETA')
|
||||||
|
|
||||||
def testGetDataWithLessThanEquals(self):
|
def testGetDataWithLessThanEquals(self):
|
||||||
geometryData = self._runConstraintTest('reportType', '<=', 'ETA')
|
self._runConstraintTest('reportType', '<=', 'ETA')
|
||||||
|
|
||||||
def testGetDataWithInTuple(self):
|
def testGetDataWithInTuple(self):
|
||||||
collection = ('ETA', 'GFS')
|
collection = ('ETA', 'GFS')
|
||||||
|
|
|
@ -25,6 +25,7 @@ from dynamicserialize.dstypes.com.raytheon.uf.common.dataquery.requests import R
|
||||||
from awips.test.dafTests import baseDafTestCase
|
from awips.test.dafTests import baseDafTestCase
|
||||||
from awips.test.dafTests import params
|
from awips.test.dafTests import params
|
||||||
|
|
||||||
|
|
||||||
class RadarSpatialTestCase(baseDafTestCase.DafTestCase):
|
class RadarSpatialTestCase(baseDafTestCase.DafTestCase):
|
||||||
"""Test DAF support for radar_spatial data"""
|
"""Test DAF support for radar_spatial data"""
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ class TopoTestCase(baseDafTestCase.DafTestCase):
|
||||||
print("Sample grid data shape:\n" + str(gridData[0].getRawData().shape) + "\n")
|
print("Sample grid data shape:\n" + str(gridData[0].getRawData().shape) + "\n")
|
||||||
print("Sample grid data:\n" + str(gridData[0].getRawData()) + "\n")
|
print("Sample grid data:\n" + str(gridData[0].getRawData()) + "\n")
|
||||||
|
|
||||||
|
|
||||||
def testRequestingTooMuchDataThrowsResponseTooLargeException(self):
|
def testRequestingTooMuchDataThrowsResponseTooLargeException(self):
|
||||||
req = DAL.newDataRequest(self.datatype)
|
req = DAL.newDataRequest(self.datatype)
|
||||||
req.addIdentifier("group", "/")
|
req.addIdentifier("group", "/")
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
|
|
||||||
from thrift.protocol.TProtocol import *
|
from thrift.protocol.TProtocol import *
|
||||||
from thrift.protocol.TBinaryProtocol import *
|
from thrift.protocol.TBinaryProtocol import *
|
||||||
import struct, numpy
|
import struct
|
||||||
|
import numpy
|
||||||
|
|
||||||
FLOAT = 64
|
FLOAT = 64
|
||||||
|
|
||||||
|
@ -28,86 +29,86 @@ doubleList = numpy.dtype(numpy.float64).newbyteorder('>')
|
||||||
|
|
||||||
class SelfDescribingBinaryProtocol(TBinaryProtocol):
|
class SelfDescribingBinaryProtocol(TBinaryProtocol):
|
||||||
|
|
||||||
def readFieldBegin(self):
|
def readFieldBegin(self):
|
||||||
ftype = self.readByte()
|
ftype = self.readByte()
|
||||||
if ftype == TType.STOP:
|
if ftype == TType.STOP:
|
||||||
return (None, ftype, 0)
|
return None, ftype, 0
|
||||||
name = self.readString()
|
name = self.readString()
|
||||||
fid = self.readI16()
|
fid = self.readI16()
|
||||||
return (name, ftype, fid)
|
return name, ftype, fid
|
||||||
|
|
||||||
def readStructBegin(self):
|
def readStructBegin(self):
|
||||||
return self.readString()
|
return self.readString()
|
||||||
|
|
||||||
def writeStructBegin(self, name):
|
def writeStructBegin(self, name):
|
||||||
self.writeString(name)
|
self.writeString(name)
|
||||||
|
|
||||||
def writeFieldBegin(self, name, ftype, fid):
|
def writeFieldBegin(self, name, ftype, fid):
|
||||||
self.writeByte(ftype)
|
self.writeByte(ftype)
|
||||||
self.writeString(name)
|
self.writeString(name)
|
||||||
self.writeI16(fid)
|
self.writeI16(fid)
|
||||||
|
|
||||||
def readFloat(self):
|
def readFloat(self):
|
||||||
d = self.readI32()
|
d = self.readI32()
|
||||||
dAsBytes = struct.pack('i', d)
|
dAsBytes = struct.pack('i', d)
|
||||||
f = struct.unpack('f', dAsBytes)
|
f = struct.unpack('f', dAsBytes)
|
||||||
return f[0]
|
return f[0]
|
||||||
|
|
||||||
def writeFloat(self, f):
|
def writeFloat(self, f):
|
||||||
dAsBytes = struct.pack('f', f)
|
dAsBytes = struct.pack('f', f)
|
||||||
i = struct.unpack('i', dAsBytes)
|
i = struct.unpack('i', dAsBytes)
|
||||||
self.writeI32(i[0])
|
self.writeI32(i[0])
|
||||||
|
|
||||||
def readI32List(self, sz):
|
def readI32List(self, sz):
|
||||||
buff = self.trans.readAll(4*sz)
|
buff = self.trans.readAll(4*sz)
|
||||||
val = numpy.frombuffer(buff, dtype=intList, count=sz)
|
val = numpy.frombuffer(buff, dtype=intList, count=sz)
|
||||||
return val
|
return val
|
||||||
|
|
||||||
def readF32List(self, sz):
|
def readF32List(self, sz):
|
||||||
buff = self.trans.readAll(4*sz)
|
buff = self.trans.readAll(4*sz)
|
||||||
val = numpy.frombuffer(buff, dtype=floatList, count=sz)
|
val = numpy.frombuffer(buff, dtype=floatList, count=sz)
|
||||||
return val
|
return val
|
||||||
|
|
||||||
def readF64List(self, sz):
|
def readF64List(self, sz):
|
||||||
buff = self.trans.readAll(8*sz)
|
buff = self.trans.readAll(8*sz)
|
||||||
val = numpy.frombuffer(buff, dtype=doubleList, count=sz)
|
val = numpy.frombuffer(buff, dtype=doubleList, count=sz)
|
||||||
return val
|
return val
|
||||||
|
|
||||||
def readI64List(self, sz):
|
def readI64List(self, sz):
|
||||||
buff = self.trans.readAll(8*sz)
|
buff = self.trans.readAll(8*sz)
|
||||||
val = numpy.frombuffer(buff, dtype=longList, count=sz)
|
val = numpy.frombuffer(buff, dtype=longList, count=sz)
|
||||||
return val
|
return val
|
||||||
|
|
||||||
def readI16List(self, sz):
|
def readI16List(self, sz):
|
||||||
buff = self.trans.readAll(2*sz)
|
buff = self.trans.readAll(2*sz)
|
||||||
val = numpy.frombuffer(buff, dtype=shortList, count=sz)
|
val = numpy.frombuffer(buff, dtype=shortList, count=sz)
|
||||||
return val
|
return val
|
||||||
|
|
||||||
def readI8List(self, sz):
|
def readI8List(self, sz):
|
||||||
buff = self.trans.readAll(sz)
|
buff = self.trans.readAll(sz)
|
||||||
val = numpy.frombuffer(buff, dtype=byteList, count=sz)
|
val = numpy.frombuffer(buff, dtype=byteList, count=sz)
|
||||||
return val
|
return val
|
||||||
|
|
||||||
def writeI32List(self, buff):
|
def writeI32List(self, buff):
|
||||||
b = numpy.asarray(buff, intList)
|
b = numpy.asarray(buff, intList)
|
||||||
self.trans.write(numpy.getbuffer(b))
|
self.trans.write(numpy.getbuffer(b))
|
||||||
|
|
||||||
def writeF32List(self, buff):
|
def writeF32List(self, buff):
|
||||||
b = numpy.asarray(buff, floatList)
|
b = numpy.asarray(buff, floatList)
|
||||||
self.trans.write(numpy.getbuffer(b))
|
self.trans.write(numpy.getbuffer(b))
|
||||||
|
|
||||||
def writeF64List(self, buff):
|
def writeF64List(self, buff):
|
||||||
b = numpy.asarray(buff, doubleList)
|
b = numpy.asarray(buff, doubleList)
|
||||||
self.trans.write(numpy.getbuffer(b))
|
self.trans.write(numpy.getbuffer(b))
|
||||||
|
|
||||||
def writeI64List(self, buff):
|
def writeI64List(self, buff):
|
||||||
b = numpy.asarray(buff, longList)
|
b = numpy.asarray(buff, longList)
|
||||||
self.trans.write(numpy.getbuffer(b))
|
self.trans.write(numpy.getbuffer(b))
|
||||||
|
|
||||||
def writeI16List(self, buff):
|
def writeI16List(self, buff):
|
||||||
b = numpy.asarray(buff, shortList)
|
b = numpy.asarray(buff, shortList)
|
||||||
self.trans.write(numpy.getbuffer(b))
|
self.trans.write(numpy.getbuffer(b))
|
||||||
|
|
||||||
def writeI8List(self, buff):
|
def writeI8List(self, buff):
|
||||||
b = numpy.asarray(buff, byteList)
|
b = numpy.asarray(buff, byteList)
|
||||||
self.trans.write(numpy.getbuffer(b))
|
self.trans.write(numpy.getbuffer(b))
|
||||||
|
|
|
@ -49,6 +49,7 @@ def buildObjMap(module):
|
||||||
tname = tname[DS_LEN:]
|
tname = tname[DS_LEN:]
|
||||||
dsObjTypes[tname] = clz
|
dsObjTypes[tname] = clz
|
||||||
|
|
||||||
|
|
||||||
buildObjMap(dstypes)
|
buildObjMap(dstypes)
|
||||||
|
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
|
@ -211,7 +212,7 @@ class ThriftSerializationContext(object):
|
||||||
try:
|
try:
|
||||||
setMethod = getattr(obj, lookingFor)
|
setMethod = getattr(obj, lookingFor)
|
||||||
setMethod(result)
|
setMethod(result)
|
||||||
except:
|
except ValueError:
|
||||||
raise dynamicserialize.SerializationException(
|
raise dynamicserialize.SerializationException(
|
||||||
"Couldn't find setter method " + lookingFor)
|
"Couldn't find setter method " + lookingFor)
|
||||||
|
|
||||||
|
@ -254,7 +255,7 @@ class ThriftSerializationContext(object):
|
||||||
pyt = type(obj)
|
pyt = type(obj)
|
||||||
if pyt in pythonToThriftMap:
|
if pyt in pythonToThriftMap:
|
||||||
return pythonToThriftMap[pyt]
|
return pythonToThriftMap[pyt]
|
||||||
elif pyt.__module__[:DS_LEN - 1] == ('dynamicserialize.dstypes'):
|
elif pyt.__module__[:DS_LEN - 1] == 'dynamicserialize.dstypes':
|
||||||
return pythonToThriftMap[object]
|
return pythonToThriftMap[object]
|
||||||
raise dynamicserialize.SerializationException(
|
raise dynamicserialize.SerializationException(
|
||||||
"Don't know how to serialize object of type: " + str(pyt))
|
"Don't know how to serialize object of type: " + str(pyt))
|
||||||
|
@ -284,7 +285,6 @@ class ThriftSerializationContext(object):
|
||||||
val = m[1]()
|
val = m[1]()
|
||||||
ft = self._lookupType(val)
|
ft = self._lookupType(val)
|
||||||
if ft == TType.STRUCT:
|
if ft == TType.STRUCT:
|
||||||
fc = val.__module__[DS_LEN:]
|
|
||||||
self._serializeField(fieldname, ft, fid, val)
|
self._serializeField(fieldname, ft, fid, val)
|
||||||
else:
|
else:
|
||||||
self._serializeField(fieldname, ft, fid, val)
|
self._serializeField(fieldname, ft, fid, val)
|
||||||
|
|
|
@ -59,7 +59,7 @@ def deserialize(context):
|
||||||
|
|
||||||
geoData = []
|
geoData = []
|
||||||
size = context.readI32()
|
size = context.readI32()
|
||||||
for __ in range(size):
|
for _ in range(size):
|
||||||
data = GeometryResponseData()
|
data = GeometryResponseData()
|
||||||
# wkb index
|
# wkb index
|
||||||
wkbIndex = context.readI32()
|
wkbIndex = context.readI32()
|
||||||
|
|
|
@ -26,7 +26,7 @@ def serialize(context, timeRange):
|
||||||
|
|
||||||
def deserialize(context):
|
def deserialize(context):
|
||||||
startTime = context.readI64()
|
startTime = context.readI64()
|
||||||
endTime = context.readI64()
|
endTime = context.readI64()
|
||||||
|
|
||||||
timeRange = TimeRange()
|
timeRange = TimeRange()
|
||||||
# java uses milliseconds, python uses microseconds
|
# java uses milliseconds, python uses microseconds
|
||||||
|
|
|
@ -92,7 +92,7 @@ def registerAdapters(package, modules):
|
||||||
clzName = m.ClassAdapter
|
clzName = m.ClassAdapter
|
||||||
classAdapterRegistry[clzName] = m
|
classAdapterRegistry[clzName] = m
|
||||||
else:
|
else:
|
||||||
raise LookupError('Adapter class ' + x + ' has no ClassAdapter field ' + \
|
raise LookupError('Adapter class ' + x + ' has no ClassAdapter field ' +
|
||||||
'and cannot be registered.')
|
'and cannot be registered.')
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,5 +3,3 @@ __all__ = [
|
||||||
'raytheon',
|
'raytheon',
|
||||||
'vividsolutions'
|
'vividsolutions'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,3 @@
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'uf'
|
'uf'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,3 @@
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'common'
|
'common'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,5 +15,3 @@ __all__ = [
|
||||||
'site',
|
'site',
|
||||||
'time'
|
'time'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,11 @@ class AlertVizRequest(object):
|
||||||
|
|
||||||
def setFilters(self, filters):
|
def setFilters(self, filters):
|
||||||
if filters is None:
|
if filters is None:
|
||||||
self.filters = {}
|
self.filters = {}
|
||||||
elif not(None in filters or filters.values().count(None)>0 or '' in filters or filters.values().count('')>0):
|
elif not(None in filters
|
||||||
self.filters = filters
|
or filters.values().count(None) > 0
|
||||||
|
or '' in filters
|
||||||
|
or filters.values().count('') > 0):
|
||||||
|
self.filters = filters
|
||||||
else:
|
else:
|
||||||
raise ValueError('Filters must not contain None or empty keys or values: %s' % filters)
|
raise ValueError('Filters must not contain None or empty keys or values: %s' % filters)
|
||||||
|
|
|
@ -3,5 +3,3 @@ __all__ = [
|
||||||
'resp',
|
'resp',
|
||||||
'user'
|
'user'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,4 +12,3 @@ class AbstractFailedResponse(with_metaclass(abc.ABCMeta, object)):
|
||||||
|
|
||||||
def setRequest(self, request):
|
def setRequest(self, request):
|
||||||
self.request = request
|
self.request = request
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
# nothing to implement here that isn't already covered by ServerErrorResponse
|
||||||
|
# Just need the separate class for de-serialization.
|
||||||
|
|
||||||
from dynamicserialize.dstypes.com.raytheon.uf.common.serialization.comm.response import ServerErrorResponse
|
from dynamicserialize.dstypes.com.raytheon.uf.common.serialization.comm.response import ServerErrorResponse
|
||||||
|
|
||||||
|
@ -6,7 +8,3 @@ class AuthServerErrorResponse(ServerErrorResponse):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(AuthServerErrorResponse, self).__init__()
|
super(AuthServerErrorResponse, self).__init__()
|
||||||
|
|
||||||
## nothing to implement here that isn't already covered by ServerErrorResponse ##
|
|
||||||
## Just need the separate class for de-serialization. ##
|
|
||||||
|
|
||||||
|
|
|
@ -17,4 +17,3 @@ class SuccessfulExecution(object):
|
||||||
|
|
||||||
def setUpdatedData(self, updatedData):
|
def setUpdatedData(self, updatedData):
|
||||||
self.updatedData = updatedData
|
self.updatedData = updatedData
|
||||||
|
|
||||||
|
|
|
@ -10,4 +10,3 @@ from .AbstractFailedResponse import AbstractFailedResponse
|
||||||
from .AuthServerErrorResponse import AuthServerErrorResponse
|
from .AuthServerErrorResponse import AuthServerErrorResponse
|
||||||
from .SuccessfulExecution import SuccessfulExecution
|
from .SuccessfulExecution import SuccessfulExecution
|
||||||
from .UserNotAuthorized import UserNotAuthorized
|
from .UserNotAuthorized import UserNotAuthorized
|
||||||
|
|
||||||
|
|
|
@ -21,4 +21,3 @@ class User(object):
|
||||||
|
|
||||||
def setAuthenticationData(self, authenticationData):
|
def setAuthenticationData(self, authenticationData):
|
||||||
self.authenticationData = authenticationData
|
self.authenticationData = authenticationData
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ except ImportError:
|
||||||
|
|
||||||
class UserId(object):
|
class UserId(object):
|
||||||
|
|
||||||
def __init__(self, userid = None):
|
def __init__(self, userid=None):
|
||||||
if userid is None:
|
if userid is None:
|
||||||
if not pwd_error:
|
if not pwd_error:
|
||||||
self.id = pwd.getpwuid(os.getuid()).pw_name
|
self.id = pwd.getpwuid(os.getuid()).pw_name
|
||||||
|
|
|
@ -4,5 +4,3 @@ __all__ = [
|
||||||
'request',
|
'request',
|
||||||
'response'
|
'response'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,6 @@ class DefaultDataRequest(IDataRequest):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
fmt = ('DefaultDataRequest(datatype={}, identifiers={}, parameters={}, ' +
|
fmt = ('DefaultDataRequest(datatype={}, identifiers={}, parameters={}, ' +
|
||||||
'levels={}, locationNames={}, envelope={})')
|
'levels={}, locationNames={}, envelope={})')
|
||||||
return fmt.format(self.datatype, self.identifiers, self.parameters, self.levels,
|
return fmt.format(self.datatype, self.identifiers, self.parameters, self.levels,
|
||||||
self.locationNames, self.envelope)
|
self.locationNames, self.envelope)
|
||||||
|
|
|
@ -14,4 +14,3 @@ class GetAvailableLocationNamesRequest(AbstractDataAccessRequest):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(GetAvailableLocationNamesRequest, self).__init__()
|
super(GetAvailableLocationNamesRequest, self).__init__()
|
||||||
|
|
||||||
|
|
|
@ -28,4 +28,3 @@ class GetGeometryDataRequest(AbstractDataAccessRequest):
|
||||||
|
|
||||||
def setRequestedPeriod(self, requestedPeriod):
|
def setRequestedPeriod(self, requestedPeriod):
|
||||||
self.requestedPeriod = requestedPeriod
|
self.requestedPeriod = requestedPeriod
|
||||||
|
|
||||||
|
|
|
@ -35,4 +35,4 @@ class GetGridDataRequest(AbstractDataAccessRequest):
|
||||||
return self.includeLatLonData
|
return self.includeLatLonData
|
||||||
|
|
||||||
def setIncludeLatLonData(self, includeLatLonData):
|
def setIncludeLatLonData(self, includeLatLonData):
|
||||||
self.includeLatLonData = includeLatLonData
|
self.includeLatLonData = includeLatLonData
|
||||||
|
|
|
@ -15,4 +15,3 @@ class GetOptionalIdentifiersRequest(AbstractIdentifierRequest):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(GetOptionalIdentifiersRequest, self).__init__()
|
super(GetOptionalIdentifiersRequest, self).__init__()
|
||||||
|
|
||||||
|
|
|
@ -12,4 +12,3 @@ class GetSupportedDatatypesRequest(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -17,4 +17,3 @@ class GetGeometryDataResponse(object):
|
||||||
|
|
||||||
def setGeoData(self, geoData):
|
def setGeoData(self, geoData):
|
||||||
self.geoData = geoData
|
self.geoData = geoData
|
||||||
|
|
||||||
|
|
|
@ -52,4 +52,3 @@ class GetGridDataResponse(object):
|
||||||
|
|
||||||
def setSiteCrsWkt(self, siteCrsWkt):
|
def setSiteCrsWkt(self, siteCrsWkt):
|
||||||
self.siteCrsWkt = siteCrsWkt
|
self.siteCrsWkt = siteCrsWkt
|
||||||
|
|
||||||
|
|
|
@ -37,4 +37,3 @@ class GetGridLatLonResponse(object):
|
||||||
|
|
||||||
def setNy(self, ny):
|
def setNy(self, ny):
|
||||||
self.ny = ny
|
self.ny = ny
|
||||||
|
|
||||||
|
|
|
@ -8,5 +8,3 @@ __all__ = [
|
||||||
'radar',
|
'radar',
|
||||||
'text'
|
'text'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,3 @@
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'hazards'
|
'hazards'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,3 @@
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'requests'
|
'requests'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,4 +23,3 @@ class RegionLookupRequest(object):
|
||||||
|
|
||||||
def setSite(self, site):
|
def setSite(self, site):
|
||||||
self.site = site
|
self.site = site
|
||||||
|
|
||||||
|
|
|
@ -4,4 +4,3 @@ __all__ = [
|
||||||
]
|
]
|
||||||
|
|
||||||
from .RegionLookupRequest import RegionLookupRequest
|
from .RegionLookupRequest import RegionLookupRequest
|
||||||
|
|
||||||
|
|
|
@ -73,4 +73,3 @@ class GridDataHistory(object):
|
||||||
|
|
||||||
def setLastSentTime(self, lastSentTime):
|
def setLastSentTime(self, lastSentTime):
|
||||||
self.lastSentTime = lastSentTime
|
self.lastSentTime = lastSentTime
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
# 06/22/2015 4573 randerso Added svcbu package
|
# 06/22/2015 4573 randerso Added svcbu package
|
||||||
# 10/06/2015 mjames@ucar Removed svcbu package
|
# 10/06/2015 mjames@ucar Removed svcbu package
|
||||||
#
|
#
|
||||||
#
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'config',
|
'config',
|
||||||
|
@ -21,4 +20,3 @@ __all__ = [
|
||||||
]
|
]
|
||||||
|
|
||||||
from .GridDataHistory import GridDataHistory
|
from .GridDataHistory import GridDataHistory
|
||||||
|
|
||||||
|
|
|
@ -93,4 +93,3 @@ class ProjectionData(object):
|
||||||
'latLonOrigin', 'stdParallelOne', 'stdParallelTwo',
|
'latLonOrigin', 'stdParallelOne', 'stdParallelTwo',
|
||||||
'gridPointLL', 'gridPointUR', 'latIntersect', 'lonCenter',
|
'gridPointLL', 'gridPointUR', 'latIntersect', 'lonCenter',
|
||||||
'lonOrigin']
|
'lonOrigin']
|
||||||
|
|
||||||
|
|
|
@ -4,4 +4,3 @@ __all__ = [
|
||||||
]
|
]
|
||||||
|
|
||||||
from .ProjectionData import ProjectionData
|
from .ProjectionData import ProjectionData
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,3 @@
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'objects'
|
'objects'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -113,11 +113,11 @@ class DatabaseID(object):
|
||||||
self.modelName = strings[3]
|
self.modelName = strings[3]
|
||||||
|
|
||||||
# date-time group
|
# date-time group
|
||||||
if (len(strings[4]) != 8 or len(strings[5]) != 4):
|
if len(strings[4]) != 8 or len(strings[5]) != 4:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# make sure the digits are there
|
# make sure the digits are there
|
||||||
dtg = strings[4] + '_' + strings[5] # back together
|
dtg = strings[4] + '_' + strings[5] # back together
|
||||||
if dtg != "00000000_0000":
|
if dtg != "00000000_0000":
|
||||||
if not self.__decodeDtg(dtg):
|
if not self.__decodeDtg(dtg):
|
||||||
return False
|
return False
|
||||||
|
@ -130,14 +130,14 @@ class DatabaseID(object):
|
||||||
try:
|
try:
|
||||||
dateStruct = time.strptime(dtgString, "%Y%m%d_%H%M")
|
dateStruct = time.strptime(dtgString, "%Y%m%d_%H%M")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return (False, dateStruct)
|
return False, dateStruct
|
||||||
return (True, dateStruct)
|
return True, dateStruct
|
||||||
|
|
||||||
def __decodeDtg(self, dtgString):
|
def __decodeDtg(self, dtgString):
|
||||||
try:
|
try:
|
||||||
time.strptime(dtgString, "%Y%m%d_%H%M")
|
time.strptime(dtgString, "%Y%m%d_%H%M")
|
||||||
self.modelTime = dtgString
|
self.modelTime = dtgString
|
||||||
except:
|
except ValueError:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ class DatabaseID(object):
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if not isinstance(other, DatabaseID):
|
if not isinstance(other, DatabaseID):
|
||||||
return False
|
return False
|
||||||
return (str(self) == str(other))
|
return str(self) == str(other)
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
return (not self.__eq__(other))
|
return not self.__eq__(other)
|
||||||
|
|
|
@ -90,4 +90,3 @@ class GFERecord(object):
|
||||||
|
|
||||||
def setIdentifier(self, identifier):
|
def setIdentifier(self, identifier):
|
||||||
self.identifier = identifier
|
self.identifier = identifier
|
||||||
|
|
||||||
|
|
|
@ -18,11 +18,10 @@ class GridLocation(object):
|
||||||
return self.__repr__()
|
return self.__repr__()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
|
# TODO: Handle geometry in dynamicserialize
|
||||||
|
# ,loc=" + this.geometry.getGeometryType()
|
||||||
s = "[SiteID =" + self.siteId + ",ProjID=" + self.projection.getProjectionID() +\
|
s = "[SiteID =" + self.siteId + ",ProjID=" + self.projection.getProjectionID() +\
|
||||||
",gridSize=(" + str(self.nx) + ',' + str(self.ny) + ")"
|
",gridSize=(" + str(self.nx) + ',' + str(self.ny) + ")]"
|
||||||
# TODO: Handle geometry in dynamicserialize
|
|
||||||
# ,loc=" + this.geometry.getGeometryType()
|
|
||||||
s += ']'
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
|
@ -43,7 +42,7 @@ class GridLocation(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
return (not self.__eq__(other))
|
return not self.__eq__(other)
|
||||||
|
|
||||||
def getSiteId(self):
|
def getSiteId(self):
|
||||||
return self.siteId
|
return self.siteId
|
||||||
|
@ -113,4 +112,3 @@ class GridLocation(object):
|
||||||
if self.origin is None or self.extent is None:
|
if self.origin is None or self.extent is None:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ class GridParmInfo(object):
|
||||||
return self.__repr__()
|
return self.__repr__()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
out = ""
|
|
||||||
if self.isValid():
|
if self.isValid():
|
||||||
out = "ParmID: " + str(self.parmID) + \
|
out = "ParmID: " + str(self.parmID) + \
|
||||||
" TimeConstraints: " + str(self.timeConstraints) + \
|
" TimeConstraints: " + str(self.timeConstraints) + \
|
||||||
|
@ -42,9 +41,9 @@ class GridParmInfo(object):
|
||||||
" TimeIndependent: " + str(self.timeIndependentParm) + \
|
" TimeIndependent: " + str(self.timeIndependentParm) + \
|
||||||
" RateParm: " + str(self.rateParm) + \
|
" RateParm: " + str(self.rateParm) + \
|
||||||
" GridType: " + self.gridType
|
" GridType: " + self.gridType
|
||||||
|
return out
|
||||||
else:
|
else:
|
||||||
out = "<Invalid>"
|
return "<Invalid>"
|
||||||
return out
|
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if not isinstance(other, GridParmInfo):
|
if not isinstance(other, GridParmInfo):
|
||||||
|
@ -88,8 +87,8 @@ class GridParmInfo(object):
|
||||||
status.append("GridParmInfo.GridLocation is not valid")
|
status.append("GridParmInfo.GridLocation is not valid")
|
||||||
if self.timeIndependentParm and self.timeConstraints.anyConstraints():
|
if self.timeIndependentParm and self.timeConstraints.anyConstraints():
|
||||||
status.append("GridParmInfo is invalid. There are time constraints" +
|
status.append("GridParmInfo is invalid. There are time constraints" +
|
||||||
" for a time independent parm. Constraints: " +
|
" for a time independent parm. Constraints: " +
|
||||||
str(self.timeConstraints))
|
str(self.timeConstraints))
|
||||||
if not self.unitString:
|
if not self.unitString:
|
||||||
status.append("GridParmInfo.Units are not defined.")
|
status.append("GridParmInfo.Units are not defined.")
|
||||||
if self.precision < -2 or self.precision > 5:
|
if self.precision < -2 or self.precision > 5:
|
||||||
|
@ -99,7 +98,7 @@ class GridParmInfo(object):
|
||||||
retVal = True
|
retVal = True
|
||||||
if status:
|
if status:
|
||||||
retVal = False
|
retVal = False
|
||||||
return (retVal, status)
|
return retVal, status
|
||||||
|
|
||||||
def isValid(self):
|
def isValid(self):
|
||||||
(valid, errors) = self.__validCheck()
|
(valid, errors) = self.__validCheck()
|
||||||
|
|
|
@ -56,7 +56,7 @@ class ParmID(object):
|
||||||
parts = parmIdentifier.split(":")
|
parts = parmIdentifier.split(":")
|
||||||
nameLevel = parts[0].split("_")
|
nameLevel = parts[0].split("_")
|
||||||
self.dbId = DatabaseID(parts[1])
|
self.dbId = DatabaseID(parts[1])
|
||||||
if (len(nameLevel) == 2):
|
if len(nameLevel) == 2:
|
||||||
self.parmName = nameLevel[0]
|
self.parmName = nameLevel[0]
|
||||||
self.parmLevel = nameLevel[1]
|
self.parmLevel = nameLevel[1]
|
||||||
else:
|
else:
|
||||||
|
@ -89,9 +89,9 @@ class ParmID(object):
|
||||||
def parmNameAndLevel(composite):
|
def parmNameAndLevel(composite):
|
||||||
pos = composite.find('_')
|
pos = composite.find('_')
|
||||||
if pos != -1:
|
if pos != -1:
|
||||||
return (composite[:pos], composite[pos+1:])
|
return composite[:pos], composite[pos+1:]
|
||||||
else:
|
else:
|
||||||
return (composite, "SFC")
|
return composite, "SFC"
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.__repr__()
|
return self.__repr__()
|
||||||
|
@ -128,4 +128,4 @@ class ParmID(object):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
return (not self.__eq__(other))
|
return not self.__eq__(other)
|
||||||
|
|
|
@ -57,13 +57,13 @@ class TimeConstraints(object):
|
||||||
return False
|
return False
|
||||||
if self.repeatInterval != other.repeatInterval:
|
if self.repeatInterval != other.repeatInterval:
|
||||||
return False
|
return False
|
||||||
return (self.startTime == other.startTime)
|
return self.startTime == other.startTime
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
return (not self.__eq__(other))
|
return not self.__eq__(other)
|
||||||
|
|
||||||
def anyConstraints(self):
|
def anyConstraints(self):
|
||||||
return (self.duration != 0)
|
return self.duration != 0
|
||||||
|
|
||||||
def isValid(self):
|
def isValid(self):
|
||||||
return self.valid
|
return self.valid
|
||||||
|
|
|
@ -14,4 +14,3 @@ from .GridLocation import GridLocation
|
||||||
from .GridParmInfo import GridParmInfo
|
from .GridParmInfo import GridParmInfo
|
||||||
from .ParmID import ParmID
|
from .ParmID import ParmID
|
||||||
from .TimeConstraints import TimeConstraints
|
from .TimeConstraints import TimeConstraints
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
## NOTE: Because the pure python dynamicserialize code does not
|
# NOTE: Because the pure python dynamicserialize code does not
|
||||||
# have a means of accessing the DiscreteDefinition, this class
|
# have a means of accessing the DiscreteDefinition, this class
|
||||||
# is only really useful as a container for deserialized data
|
# is only really useful as a container for deserialized data
|
||||||
# from EDEX. I would not recommend trying to use it for anything
|
# from EDEX. I would not recommend trying to use it for anything
|
||||||
|
@ -24,7 +24,7 @@ class DiscreteKey(object):
|
||||||
def __getitem__(self, key):
|
def __getitem__(self, key):
|
||||||
try:
|
try:
|
||||||
index = int(key)
|
index = int(key)
|
||||||
except:
|
except TypeError:
|
||||||
raise TypeError("list indices must be integers, not " + str(type(key)))
|
raise TypeError("list indices must be integers, not " + str(type(key)))
|
||||||
if index < 0 or index > len(self.subKeys):
|
if index < 0 or index > len(self.subKeys):
|
||||||
raise IndexError("index out of range")
|
raise IndexError("index out of range")
|
||||||
|
@ -48,7 +48,7 @@ class DiscreteKey(object):
|
||||||
return self.subKeys == other.subKeys
|
return self.subKeys == other.subKeys
|
||||||
|
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
return (not self.__eq__(other))
|
return not self.__eq__(other)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def auxData(subkey):
|
def auxData(subkey):
|
||||||
|
@ -83,4 +83,3 @@ class DiscreteKey(object):
|
||||||
|
|
||||||
def setParmID(self, parmID):
|
def setParmID(self, parmID):
|
||||||
self.parmID = parmID
|
self.parmID = parmID
|
||||||
|
|
||||||
|
|
|
@ -4,4 +4,3 @@ __all__ = [
|
||||||
]
|
]
|
||||||
|
|
||||||
from .DiscreteKey import DiscreteKey
|
from .DiscreteKey import DiscreteKey
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ class Grid2DByte(object):
|
||||||
def getBuffer(self):
|
def getBuffer(self):
|
||||||
return self.buffer
|
return self.buffer
|
||||||
|
|
||||||
def setBuffer(self, buffer):
|
def setBuffer(self, bytebuffer):
|
||||||
self.buffer = buffer
|
self.buffer = bytebuffer
|
||||||
|
|
||||||
def getXdim(self):
|
def getXdim(self):
|
||||||
return self.xdim
|
return self.xdim
|
||||||
|
@ -28,4 +28,3 @@ class Grid2DByte(object):
|
||||||
|
|
||||||
def getNumPyGrid(self):
|
def getNumPyGrid(self):
|
||||||
return numpy.resize(self.buffer, (self.xdim, self.ydim))
|
return numpy.resize(self.buffer, (self.xdim, self.ydim))
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ class Grid2DFloat(object):
|
||||||
def getBuffer(self):
|
def getBuffer(self):
|
||||||
return self.buffer
|
return self.buffer
|
||||||
|
|
||||||
def setBuffer(self, buffer):
|
def setBuffer(self, bytebuffer):
|
||||||
self.buffer = buffer
|
self.buffer = bytebuffer
|
||||||
|
|
||||||
def getXdim(self):
|
def getXdim(self):
|
||||||
return self.xdim
|
return self.xdim
|
||||||
|
|
|
@ -6,4 +6,3 @@ __all__ = [
|
||||||
|
|
||||||
from .Grid2DByte import Grid2DByte
|
from .Grid2DByte import Grid2DByte
|
||||||
from .Grid2DFloat import Grid2DFloat
|
from .Grid2DFloat import Grid2DFloat
|
||||||
|
|
||||||
|
|
|
@ -24,4 +24,3 @@ class CommitGridsRequest(object):
|
||||||
|
|
||||||
def setSiteID(self, siteID):
|
def setSiteID(self, siteID):
|
||||||
self.siteID = siteID
|
self.siteID = siteID
|
||||||
|
|
||||||
|
|
|
@ -31,4 +31,3 @@ class ConfigureTextProductsRequest(object):
|
||||||
|
|
||||||
def setDestinationDir(self, destinationDir):
|
def setDestinationDir(self, destinationDir):
|
||||||
self.destinationDir = destinationDir
|
self.destinationDir = destinationDir
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ class ExportGridsRequest(AbstractGfeRequest):
|
||||||
if inputVal in validValues:
|
if inputVal in validValues:
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
else:
|
else:
|
||||||
raise ValueError(inputVal + " not a valid ExportGridsMode value. Must be one of " + str(validValues))
|
raise ValueError(inputVal + " invalid ExportGridsMode. Must be " + str(validValues))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
retVal = "ExportGridsRequest["
|
retVal = "ExportGridsRequest["
|
||||||
|
|
|
@ -45,4 +45,3 @@ class GetASCIIGridsRequest(object):
|
||||||
|
|
||||||
def setSiteID(self, siteID):
|
def setSiteID(self, siteID):
|
||||||
self.siteID = siteID
|
self.siteID = siteID
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ class GetGridDataRequest(with_metaclass(abc.ABCMeta, object)):
|
||||||
|
|
||||||
def addRequest(self, gridDataReq):
|
def addRequest(self, gridDataReq):
|
||||||
if not isinstance(gridDataReq, GetGridRequest):
|
if not isinstance(gridDataReq, GetGridRequest):
|
||||||
raise TypeError("Invalid request specified: " + str(type(gridDataReq)) + \
|
raise TypeError("Invalid request specified: " + str(type(gridDataReq)) +
|
||||||
". Only GetGridRequests are supported.")
|
". Only GetGridRequests are supported.")
|
||||||
else:
|
else:
|
||||||
self.requests.append(gridDataReq)
|
self.requests.append(gridDataReq)
|
||||||
|
@ -36,4 +36,3 @@ class GetGridDataRequest(with_metaclass(abc.ABCMeta, object)):
|
||||||
|
|
||||||
def setSiteID(self, siteID):
|
def setSiteID(self, siteID):
|
||||||
self.siteID = siteID
|
self.siteID = siteID
|
||||||
|
|
||||||
|
|
|
@ -24,4 +24,3 @@ class GetGridInventoryRequest(object):
|
||||||
|
|
||||||
def setSiteID(self, siteID):
|
def setSiteID(self, siteID):
|
||||||
self.siteID = siteID
|
self.siteID = siteID
|
||||||
|
|
||||||
|
|
|
@ -24,4 +24,3 @@ class GetLockTablesRequest(object):
|
||||||
|
|
||||||
def setSiteID(self, siteID):
|
def setSiteID(self, siteID):
|
||||||
self.siteID = siteID
|
self.siteID = siteID
|
||||||
|
|
||||||
|
|
|
@ -17,4 +17,3 @@ class GetOfficialDbNameRequest(object):
|
||||||
|
|
||||||
def setSiteID(self, siteID):
|
def setSiteID(self, siteID):
|
||||||
self.siteID = siteID
|
self.siteID = siteID
|
||||||
|
|
||||||
|
|
|
@ -24,4 +24,3 @@ class GetParmListRequest(object):
|
||||||
|
|
||||||
def setSiteID(self, siteID):
|
def setSiteID(self, siteID):
|
||||||
self.siteID = siteID
|
self.siteID = siteID
|
||||||
|
|
||||||
|
|
|
@ -24,4 +24,3 @@ class GetSelectTimeRangeRequest(object):
|
||||||
|
|
||||||
def setSiteID(self, siteID):
|
def setSiteID(self, siteID):
|
||||||
self.siteID = siteID
|
self.siteID = siteID
|
||||||
|
|
||||||
|
|
|
@ -17,4 +17,3 @@ class GetSingletonDbIdsRequest(object):
|
||||||
|
|
||||||
def setSiteID(self, siteID):
|
def setSiteID(self, siteID):
|
||||||
self.siteID = siteID
|
self.siteID = siteID
|
||||||
|
|
||||||
|
|
|
@ -21,4 +21,3 @@ class GetSiteTimeZoneInfoRequest(AbstractGfeRequest):
|
||||||
|
|
||||||
def setRequestedSiteIDs(self, requestedSiteIDs):
|
def setRequestedSiteIDs(self, requestedSiteIDs):
|
||||||
self.requestedSiteIDs = requestedSiteIDs
|
self.requestedSiteIDs = requestedSiteIDs
|
||||||
|
|
||||||
|
|
|
@ -17,4 +17,3 @@ class GridLocRequest(object):
|
||||||
|
|
||||||
def setSiteID(self, siteID):
|
def setSiteID(self, siteID):
|
||||||
self.siteID = siteID
|
self.siteID = siteID
|
||||||
|
|
||||||
|
|
|
@ -24,4 +24,3 @@ class LockChangeRequest(object):
|
||||||
|
|
||||||
def setSiteID(self, siteID):
|
def setSiteID(self, siteID):
|
||||||
self.siteID = siteID
|
self.siteID = siteID
|
||||||
|
|
||||||
|
|
|
@ -24,4 +24,3 @@ class SaveASCIIGridsRequest(object):
|
||||||
|
|
||||||
def setSiteID(self, siteID):
|
def setSiteID(self, siteID):
|
||||||
self.siteID = siteID
|
self.siteID = siteID
|
||||||
|
|
||||||
|
|
|
@ -38,4 +38,3 @@ class SmartInitRequest(object):
|
||||||
|
|
||||||
def setSiteID(self, siteID):
|
def setSiteID(self, siteID):
|
||||||
self.siteID = siteID
|
self.siteID = siteID
|
||||||
|
|
||||||
|
|
|
@ -59,4 +59,3 @@ from .PurgeGfeGridsRequest import PurgeGfeGridsRequest
|
||||||
from .SaveASCIIGridsRequest import SaveASCIIGridsRequest
|
from .SaveASCIIGridsRequest import SaveASCIIGridsRequest
|
||||||
from .SmartInitRequest import SmartInitRequest
|
from .SmartInitRequest import SmartInitRequest
|
||||||
from .RsyncGridsToCWFRequest import RsyncGridsToCWFRequest
|
from .RsyncGridsToCWFRequest import RsyncGridsToCWFRequest
|
||||||
|
|
||||||
|
|
|
@ -5,5 +5,3 @@ __all__ = [
|
||||||
'notify',
|
'notify',
|
||||||
'request'
|
'request'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,4 +50,3 @@ class Lock(object):
|
||||||
+ ', ' + time.strftime(timeformat, t1)
|
+ ', ' + time.strftime(timeformat, t1)
|
||||||
msg += " WsId: " + str(self.wsId)
|
msg += " WsId: " + str(self.wsId)
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|
|
@ -40,4 +40,3 @@ class LockTable(object):
|
||||||
for i in self.locks:
|
for i in self.locks:
|
||||||
msg += "\n Lock: " + str(i)
|
msg += "\n Lock: " + str(i)
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|
|
@ -6,4 +6,3 @@ __all__ = [
|
||||||
|
|
||||||
from .Lock import Lock
|
from .Lock import Lock
|
||||||
from .LockTable import LockTable
|
from .LockTable import LockTable
|
||||||
|
|
||||||
|
|
|
@ -10,4 +10,3 @@ class ServerMsg(object):
|
||||||
|
|
||||||
def setMessage(self, message):
|
def setMessage(self, message):
|
||||||
self.message = message
|
self.message = message
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,10 @@ class ServerResponse(object):
|
||||||
self.notifications = notifications
|
self.notifications = notifications
|
||||||
|
|
||||||
def isOkay(self):
|
def isOkay(self):
|
||||||
return (self.messages is None or len(self.messages) == 0)
|
return self.messages is None or len(self.messages) == 0
|
||||||
|
|
||||||
def message(self):
|
def message(self):
|
||||||
if (self.isOkay()):
|
if self.isOkay():
|
||||||
return ""
|
return ""
|
||||||
else:
|
else:
|
||||||
compMessage = ""
|
compMessage = ""
|
||||||
|
|
|
@ -6,4 +6,3 @@ __all__ = [
|
||||||
|
|
||||||
from .ServerMsg import ServerMsg
|
from .ServerMsg import ServerMsg
|
||||||
from .ServerResponse import ServerResponse
|
from .ServerResponse import ServerResponse
|
||||||
|
|
||||||
|
|
|
@ -34,4 +34,3 @@ class DBInvChangeNotification(GfeNotification.GfeNotification):
|
||||||
msg = 'Additions' + str(self.additions) + '\n'
|
msg = 'Additions' + str(self.additions) + '\n'
|
||||||
msg += 'Deletions' + str(self.deletions)
|
msg += 'Deletions' + str(self.deletions)
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ class GfeNotification(with_metaclass(abc.ABCMeta, object)):
|
||||||
def setSiteID(self, siteID):
|
def setSiteID(self, siteID):
|
||||||
self.siteID = siteID
|
self.siteID = siteID
|
||||||
|
|
||||||
|
|
||||||
def getSourceID(self):
|
def getSourceID(self):
|
||||||
return self.sourceID
|
return self.sourceID
|
||||||
|
|
||||||
|
|
|
@ -39,4 +39,3 @@ class GridHistoryUpdateNotification(GfeNotification):
|
||||||
msg = "ParmID: " + str(self.parmId)
|
msg = "ParmID: " + str(self.parmId)
|
||||||
msg += '\n' + "Histories: " + str(self.histories)
|
msg += '\n' + "Histories: " + str(self.histories)
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|
|
@ -48,4 +48,3 @@ class GridUpdateNotification(GfeNotification):
|
||||||
msg += '\n' + "Replacement TimeRange: " + str(self.replacementTimeRange)
|
msg += '\n' + "Replacement TimeRange: " + str(self.replacementTimeRange)
|
||||||
msg += '\n' + "Histories: " + str(self.histories)
|
msg += '\n' + "Histories: " + str(self.histories)
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue