PEP 8 coding standards

This commit is contained in:
Michael James 2018-10-16 21:33:43 -06:00
parent d2b34d09bb
commit 1b68f8800c
234 changed files with 272 additions and 536 deletions

View file

@ -56,6 +56,7 @@ def convertToDateTime(timeArg):
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)
@ -64,6 +65,7 @@ def _convertSecsAndMicros(seconds, micros):
rval = datetime.datetime.utcfromtimestamp(MAX_TIME) + extraTime
return rval.replace(microsecond=micros)
def constructTimeRange(*args):
"""
Builds a python dynamicserialize TimeRange object from the given

View file

@ -53,12 +53,13 @@ class QpidSubscriber:
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'):
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.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)
@ -75,12 +76,12 @@ class QpidSubscriber:
message = queue.get(timeout=10)
content = message.body
self.__session.message_accept(qpid.datatypes.RangedSet(message.id))
if (self.decompress):
if self.decompress:
try:
# http://stackoverflow.com/questions/2423866/python-decompressing-gzip-chunk-by-chunk
d = zlib.decompressobj(16+zlib.MAX_WBITS)
content = d.decompress(content)
except Exception:
except ValueError:
# decompression failed, return the original content
pass
callback(content)
@ -94,10 +95,9 @@ class QpidSubscriber:
self.subscribed = False
try:
self.__session.close(timeout=10)
except Exception:
except ValueError:
pass
@property
def queueStarted(self):
return self.__queueStarted

View file

@ -24,7 +24,7 @@ def get_datetime_str(record):
Returns:
datetime string.
"""
return str(record.getDataTime())[0:19].replace(" ","_") + ".0"
return str(record.getDataTime())[0:19].replace(" ", "_") + ".0"
def get_data_type(azdat):
@ -59,7 +59,7 @@ def get_hdf5_data(idra):
elif idra[ii].getName() == "Thresholds":
threshVals = idra[ii].getShortData()
return rdat,azdat,depVals,threshVals
return rdat, azdat, depVals, threshVals
def get_header(record, headerFormat, xLen, yLen, azdat, description):
@ -90,7 +90,7 @@ def encode_thresh_vals(threshVals):
nnn = len(threshVals)
j = 0
msg = ""
while j<nnn:
while j < nnn:
lo = threshVals[j] % 256
hi = threshVals[j] / 256
msg += " "

View file

@ -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.
#
@ -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:
@ -32,12 +32,12 @@ class ThriftClient:
# 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):
if len(hostParts) > 1:
hostString = hostParts[0]
self.__uri = "/" + hostParts[1]
self.__httpConn = httpcl.HTTPConnection(hostString)
else:
if (port is None):
if port is None:
self.__httpConn = httpcl.HTTPConnection(host)
else:
self.__httpConn = httpcl.HTTPConnection(host, port)
@ -53,7 +53,7 @@ class ThriftClient:
self.__httpConn.request("POST", self.__uri + uri, message)
response = self.__httpConn.getresponse()
if (response.status != 200):
if response.status != 200:
raise ThriftRequestException("Unable to post request to server")
rval = self.__dsm.deserializeBytes(response.read())
@ -78,4 +78,3 @@ class ThriftRequestException(Exception):
def __str__(self):
return repr(self.parameter)

View file

@ -49,7 +49,7 @@ import time
def determineDrtOffset(timeStr):
launchStr = timeStr
# Check for time difference
if timeStr.find(",") >=0:
if timeStr.find(",") >= 0:
times = timeStr.split(",")
t1 = makeTime(times[0])
t2 = makeTime(times[1])
@ -67,8 +67,9 @@ def determineDrtOffset(timeStr):
# i.e. "truncate" cur_t to most recent hour.
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' % (repr(gm[0]),repr(gm[1]),repr(gm[2]),repr(gm[3]))
curStr = curStr.replace(' ','0')
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
offset = drt_t - cur_t

View file

@ -27,7 +27,7 @@ class UsageArgumentParser(argparse.ArgumentParser):
sys.exit(2)
## Custom actions for ArgumentParser objects ##
# Custom actions for ArgumentParser objects
class StoreDatabaseIDAction(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
did = DatabaseID(values)
@ -41,8 +41,7 @@ class AppendParmNameAndLevelAction(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
tx = ParmID.parmNameAndLevel(values)
comp = tx[0] + '_' + tx[1]
if (hasattr(namespace, self.dest)) and \
(getattr(namespace, self.dest) is not None):
if (hasattr(namespace, self.dest)) and (getattr(namespace, self.dest) is not None):
currentValues = getattr(namespace, self.dest)
currentValues.append(comp)
setattr(namespace, self.dest, currentValues)
@ -58,8 +57,6 @@ class StoreTimeAction(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
try:
timeStruct = time.strptime(values, TIME_FORMAT)
setattr(namespace, self.dest, timeStruct)
except ValueError:
parser.error(str(values) + " is not a valid time string of the format YYYYMMDD_hhmm")
setattr(namespace, self.dest, timeStruct)

View file

@ -76,9 +76,9 @@ def __getAvailableTimesForEachLocation(request, refTimeOnly=False):
def __cloneRequest(request):
return DataAccessLayer.newDataRequest(datatype = request.getDatatype(),
parameters = request.getParameters(),
levels = request.getLevels(),
locationNames = request.getLocationNames(),
envelope = request.getEnvelope(),
return DataAccessLayer.newDataRequest(datatype=request.getDatatype(),
parameters=request.getParameters(),
levels=request.getLevels(),
locationNames=request.getLocationNames(),
envelope=request.getEnvelope(),
**request.getIdentifiers())

View file

@ -5,23 +5,20 @@
# 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.
# 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
# Apr 13, 2016 5379 tgurney Add getIdentifierValues()
# Jun 01, 2016 5587 tgurney Add new signatures for
# getRequiredIdentifiers() and
# getOptionalIdentifiers()
# Apr 13, 2016 5379 tgurney Add getIdentifierValues(), getRequiredIdentifiers(),
# and getOptionalIdentifiers()
# Oct 07, 2016 ---- mjames@ucar Added getForecastRun
# Oct 18, 2016 5916 bsteffen Add setLazyLoadGridLatLon
# Oct 11, 2018 mjames@ucar Added getMetarObs() getSynopticObs()
# Oct 11, 2018 ---- mjames@ucar Added getMetarObs() getSynopticObs()
#
import sys
@ -145,6 +142,7 @@ def getForecastRun(cycle, times):
fcstRun.append(t)
return fcstRun
def getAvailableTimes(request, refTimeOnly=False):
"""
Get the times of available data to the request.
@ -282,6 +280,7 @@ def getIdentifierValues(request, identifierKey):
"""
return router.getIdentifierValues(request, identifierKey)
def newDataRequest(datatype=None, **kwargs):
"""
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)
def getSupportedDatatypes():
"""
Gets the datatypes that are supported by the framework
@ -317,7 +317,7 @@ def changeEDEXHost(newHostName):
method will throw a TypeError.
Args:
newHostHame: the EDEX host to connect to
newHostName: the EDEX host to connect to
"""
if USING_NATIVE_THRIFT:
global THRIFT_HOST
@ -327,6 +327,7 @@ def changeEDEXHost(newHostName):
else:
raise TypeError("Cannot call changeEDEXHost when using JepRouter.")
def setLazyLoadGridLatLon(lazyLoadGridLatLon):
"""
Provide a hint to the Data Access Framework indicating whether to load the

View file

@ -56,7 +56,7 @@ THRIFT_HOST = "edex"
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:
# 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.
Args:
newHostHame: the EDEX host to connect to
newHostName: the EDEX host to connect to
"""
if USING_NATIVE_THRIFT:
global THRIFT_HOST

View file

@ -25,15 +25,12 @@ if sys.version_info.major == 2:
else: # Python 3 module renamed to 'queue'
from queue import Queue, Empty
# Used to indicate a DataQueue that will produce geometry data.
GEOMETRY = object()
# Used to indicate a DataQueue that will produce grid data.
GRID = object()
# Default maximum queue size.
_DEFAULT_MAXSIZE = 100

View file

@ -39,12 +39,8 @@ def getSounding(modelName, weatherElements, levels, samplePoint, timeRange=None)
(locationNames, parameters, levels, envelope, timeRange) = \
__sanitizeInputs(modelName, weatherElements, levels, samplePoint, timeRange)
requestArgs = { 'datatype' : 'grid',
'locationNames' : locationNames,
'parameters' : parameters,
'levels' : levels,
'envelope' : envelope
}
requestArgs = {'datatype': 'grid', 'locationNames': locationNames,
'parameters': parameters, 'levels': levels, 'envelope': envelope}
req = DataAccessLayer.newDataRequest(**requestArgs)
response = DataAccessLayer.getGeometryData(req, timeRange)

View file

@ -28,7 +28,7 @@ The ability to unit convert grid data is not currently available in this version
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)
nx = nx
ny = ny
@ -38,7 +38,6 @@ class PyGridData(IGridData, PyData.PyData):
self.__latLonGrid = latLonGrid
self.__latLonDelegate = latLonDelegate
def getParameter(self):
return self.__parameter

View file

@ -33,7 +33,7 @@ class PyGridNotification(PyNotification):
newReq.setParameters(self.request.getParameters())
data = self.getData(newReq, [])
self.callback(data)
except Exception:
except ValueError:
traceback.print_exc()
def getData(self, request, dataTimes):

View file

@ -224,7 +224,8 @@ class ThriftClientRouter(object):
return [x.decode('utf-8') for x in 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()
if datatype:
req.setDatatype(datatype)

View file

@ -91,7 +91,7 @@ class IFPClient(object):
sr.setPayload(inventoryList)
return sr
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)) +
" specified to getGridInventory(). Accepts ParmID or lists of ParmID.")

View file

@ -77,12 +77,13 @@ QPID_PASSWORD = 'guest'
class IngestViaQPID:
def __init__(self, host='localhost', port=5672, ssl=None):
'''
"""
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)
@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:
#
@ -100,31 +101,31 @@ class IngestViaQPID:
keyfile = os.path.join(certdb, certname + ".key")
trustfile = os.path.join(certdb, "root.crt")
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.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:
except ValueError:
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
head = self.session.message_properties(application_headers={'header': header},
user_id=QPID_USERNAME)
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')

View file

@ -89,11 +89,11 @@ class DafTestCase(unittest.TestCase):
print("Optional identifiers:", optional)
def runGetIdValuesTest(self, identifiers):
for id in identifiers:
if id.lower() == 'datauri':
for identifier in identifiers:
if identifier.lower() == 'datauri':
continue
req = DAL.newDataRequest(self.datatype)
idValues = DAL.getIdentifierValues(req, id)
idValues = DAL.getIdentifierValues(req, identifier)
self.assertTrue(hasattr(idValues, '__iter__'))
def runInvalidIdValuesTest(self):
@ -145,20 +145,9 @@ class DafTestCase(unittest.TestCase):
times = DafTestCase.getTimesIfSupported(req)
geomData = DAL.getGeometryData(req, times[:self.numTimesToLimit])
self.assertIsNotNone(geomData)
#if times:
# self.assertNotEqual(len(geomData), 0)
if not geomData:
raise unittest.SkipTest("No data available")
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
def runGeometryDataTestWithTimeRange(self, req, timeRange):
@ -171,14 +160,6 @@ class DafTestCase(unittest.TestCase):
if not geomData:
raise unittest.SkipTest("No data available")
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
def runGridDataTest(self, req, testSameShape=True):
@ -187,6 +168,7 @@ class DafTestCase(unittest.TestCase):
request.
Args:
req: the grid request
testSameShape: whether or not to verify that all the retrieved data
have the same shape (most data don't change shape)
"""

View file

@ -32,8 +32,8 @@ class CombinedTimeQueryTestCase(unittest.TestCase):
def testSuccessfulQuery(self):
req = DAL.newDataRequest('grid')
req.setLocationNames(self.modelName)
req.setParameters('T','GH')
req.setLevels('300MB', '500MB','700MB')
req.setParameters('T', 'GH')
req.setLevels('300MB', '500MB', '700MB')
times = CTQ.getAvailableTimes(req)
self.assertNotEqual(len(times), 0)
@ -43,7 +43,7 @@ class CombinedTimeQueryTestCase(unittest.TestCase):
"""
req = DAL.newDataRequest('grid')
req.setLocationNames(self.modelName)
req.setParameters('T','GH', 'LgSP1hr')
req.setLevels('300MB', '500MB','700MB','0.0SFC')
req.setParameters('T', 'GH', 'LgSP1hr')
req.setLevels('300MB', '500MB', '700MB', '0.0SFC')
times = CTQ.getAvailableTimes(req)
self.assertEqual(len(times), 0)

View file

@ -78,7 +78,7 @@ class GfeTestCase(baseDafTestCase.DafTestCase):
# Ensure all points are within one degree of the original box
# to allow slight margin of error for reprojection distortion.
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)):
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.setParameters('Wind')
times = DAL.getAvailableTimes(req)
if not(times):
if not times:
raise unittest.SkipTest('No Wind Data available for testing')
gridData = DAL.getGridData(req, [times[0]])
rawWind = None
rawDir = None
for grid in gridData:
if grid.getParameter() == 'Wind':
self.assertEqual(grid.getUnit(),'kts')
self.assertEqual(grid.getUnit(), 'kts')
rawWind = grid.getRawData()
elif grid.getParameter() == 'WindDirection':
self.assertEqual(grid.getUnit(),'deg')
self.assertEqual(grid.getUnit(), 'deg')
rawDir = grid.getRawData()
self.assertIsNotNone(rawWind, 'Wind Magnitude grid is not present')
self.assertIsNotNone(rawDir, 'Wind Direction grid is not present')
@ -192,4 +192,3 @@ class GfeTestCase(baseDafTestCase.DafTestCase):
def testGetDataWithEmptyInConstraintThrowsException(self):
with self.assertRaises(ValueError):
self._runConstraintTest('parmId.dbId.modelName', 'in', [])

View file

@ -86,7 +86,6 @@ class GridTestCase(baseDafTestCase.DafTestCase):
def testGetNonexistentIdentifierValuesThrowsException(self):
self.runNonexistentIdValuesTest()
def testGetDataWithEnvelope(self):
req = DAL.newDataRequest(self.datatype)
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
# to allow slight margin of error for reprojection distortion.
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)):
self.assertTrue(testEnv.contains(Point(lons[i], lats[i])))
def _runConstraintTest(self, key, operator, value):
req = DAL.newDataRequest(self.datatype)
constraint = RequestConstraint.new(operator, value)

View file

@ -124,7 +124,7 @@ class ModelSoundingTestCase(baseDafTestCase.DafTestCase):
# No numeric tests since no numeric identifiers are available.
def testGetDataWithEqualsNone(self):
geometryData = self._runConstraintTest('reportType', '=', None)
self._runConstraintTest('reportType', '=', None)
def testGetDataWithNotEquals(self):
geometryData = self._runConstraintTest('reportType', '!=', 'ETA')
@ -132,19 +132,19 @@ class ModelSoundingTestCase(baseDafTestCase.DafTestCase):
self.assertNotIn('/ETA/', record.getString('dataURI'))
def testGetDataWithNotEqualsNone(self):
geometryData = self._runConstraintTest('reportType', '!=', None)
self._runConstraintTest('reportType', '!=', None)
def testGetDataWithGreaterThan(self):
geometryData = self._runConstraintTest('reportType', '>', 'ETA')
self._runConstraintTest('reportType', '>', 'ETA')
def testGetDataWithLessThan(self):
geometryData = self._runConstraintTest('reportType', '<', 'ETA')
self._runConstraintTest('reportType', '<', 'ETA')
def testGetDataWithGreaterThanEquals(self):
geometryData = self._runConstraintTest('reportType', '>=', 'ETA')
self._runConstraintTest('reportType', '>=', 'ETA')
def testGetDataWithLessThanEquals(self):
geometryData = self._runConstraintTest('reportType', '<=', 'ETA')
self._runConstraintTest('reportType', '<=', 'ETA')
def testGetDataWithInTuple(self):
collection = ('ETA', 'GFS')

View file

@ -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 params
class RadarSpatialTestCase(baseDafTestCase.DafTestCase):
"""Test DAF support for radar_spatial data"""

View file

@ -49,7 +49,6 @@ class TopoTestCase(baseDafTestCase.DafTestCase):
print("Sample grid data shape:\n" + str(gridData[0].getRawData().shape) + "\n")
print("Sample grid data:\n" + str(gridData[0].getRawData()) + "\n")
def testRequestingTooMuchDataThrowsResponseTooLargeException(self):
req = DAL.newDataRequest(self.datatype)
req.addIdentifier("group", "/")

View file

@ -14,7 +14,8 @@
from thrift.protocol.TProtocol import *
from thrift.protocol.TBinaryProtocol import *
import struct, numpy
import struct
import numpy
FLOAT = 64
@ -31,10 +32,10 @@ class SelfDescribingBinaryProtocol(TBinaryProtocol):
def readFieldBegin(self):
ftype = self.readByte()
if ftype == TType.STOP:
return (None, ftype, 0)
return None, ftype, 0
name = self.readString()
fid = self.readI16()
return (name, ftype, fid)
return name, ftype, fid
def readStructBegin(self):
return self.readString()

View file

@ -49,6 +49,7 @@ def buildObjMap(module):
tname = tname[DS_LEN:]
dsObjTypes[tname] = clz
buildObjMap(dstypes)
if six.PY2:
@ -211,7 +212,7 @@ class ThriftSerializationContext(object):
try:
setMethod = getattr(obj, lookingFor)
setMethod(result)
except:
except ValueError:
raise dynamicserialize.SerializationException(
"Couldn't find setter method " + lookingFor)
@ -254,7 +255,7 @@ class ThriftSerializationContext(object):
pyt = type(obj)
if pyt in pythonToThriftMap:
return pythonToThriftMap[pyt]
elif pyt.__module__[:DS_LEN - 1] == ('dynamicserialize.dstypes'):
elif pyt.__module__[:DS_LEN - 1] == 'dynamicserialize.dstypes':
return pythonToThriftMap[object]
raise dynamicserialize.SerializationException(
"Don't know how to serialize object of type: " + str(pyt))
@ -284,7 +285,6 @@ class ThriftSerializationContext(object):
val = m[1]()
ft = self._lookupType(val)
if ft == TType.STRUCT:
fc = val.__module__[DS_LEN:]
self._serializeField(fieldname, ft, fid, val)
else:
self._serializeField(fieldname, ft, fid, val)

View file

@ -59,7 +59,7 @@ def deserialize(context):
geoData = []
size = context.readI32()
for __ in range(size):
for _ in range(size):
data = GeometryResponseData()
# wkb index
wkbIndex = context.readI32()

View file

@ -92,7 +92,7 @@ def registerAdapters(package, modules):
clzName = m.ClassAdapter
classAdapterRegistry[clzName] = m
else:
raise LookupError('Adapter class ' + x + ' has no ClassAdapter field ' + \
raise LookupError('Adapter class ' + x + ' has no ClassAdapter field ' +
'and cannot be registered.')

View file

@ -3,5 +3,3 @@ __all__ = [
'raytheon',
'vividsolutions'
]

View file

@ -2,5 +2,3 @@
__all__ = [
'uf'
]

View file

@ -2,5 +2,3 @@
__all__ = [
'common'
]

View file

@ -15,5 +15,3 @@ __all__ = [
'site',
'time'
]

View file

@ -54,7 +54,10 @@ class AlertVizRequest(object):
def setFilters(self, filters):
if filters is None:
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
or filters.values().count(None) > 0
or '' in filters
or filters.values().count('') > 0):
self.filters = filters
else:
raise ValueError('Filters must not contain None or empty keys or values: %s' % filters)

View file

@ -3,5 +3,3 @@ __all__ = [
'resp',
'user'
]

View file

@ -12,4 +12,3 @@ class AbstractFailedResponse(with_metaclass(abc.ABCMeta, object)):
def setRequest(self, request):
self.request = request

View file

@ -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
@ -6,7 +8,3 @@ class AuthServerErrorResponse(ServerErrorResponse):
def __init__(self):
super(AuthServerErrorResponse, self).__init__()
## nothing to implement here that isn't already covered by ServerErrorResponse ##
## Just need the separate class for de-serialization. ##

View file

@ -17,4 +17,3 @@ class SuccessfulExecution(object):
def setUpdatedData(self, updatedData):
self.updatedData = updatedData

View file

@ -10,4 +10,3 @@ from .AbstractFailedResponse import AbstractFailedResponse
from .AuthServerErrorResponse import AuthServerErrorResponse
from .SuccessfulExecution import SuccessfulExecution
from .UserNotAuthorized import UserNotAuthorized

View file

@ -21,4 +21,3 @@ class User(object):
def setAuthenticationData(self, authenticationData):
self.authenticationData = authenticationData

View file

@ -8,7 +8,7 @@ except ImportError:
class UserId(object):
def __init__(self, userid = None):
def __init__(self, userid=None):
if userid is None:
if not pwd_error:
self.id = pwd.getpwuid(os.getuid()).pw_name

View file

@ -4,5 +4,3 @@ __all__ = [
'request',
'response'
]

View file

@ -14,4 +14,3 @@ class GetAvailableLocationNamesRequest(AbstractDataAccessRequest):
def __init__(self):
super(GetAvailableLocationNamesRequest, self).__init__()

View file

@ -28,4 +28,3 @@ class GetGeometryDataRequest(AbstractDataAccessRequest):
def setRequestedPeriod(self, requestedPeriod):
self.requestedPeriod = requestedPeriod

View file

@ -15,4 +15,3 @@ class GetOptionalIdentifiersRequest(AbstractIdentifierRequest):
def __init__(self):
super(GetOptionalIdentifiersRequest, self).__init__()

View file

@ -12,4 +12,3 @@ class GetSupportedDatatypesRequest(object):
def __init__(self):
pass

View file

@ -17,4 +17,3 @@ class GetGeometryDataResponse(object):
def setGeoData(self, geoData):
self.geoData = geoData

View file

@ -52,4 +52,3 @@ class GetGridDataResponse(object):
def setSiteCrsWkt(self, siteCrsWkt):
self.siteCrsWkt = siteCrsWkt

View file

@ -37,4 +37,3 @@ class GetGridLatLonResponse(object):
def setNy(self, ny):
self.ny = ny

View file

@ -8,5 +8,3 @@ __all__ = [
'radar',
'text'
]

View file

@ -2,5 +2,3 @@
__all__ = [
'hazards'
]

View file

@ -23,4 +23,3 @@ class RegionLookupRequest(object):
def setSite(self, site):
self.site = site

View file

@ -4,4 +4,3 @@ __all__ = [
]
from .RegionLookupRequest import RegionLookupRequest

View file

@ -73,4 +73,3 @@ class GridDataHistory(object):
def setLastSentTime(self, lastSentTime):
self.lastSentTime = lastSentTime

View file

@ -6,7 +6,6 @@
# 06/22/2015 4573 randerso Added svcbu package
# 10/06/2015 mjames@ucar Removed svcbu package
#
#
__all__ = [
'config',
@ -21,4 +20,3 @@ __all__ = [
]
from .GridDataHistory import GridDataHistory

View file

@ -93,4 +93,3 @@ class ProjectionData(object):
'latLonOrigin', 'stdParallelOne', 'stdParallelTwo',
'gridPointLL', 'gridPointUR', 'latIntersect', 'lonCenter',
'lonOrigin']

View file

@ -4,4 +4,3 @@ __all__ = [
]
from .ProjectionData import ProjectionData

View file

@ -2,5 +2,3 @@
__all__ = [
'objects'
]

View file

@ -113,7 +113,7 @@ class DatabaseID(object):
self.modelName = strings[3]
# 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
# make sure the digits are there
@ -130,14 +130,14 @@ class DatabaseID(object):
try:
dateStruct = time.strptime(dtgString, "%Y%m%d_%H%M")
except ValueError:
return (False, dateStruct)
return (True, dateStruct)
return False, dateStruct
return True, dateStruct
def __decodeDtg(self, dtgString):
try:
time.strptime(dtgString, "%Y%m%d_%H%M")
self.modelTime = dtgString
except:
except ValueError:
return False
return True
@ -188,7 +188,7 @@ class DatabaseID(object):
def __eq__(self, other):
if not isinstance(other, DatabaseID):
return False
return (str(self) == str(other))
return str(self) == str(other)
def __ne__(self, other):
return (not self.__eq__(other))
return not self.__eq__(other)

View file

@ -90,4 +90,3 @@ class GFERecord(object):
def setIdentifier(self, identifier):
self.identifier = identifier

View file

@ -18,11 +18,10 @@ class GridLocation(object):
return self.__repr__()
def __repr__(self):
s = "[SiteID =" + self.siteId + ",ProjID=" + self.projection.getProjectionID() +\
",gridSize=(" + str(self.nx) + ',' + str(self.ny) + ")"
# TODO: Handle geometry in dynamicserialize
# ,loc=" + this.geometry.getGeometryType()
s += ']'
s = "[SiteID =" + self.siteId + ",ProjID=" + self.projection.getProjectionID() +\
",gridSize=(" + str(self.nx) + ',' + str(self.ny) + ")]"
return s
def __eq__(self, other):
@ -43,7 +42,7 @@ class GridLocation(object):
return True
def __ne__(self, other):
return (not self.__eq__(other))
return not self.__eq__(other)
def getSiteId(self):
return self.siteId
@ -113,4 +112,3 @@ class GridLocation(object):
if self.origin is None or self.extent is None:
return False
return True

View file

@ -30,7 +30,6 @@ class GridParmInfo(object):
return self.__repr__()
def __repr__(self):
out = ""
if self.isValid():
out = "ParmID: " + str(self.parmID) + \
" TimeConstraints: " + str(self.timeConstraints) + \
@ -42,9 +41,9 @@ class GridParmInfo(object):
" TimeIndependent: " + str(self.timeIndependentParm) + \
" RateParm: " + str(self.rateParm) + \
" GridType: " + self.gridType
else:
out = "<Invalid>"
return out
else:
return "<Invalid>"
def __eq__(self, other):
if not isinstance(other, GridParmInfo):
@ -99,7 +98,7 @@ class GridParmInfo(object):
retVal = True
if status:
retVal = False
return (retVal, status)
return retVal, status
def isValid(self):
(valid, errors) = self.__validCheck()

View file

@ -56,7 +56,7 @@ class ParmID(object):
parts = parmIdentifier.split(":")
nameLevel = parts[0].split("_")
self.dbId = DatabaseID(parts[1])
if (len(nameLevel) == 2):
if len(nameLevel) == 2:
self.parmName = nameLevel[0]
self.parmLevel = nameLevel[1]
else:
@ -89,9 +89,9 @@ class ParmID(object):
def parmNameAndLevel(composite):
pos = composite.find('_')
if pos != -1:
return (composite[:pos], composite[pos+1:])
return composite[:pos], composite[pos+1:]
else:
return (composite, "SFC")
return composite, "SFC"
def __str__(self):
return self.__repr__()
@ -128,4 +128,4 @@ class ParmID(object):
return True
def __ne__(self, other):
return (not self.__eq__(other))
return not self.__eq__(other)

View file

@ -57,13 +57,13 @@ class TimeConstraints(object):
return False
if self.repeatInterval != other.repeatInterval:
return False
return (self.startTime == other.startTime)
return self.startTime == other.startTime
def __ne__(self, other):
return (not self.__eq__(other))
return not self.__eq__(other)
def anyConstraints(self):
return (self.duration != 0)
return self.duration != 0
def isValid(self):
return self.valid

View file

@ -14,4 +14,3 @@ from .GridLocation import GridLocation
from .GridParmInfo import GridParmInfo
from .ParmID import ParmID
from .TimeConstraints import TimeConstraints

View file

@ -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
# is only really useful as a container for deserialized data
# from EDEX. I would not recommend trying to use it for anything
@ -24,7 +24,7 @@ class DiscreteKey(object):
def __getitem__(self, key):
try:
index = int(key)
except:
except TypeError:
raise TypeError("list indices must be integers, not " + str(type(key)))
if index < 0 or index > len(self.subKeys):
raise IndexError("index out of range")
@ -48,7 +48,7 @@ class DiscreteKey(object):
return self.subKeys == other.subKeys
def __ne__(self, other):
return (not self.__eq__(other))
return not self.__eq__(other)
@staticmethod
def auxData(subkey):
@ -83,4 +83,3 @@ class DiscreteKey(object):
def setParmID(self, parmID):
self.parmID = parmID

View file

@ -4,4 +4,3 @@ __all__ = [
]
from .DiscreteKey import DiscreteKey

View file

@ -11,8 +11,8 @@ class Grid2DByte(object):
def getBuffer(self):
return self.buffer
def setBuffer(self, buffer):
self.buffer = buffer
def setBuffer(self, bytebuffer):
self.buffer = bytebuffer
def getXdim(self):
return self.xdim
@ -28,4 +28,3 @@ class Grid2DByte(object):
def getNumPyGrid(self):
return numpy.resize(self.buffer, (self.xdim, self.ydim))

View file

@ -11,8 +11,8 @@ class Grid2DFloat(object):
def getBuffer(self):
return self.buffer
def setBuffer(self, buffer):
self.buffer = buffer
def setBuffer(self, bytebuffer):
self.buffer = bytebuffer
def getXdim(self):
return self.xdim

View file

@ -6,4 +6,3 @@ __all__ = [
from .Grid2DByte import Grid2DByte
from .Grid2DFloat import Grid2DFloat

View file

@ -24,4 +24,3 @@ class CommitGridsRequest(object):
def setSiteID(self, siteID):
self.siteID = siteID

View file

@ -31,4 +31,3 @@ class ConfigureTextProductsRequest(object):
def setDestinationDir(self, destinationDir):
self.destinationDir = destinationDir

View file

@ -37,7 +37,7 @@ class ExportGridsRequest(AbstractGfeRequest):
if inputVal in validValues:
self.mode = mode
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):
retVal = "ExportGridsRequest["

View file

@ -45,4 +45,3 @@ class GetASCIIGridsRequest(object):
def setSiteID(self, siteID):
self.siteID = siteID

View file

@ -12,7 +12,7 @@ class GetGridDataRequest(with_metaclass(abc.ABCMeta, object)):
def addRequest(self, gridDataReq):
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.")
else:
self.requests.append(gridDataReq)
@ -36,4 +36,3 @@ class GetGridDataRequest(with_metaclass(abc.ABCMeta, object)):
def setSiteID(self, siteID):
self.siteID = siteID

View file

@ -24,4 +24,3 @@ class GetGridInventoryRequest(object):
def setSiteID(self, siteID):
self.siteID = siteID

View file

@ -24,4 +24,3 @@ class GetLockTablesRequest(object):
def setSiteID(self, siteID):
self.siteID = siteID

View file

@ -17,4 +17,3 @@ class GetOfficialDbNameRequest(object):
def setSiteID(self, siteID):
self.siteID = siteID

View file

@ -24,4 +24,3 @@ class GetParmListRequest(object):
def setSiteID(self, siteID):
self.siteID = siteID

View file

@ -24,4 +24,3 @@ class GetSelectTimeRangeRequest(object):
def setSiteID(self, siteID):
self.siteID = siteID

View file

@ -17,4 +17,3 @@ class GetSingletonDbIdsRequest(object):
def setSiteID(self, siteID):
self.siteID = siteID

View file

@ -21,4 +21,3 @@ class GetSiteTimeZoneInfoRequest(AbstractGfeRequest):
def setRequestedSiteIDs(self, requestedSiteIDs):
self.requestedSiteIDs = requestedSiteIDs

View file

@ -17,4 +17,3 @@ class GridLocRequest(object):
def setSiteID(self, siteID):
self.siteID = siteID

View file

@ -24,4 +24,3 @@ class LockChangeRequest(object):
def setSiteID(self, siteID):
self.siteID = siteID

View file

@ -24,4 +24,3 @@ class SaveASCIIGridsRequest(object):
def setSiteID(self, siteID):
self.siteID = siteID

View file

@ -38,4 +38,3 @@ class SmartInitRequest(object):
def setSiteID(self, siteID):
self.siteID = siteID

View file

@ -59,4 +59,3 @@ from .PurgeGfeGridsRequest import PurgeGfeGridsRequest
from .SaveASCIIGridsRequest import SaveASCIIGridsRequest
from .SmartInitRequest import SmartInitRequest
from .RsyncGridsToCWFRequest import RsyncGridsToCWFRequest

View file

@ -5,5 +5,3 @@ __all__ = [
'notify',
'request'
]

View file

@ -50,4 +50,3 @@ class Lock(object):
+ ', ' + time.strftime(timeformat, t1)
msg += " WsId: " + str(self.wsId)
return msg

View file

@ -40,4 +40,3 @@ class LockTable(object):
for i in self.locks:
msg += "\n Lock: " + str(i)
return msg

View file

@ -6,4 +6,3 @@ __all__ = [
from .Lock import Lock
from .LockTable import LockTable

View file

@ -10,4 +10,3 @@ class ServerMsg(object):
def setMessage(self, message):
self.message = message

View file

@ -26,10 +26,10 @@ class ServerResponse(object):
self.notifications = notifications
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):
if (self.isOkay()):
if self.isOkay():
return ""
else:
compMessage = ""

View file

@ -6,4 +6,3 @@ __all__ = [
from .ServerMsg import ServerMsg
from .ServerResponse import ServerResponse

View file

@ -34,4 +34,3 @@ class DBInvChangeNotification(GfeNotification.GfeNotification):
msg = 'Additions' + str(self.additions) + '\n'
msg += 'Deletions' + str(self.deletions)
return msg

View file

@ -22,7 +22,6 @@ class GfeNotification(with_metaclass(abc.ABCMeta, object)):
def setSiteID(self, siteID):
self.siteID = siteID
def getSourceID(self):
return self.sourceID

View file

@ -39,4 +39,3 @@ class GridHistoryUpdateNotification(GfeNotification):
msg = "ParmID: " + str(self.parmId)
msg += '\n' + "Histories: " + str(self.histories)
return msg

View file

@ -48,4 +48,3 @@ class GridUpdateNotification(GfeNotification):
msg += '\n' + "Replacement TimeRange: " + str(self.replacementTimeRange)
msg += '\n' + "Histories: " + str(self.histories)
return msg

View file

@ -24,4 +24,3 @@ class LockNotification(GfeNotification):
def __str__(self):
return str(self.lockTable)

View file

@ -40,4 +40,3 @@ class UserMessageNotification(GfeNotification):
msg += 'Priority: ' + str(self.priority) + '\n'
msg += 'Category: ' + str(self.category) + '\n'
return msg

View file

@ -16,4 +16,3 @@ from .GridHistoryUpdateNotification import GridHistoryUpdateNotification
from .GridUpdateNotification import GridUpdateNotification
from .LockNotification import LockNotification
from .UserMessageNotification import UserMessageNotification

Some files were not shown because too many files have changed in this diff Show more