python3 compliance notebook tested

This commit is contained in:
Michael James 2018-09-06 12:11:36 -06:00
parent edb5c276e8
commit f172333430
146 changed files with 619 additions and 471 deletions

View file

@ -18,7 +18,7 @@
# #
import logging import logging
import NotificationMessage from . import NotificationMessage
class AlertVizHandler(logging.Handler): class AlertVizHandler(logging.Handler):

View file

@ -46,10 +46,10 @@ def convertToDateTime(timeArg):
return datetime.datetime(*timeArg[:6]) return datetime.datetime(*timeArg[:6])
elif isinstance(timeArg, float): elif isinstance(timeArg, float):
# seconds as float, should be avoided due to floating point errors # seconds as float, should be avoided due to floating point errors
totalSecs = long(timeArg) totalSecs = int(timeArg)
micros = int((timeArg - totalSecs) * MICROS_IN_SECOND) micros = int((timeArg - totalSecs) * MICROS_IN_SECOND)
return _convertSecsAndMicros(totalSecs, micros) return _convertSecsAndMicros(totalSecs, micros)
elif isinstance(timeArg, (int, long)): elif isinstance(timeArg, (int, int)):
# seconds as integer # seconds as integer
totalSecs = timeArg totalSecs = timeArg
return _convertSecsAndMicros(totalSecs, 0) return _convertSecsAndMicros(totalSecs, 0)

View file

@ -4,14 +4,14 @@
from string import Template from string import Template
import ctypes import ctypes
import stomp from . import stomp
import socket import socket
import sys import sys
import time import time
import threading import threading
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
import ThriftClient from . import ThriftClient
from dynamicserialize.dstypes.com.raytheon.uf.common.alertviz import AlertVizRequest from dynamicserialize.dstypes.com.raytheon.uf.common.alertviz import AlertVizRequest
from dynamicserialize import DynamicSerializationManager from dynamicserialize import DynamicSerializationManager
@ -75,8 +75,8 @@ class NotificationMessage:
priorityInt = int(5) priorityInt = int(5)
if (priorityInt < 0 or priorityInt > 5): if (priorityInt < 0 or priorityInt > 5):
print "Error occurred, supplied an invalid Priority value: " + str(priorityInt) print("Error occurred, supplied an invalid Priority value: " + str(priorityInt))
print "Priority values are 0, 1, 2, 3, 4 and 5." print("Priority values are 0, 1, 2, 3, 4 and 5.")
sys.exit(1) sys.exit(1)
if priorityInt is not None: if priorityInt is not None:
@ -86,7 +86,7 @@ class NotificationMessage:
def connection_timeout(self, connection): def connection_timeout(self, connection):
if (connection is not None and not connection.is_connected()): if (connection is not None and not connection.is_connected()):
print "Connection Retry Timeout" print("Connection Retry Timeout")
for tid, tobj in threading._active.items(): for tid, tobj in threading._active.items():
if tobj.name is "MainThread": if tobj.name is "MainThread":
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(SystemExit)) res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(SystemExit))
@ -138,14 +138,14 @@ class NotificationMessage:
serverResponse = None serverResponse = None
try: try:
serverResponse = thriftClient.sendRequest(alertVizRequest) serverResponse = thriftClient.sendRequest(alertVizRequest)
except Exception, ex: except Exception as ex:
print "Caught exception submitting AlertVizRequest: ", str(ex) print("Caught exception submitting AlertVizRequest: ", str(ex))
if (serverResponse != "None"): if (serverResponse != "None"):
print "Error occurred submitting Notification Message to AlertViz receiver: ", serverResponse print("Error occurred submitting Notification Message to AlertViz receiver: ", serverResponse)
sys.exit(1) sys.exit(1)
else: else:
print "Response: " + str(serverResponse) print("Response: " + str(serverResponse))
def createRequest(message, priority, source, category, audioFile, filters): def createRequest(message, priority, source, category, audioFile, filters):
obj = AlertVizRequest() obj = AlertVizRequest()

View file

@ -58,7 +58,7 @@ class QpidSubscriber:
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)
@ -69,7 +69,7 @@ class QpidSubscriber:
queue = self.__session.incoming(local_queue_name) queue = self.__session.incoming(local_queue_name)
self.__session.message_subscribe(serverQueueName, destination=local_queue_name) self.__session.message_subscribe(serverQueueName, destination=local_queue_name)
queue.start() queue.start()
print "Connection complete to broker on", self.host print("Connection complete to broker on", self.host)
self.__queueStarted = True self.__queueStarted = True
while self.subscribed: while self.subscribed:

150
awips/RadarCommon.py Normal file
View file

@ -0,0 +1,150 @@
##
##
#
# Common methods for the a2gtrad and a2advrad scripts.
#
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 08/13/2014 3393 nabowle Initial creation to contain common
# code for a2*radStub scripts.
# 03/15/2015 mjames@ucar Edited/added to awips package as RadarCommon
#
#
import argparse
import sys
from datetime import datetime
from datetime import timedelta
from awips import ThriftClient
from dynamicserialize.dstypes.com.raytheon.uf.common.time import TimeRange
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.radar.request import GetRadarDataRecordRequest
def get_datetime_str(record):
"""
Get the datetime string for a record.
:param record: the record to get data for.
:returns: datetime string.
"""
return str(record.getDataTime())[0:19].replace(" ","_") + ".0"
def get_data_type(azdat):
"""
Get the radar file type (radial or raster).
:param azdat: Boolean.
:returns: Radial or raster.
"""
if azdat:
dattyp = "radial"
else :
dattyp = "raster"
return dattyp
def get_hdf5_data(idra):
rdat = []
azdat = []
depVals = []
threshVals = []
if len(idra) > 0:
for ii in range(len(idra)):
if idra[ii].getName() == b"Data":
rdat = idra[ii]
elif idra[ii].getName() == b"Angles":
azdat = idra[ii]
dattyp = "radial"
elif idra[ii].getName() == b"DependentValues":
depVals = idra[ii].getShortData()
elif idra[ii].getName() == b"Thresholds":
threshVals = idra[ii].getShortData()
return rdat,azdat,depVals,threshVals
def get_header(record, format, xLen, yLen, azdat, description):
# Encode dimensions, time, mapping, description, tilt, and VCP
mytime = get_datetime_str(record)
dattyp = get_data_type(azdat)
if format :
msg = str(xLen) + " " + str(yLen) + " " + mytime + " " + \
dattyp + " " + str(record.getLatitude()) + " " + \
str(record.getLongitude()) + " " + \
str(record.getElevation()) + " " + \
str(record.getElevationNumber()) + " " + \
description + " " + str(record.getTrueElevationAngle()) + " " + \
str(record.getVolumeCoveragePattern()) + "\n"
#"%.1f"%
else :
msg = str(xLen) + " " + str(yLen) + " " + mytime + " " + \
dattyp + " " + description + " " + \
str(record.getTrueElevationAngle()) + " " + \
str(record.getVolumeCoveragePattern()) + "\n"
return msg
def encode_thresh_vals(threshVals):
spec = [".", "TH", "ND", "RF", "BI", "GC", "IC", "GR", "WS", "DS",
"RA", "HR", "BD", "HA", "UK"]
nnn = len(threshVals)
j = 0
msg = ""
while j<nnn :
lo = threshVals[j] % 256
hi = threshVals[j] / 256
msg += " "
j += 1
if hi < 0 :
if lo > 14 :
msg += "."
else :
msg += spec[lo]
continue
if hi % 16 >= 8 :
msg += ">"
elif hi % 8 >= 4 :
msg += "<"
if hi % 4 >= 2 :
msg += "+"
elif hi % 2 >= 1 :
msg += "-"
if hi >= 64 :
msg += "%.2f"%(lo*0.01)
elif hi % 64 >= 32 :
msg += "%.2f"%(lo*0.05)
elif hi % 32 >= 16 :
msg += "%.1f"%(lo*0.1)
else :
msg += str(lo)
msg += "\n"
return msg
def encode_dep_vals(depVals):
nnn = len(depVals)
j = 0
msg = []
while j<nnn :
msg.append(str(depVals[j]))
j += 1
return msg
def encode_radial(azVals):
azValsLen = len(azVals)
j = 0
msg = []
while j<azValsLen :
msg.append(azVals[j])
j += 1
return msg

View file

@ -1,7 +1,10 @@
## ##
## ##
import httplib try:
import http.client as httpcl
except ImportError:
import httplib as httpcl
from dynamicserialize import DynamicSerializationManager from dynamicserialize import DynamicSerializationManager
from dynamicserialize.dstypes.com.raytheon.uf.common.serialization.comm.response import ServerErrorResponse from dynamicserialize.dstypes.com.raytheon.uf.common.serialization.comm.response import ServerErrorResponse
from dynamicserialize.dstypes.com.raytheon.uf.common.serialization import SerializableExceptionWrapper from dynamicserialize.dstypes.com.raytheon.uf.common.serialization import SerializableExceptionWrapper
@ -38,12 +41,12 @@ class ThriftClient:
if (len(hostParts) > 1): if (len(hostParts) > 1):
hostString = hostParts[0] hostString = hostParts[0]
self.__uri = "/" + hostParts[1] self.__uri = "/" + hostParts[1]
self.__httpConn = httplib.HTTPConnection(hostString) self.__httpConn = httpcl.HTTPConnection(hostString)
else: else:
if (port is None): if (port is None):
self.__httpConn = httplib.HTTPConnection(host) self.__httpConn = httpcl.HTTPConnection(host)
else: else:
self.__httpConn = httplib.HTTPConnection(host, port) self.__httpConn = httpcl.HTTPConnection(host, port)
self.__uri = uri self.__uri = uri

View file

@ -53,7 +53,6 @@ def determineDrtOffset(timeStr):
times = timeStr.split(",") times = timeStr.split(",")
t1 = makeTime(times[0]) t1 = makeTime(times[0])
t2 = makeTime(times[1]) t2 = makeTime(times[1])
#print "time offset", t1-t2, (t1-t2)/3600
return t1-t2, launchStr return t1-t2, launchStr
# Check for synchronized mode # Check for synchronized mode
synch = 0 synch = 0
@ -61,22 +60,18 @@ def determineDrtOffset(timeStr):
timeStr = timeStr[1:] timeStr = timeStr[1:]
synch = 1 synch = 1
drt_t = makeTime(timeStr) drt_t = makeTime(timeStr)
#print "input", year, month, day, hour, minute
gm = time.gmtime() gm = time.gmtime()
cur_t = time.mktime(gm) cur_t = time.mktime(gm)
# Synchronize to most recent hour # Synchronize to most recent hour
# i.e. "truncate" cur_t to most recent hour. # i.e. "truncate" cur_t to most recent hour.
#print "gmtime", gm
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' % (`gm[0]`,`gm[1]`,`gm[2]`,`gm[3]`) curStr = '%4s%2s%2s_%2s00\n' % (gm[0],gm[1],gm[2],gm[3])
curStr = curStr.replace(' ','0') curStr = curStr.replace(' ','0')
launchStr = timeStr + "," + curStr launchStr = timeStr + "," + curStr
#print "drt, cur", drt_t, cur_t
offset = drt_t - cur_t offset = drt_t - cur_t
#print "offset", offset, offset/3600, launchStr
return int(offset), launchStr return int(offset), launchStr
def makeTime(timeStr): def makeTime(timeStr):

View file

@ -56,16 +56,13 @@ from awips.dataaccess.PyGeometryNotification import PyGeometryNotification
from awips.dataaccess.PyGridNotification import PyGridNotification from awips.dataaccess.PyGridNotification import PyGridNotification
THRIFT_HOST = subprocess.check_output( THRIFT_HOST = "edex"
"source /awips2/fxa/bin/setup.env; echo $DEFAULT_HOST",
shell=True).strip()
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 sys.modules.has_key('jep'): 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
# be obvious that something is configured wrong when running from within # be obvious that something is configured wrong when running from within
# Java instead of allowing false confidence and fallback behavior # Java instead of allowing false confidence and fallback behavior

View file

@ -29,18 +29,18 @@ class PyGeometryData(IGeometryData, PyData.PyData):
self.__geometry = geometry self.__geometry = geometry
self.__dataMap = {} self.__dataMap = {}
tempDataMap = geoDataRecord.getDataMap() tempDataMap = geoDataRecord.getDataMap()
for key, value in tempDataMap.items(): for key, value in list(tempDataMap.items()):
self.__dataMap[key] = (value[0], value[1], value[2]) self.__dataMap[key] = (value[0], value[1], value[2])
def getGeometry(self): def getGeometry(self):
return self.__geometry return self.__geometry
def getParameters(self): def getParameters(self):
return self.__dataMap.keys() return list(self.__dataMap.keys())
def getString(self, param): def getString(self, param):
value = self.__dataMap[param][0] value = self.__dataMap[param][0]
return str(value) return value
def getNumber(self, param): def getNumber(self, param):
value = self.__dataMap[param][0] value = self.__dataMap[param][0]
@ -48,7 +48,7 @@ class PyGeometryData(IGeometryData, PyData.PyData):
if t == 'INT' or t == 'SHORT': if t == 'INT' or t == 'SHORT':
return int(value) return int(value)
elif t == 'LONG': elif t == 'LONG':
return long(value) return int(value)
elif t == 'FLOAT': elif t == 'FLOAT':
return float(value) return float(value)
elif t == 'DOUBLE': elif t == 'DOUBLE':

View file

@ -15,7 +15,7 @@
# Sep 07, 2017 6175 tgurney Override messageReceived in subclasses # Sep 07, 2017 6175 tgurney Override messageReceived in subclasses
# #
from six import with_metaclass
import abc import abc
import time import time
import traceback import traceback
@ -28,14 +28,12 @@ from awips.ThriftClient import ThriftRequestException
from dynamicserialize.dstypes.com.raytheon.uf.common.time import DataTime from dynamicserialize.dstypes.com.raytheon.uf.common.time import DataTime
class PyNotification(INotificationSubscriber): class PyNotification(with_metaclass(abc.ABCMeta, INotificationSubscriber)):
""" """
Receives notifications for new data and retrieves the data that meets Receives notifications for new data and retrieves the data that meets
specified filtering criteria. specified filtering criteria.
""" """
__metaclass__ = abc.ABCMeta
def __init__(self, request, filter, host='localhost', port=5672, requestHost='localhost'): def __init__(self, request, filter, host='localhost', port=5672, requestHost='localhost'):
self.DAL = DataAccessLayer self.DAL = DataAccessLayer
self.DAL.changeEDEXHost(requestHost) self.DAL.changeEDEXHost(requestHost)

View file

@ -106,7 +106,7 @@ class ThriftClientRouter(object):
response = self._client.sendRequest(gridDataRequest) response = self._client.sendRequest(gridDataRequest)
locSpecificData = {} locSpecificData = {}
locNames = response.getSiteNxValues().keys() locNames = list(response.getSiteNxValues().keys())
for location in locNames: for location in locNames:
nx = response.getSiteNxValues()[location] nx = response.getSiteNxValues()[location]
ny = response.getSiteNyValues()[location] ny = response.getSiteNyValues()[location]

View file

@ -26,6 +26,7 @@ __all__ = [
] ]
import abc import abc
from six import with_metaclass
class IDataRequest(object): class IDataRequest(object):
""" """
@ -149,11 +150,10 @@ class IDataRequest(object):
class IData(object): class IData(with_metaclass(abc.ABCMeta, object)):
""" """
An IData representing data returned from the DataAccessLayer. An IData representing data returned from the DataAccessLayer.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def getAttribute(self, key): def getAttribute(self, key):
@ -337,12 +337,11 @@ class IGeometryData(IData):
return return
class INotificationSubscriber(object): class INotificationSubscriber(with_metaclass(abc.ABCMeta, object)):
""" """
An INotificationSubscriber representing a notification filter returned from An INotificationSubscriber representing a notification filter returned from
the DataNotificationLayer. the DataNotificationLayer.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def subscribe(self, callback): def subscribe(self, callback):
@ -361,12 +360,11 @@ class INotificationSubscriber(object):
"""Closes the notification subscriber""" """Closes the notification subscriber"""
pass pass
class INotificationFilter(object): class INotificationFilter(with_metaclass(abc.ABCMeta, object)):
""" """
Represents data required to filter a set of URIs and Represents data required to filter a set of URIs and
return a corresponding list of IDataRequest to retrieve data for. return a corresponding list of IDataRequest to retrieve data for.
""" """
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def accept(dataUri): def accept(dataUri):
pass pass

View file

@ -15,7 +15,10 @@ import urllib2
from json import load as loadjson from json import load as loadjson
from xml.etree.ElementTree import parse as parseXml from xml.etree.ElementTree import parse as parseXml
from base64 import b64encode from base64 import b64encode
from StringIO import StringIO try:
from StringIO import StringIO
except ImportError:
from io import StringIO
from getpass import getuser from getpass import getuser
import dateutil.parser import dateutil.parser
import contextlib import contextlib
@ -103,7 +106,7 @@ class _LocalizationOutput(StringIO):
urllib2.urlopen(request) urllib2.urlopen(request)
except urllib2.HTTPError as e: except urllib2.HTTPError as e:
if e.code == 409: if e.code == 409:
raise LocalizationFileVersionConflictException, e.read() raise LocalizationFileVersionConflictException(e.read())
else: else:
raise e raise e
def __enter__(self): def __enter__(self):
@ -166,12 +169,12 @@ class LocalizationFile(object):
if not(self.isDirectory()): if not(self.isDirectory()):
checksum = response.headers["Content-MD5"] checksum = response.headers["Content-MD5"]
if self.checksum != checksum: if self.checksum != checksum:
raise RuntimeError, "Localization checksum mismatch " + self.checksum + " " + checksum raise RuntimeError("Localization checksum mismatch " + self.checksum + " " + checksum)
return contextlib.closing(response) return contextlib.closing(response)
elif mode == 'w': elif mode == 'w':
return _LocalizationOutput(self._manager, self) return _LocalizationOutput(self._manager, self)
else: else:
raise ValueError, "mode string must be 'r' or 'w' not " + str(r) raise ValueError("mode string must be 'r' or 'w' not " + str(r))
def delete(self): def delete(self):
"""Delete this file from the server""" """Delete this file from the server"""
request = self._manager._buildRequest(self.context, self.path, method='DELETE') request = self._manager._buildRequest(self.context, self.path, method='DELETE')
@ -180,7 +183,7 @@ class LocalizationFile(object):
urllib2.urlopen(request) urllib2.urlopen(request)
except urllib2.HTTPError as e: except urllib2.HTTPError as e:
if e.code == 409: if e.code == 409:
raise LocalizationFileVersionConflictException, e.read() raise LocalizationFileVersionConflictException(e.read())
else: else:
raise e raise e
def exists(self): def exists(self):
@ -333,7 +336,7 @@ class LocalizationFileManager(object):
exists = True exists = True
if not(response.geturl().endswith("/")): if not(response.geturl().endswith("/")):
# For ordinary files the server sends a redirect to remove the slash. # For ordinary files the server sends a redirect to remove the slash.
raise LocalizationFileIsNotDirectoryException, "Not a directory: " + path raise LocalizationFileIsNotDirectoryException("Not a directory: " + path)
elif response.headers["Content-Type"] == "application/xml": elif response.headers["Content-Type"] == "application/xml":
fileList += _parseXmlList(self, response, context, path) fileList += _parseXmlList(self, response, context, path)
else: else:
@ -342,7 +345,7 @@ class LocalizationFileManager(object):
if e.code != 404: if e.code != 404:
raise e raise e
if not(exists): if not(exists):
raise LocalizationFileDoesNotExistException, "No such file or directory: " + path raise LocalizationFileDoesNotExistException("No such file or directory: " + path)
return fileList return fileList
def _get(self, context, path): def _get(self, context, path):
path = self._normalizePath(path) path = self._normalizePath(path)
@ -353,10 +356,10 @@ class LocalizationFileManager(object):
checksum = DIRECTORY_CHECKSUM; checksum = DIRECTORY_CHECKSUM;
else: else:
if "Content-MD5" not in resp.headers: if "Content-MD5" not in resp.headers:
raise RuntimeError, "Missing Content-MD5 header in response from " + resp.geturl() raise RuntimeError("Missing Content-MD5 header in response from " + resp.geturl())
checksum = resp.headers["Content-MD5"] checksum = resp.headers["Content-MD5"]
if "Last-Modified" not in resp.headers: if "Last-Modified" not in resp.headers:
raise RuntimeError, "Missing Last-Modified header in response from " + resp.geturl() raise RuntimeError("Missing Last-Modified header in response from " + resp.geturl())
timestamp = dateutil.parser.parse(resp.headers["Last-Modified"]) timestamp = dateutil.parser.parse(resp.headers["Last-Modified"])
return LocalizationFile(self, context, path, checksum, timestamp) return LocalizationFile(self, context, path, checksum, timestamp)
except urllib2.HTTPError as e: except urllib2.HTTPError as e:
@ -447,7 +450,7 @@ class LocalizationFileManager(object):
for context in self._contexts: for context in self._contexts:
if context.level == level: if context.level == level:
return self._get(context, path) return self._get(context, path)
raise ValueError, "No context defined for level " + level raise ValueError("No context defined for level " + level)
def __str__(self): def __str__(self):
contextsStr = '[' + ' '.join((str(c) for c in self._contexts)) + ']' contextsStr = '[' + ' '.join((str(c) for c in self._contexts)) + ']'
return '<' + self.__class__.__name__ + " for " + self._baseUrl + ' ' + contextsStr + '>' return '<' + self.__class__.__name__ + " for " + self._baseUrl + ' ' + contextsStr + '>'

View file

@ -103,9 +103,9 @@ class IngestViaQPID:
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:
print 'Unable to connect to Qpid' print('Unable to connect to Qpid')
def sendmessage(self, filepath, header): def sendmessage(self, filepath, header):
''' '''
@ -126,4 +126,4 @@ class IngestViaQPID:
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')

View file

@ -64,18 +64,26 @@
""" """
from __future__ import print_function
import hashlib import hashlib
import math import math
import random import random
import re import re
import socket import socket
import sys import sys
import thread
import threading import threading
import time import time
import types import types
import xml.dom.minidom import xml.dom.minidom
from cStringIO import StringIO try:
from StringIO import StringIO
except ImportError:
from io import StringIO
from functools import reduce
try:
import _thread
except ImportError:
import thread
# #
# stomp.py version number # stomp.py version number
@ -89,14 +97,14 @@ def _uuid( *args ):
(http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/213761) (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/213761)
""" """
t = long( time.time() * 1000 ) t = int( time.time() * 1000 )
r = long( random.random() * 100000000000000000L ) r = int( random.random() * 100000000000000000 )
try: try:
a = socket.gethostbyname( socket.gethostname() ) a = socket.gethostbyname( socket.gethostname() )
except: except:
# if we can't get a network address, just imagine one # if we can't get a network address, just imagine one
a = random.random() * 100000000000000000L a = random.random() * 100000000000000000
data = str(t) + ' ' + str(r) + ' ' + str(a) + ' ' + str(args) data = str(t) + ' ' + str(r) + ' ' + str(a) + ' ' + str(args)
md5 = hashlib.md5() md5 = hashlib.md5()
md5.update(data) md5.update(data)
@ -109,7 +117,7 @@ class DevNullLogger(object):
dummy logging class for environments without the logging module dummy logging class for environments without the logging module
""" """
def log(self, msg): def log(self, msg):
print msg print(msg)
def devnull(self, msg): def devnull(self, msg):
pass pass
@ -354,7 +362,7 @@ class Connection(object):
""" """
self.__running = True self.__running = True
self.__attempt_connection() self.__attempt_connection()
thread.start_new_thread(self.__receiver_loop, ()) _thread.start_new_thread(self.__receiver_loop, ())
def stop(self): def stop(self):
""" """
@ -417,7 +425,7 @@ class Connection(object):
def begin(self, headers={}, **keyword_headers): def begin(self, headers={}, **keyword_headers):
use_headers = self.__merge_headers([headers, keyword_headers]) use_headers = self.__merge_headers([headers, keyword_headers])
if not 'transaction' in use_headers.keys(): if not 'transaction' in list(use_headers.keys()):
use_headers['transaction'] = _uuid() use_headers['transaction'] = _uuid()
self.__send_frame_helper('BEGIN', '', use_headers, [ 'transaction' ]) self.__send_frame_helper('BEGIN', '', use_headers, [ 'transaction' ])
return use_headers['transaction'] return use_headers['transaction']
@ -429,7 +437,7 @@ class Connection(object):
self.__send_frame_helper('COMMIT', '', self.__merge_headers([headers, keyword_headers]), [ 'transaction' ]) self.__send_frame_helper('COMMIT', '', self.__merge_headers([headers, keyword_headers]), [ 'transaction' ])
def connect(self, headers={}, **keyword_headers): def connect(self, headers={}, **keyword_headers):
if keyword_headers.has_key('wait') and keyword_headers['wait']: if 'wait' in keyword_headers and keyword_headers['wait']:
while not self.is_connected(): time.sleep(0.1) while not self.is_connected(): time.sleep(0.1)
del keyword_headers['wait'] del keyword_headers['wait']
self.__send_frame_helper('CONNECT', '', self.__merge_headers([self.__connect_headers, headers, keyword_headers]), [ ]) self.__send_frame_helper('CONNECT', '', self.__merge_headers([self.__connect_headers, headers, keyword_headers]), [ ])
@ -515,11 +523,11 @@ class Connection(object):
if type(required_header_key) == tuple: if type(required_header_key) == tuple:
found_alternative = False found_alternative = False
for alternative in required_header_key: for alternative in required_header_key:
if alternative in headers.keys(): if alternative in list(headers.keys()):
found_alternative = True found_alternative = True
if not found_alternative: if not found_alternative:
raise KeyError("Command %s requires one of the following headers: %s" % (command, str(required_header_key))) raise KeyError("Command %s requires one of the following headers: %s" % (command, str(required_header_key)))
elif not required_header_key in headers.keys(): elif not required_header_key in list(headers.keys()):
raise KeyError("Command %s requires header %r" % (command, required_header_key)) raise KeyError("Command %s requires header %r" % (command, required_header_key))
self.__send_frame(command, headers, payload) self.__send_frame(command, headers, payload)
@ -533,7 +541,7 @@ class Connection(object):
if self.__socket is not None: if self.__socket is not None:
frame = '%s\n%s\n%s\x00' % (command, frame = '%s\n%s\n%s\x00' % (command,
reduce(lambda accu, key: accu + ('%s:%s\n' % (key, headers[key])), headers.keys(), ''), reduce(lambda accu, key: accu + ('%s:%s\n' % (key, list(headers[key]))), headers.keys(), ''),
payload) payload)
self.__socket.sendall(frame) self.__socket.sendall(frame)
log.debug("Sent frame: type=%s, headers=%r, body=%r" % (command, headers, payload)) log.debug("Sent frame: type=%s, headers=%r, body=%r" % (command, headers, payload))
@ -690,7 +698,7 @@ class Connection(object):
assert len(pair) == 2 assert len(pair) == 2
entries[pair[0]] = pair[1] entries[pair[0]] = pair[1]
return entries return entries
except Exception, ex: except Exception as ex:
# unable to parse message. return original # unable to parse message. return original
return body return body
@ -745,7 +753,7 @@ class Connection(object):
break break
except socket.error: except socket.error:
self.__socket = None self.__socket = None
if type(sys.exc_info()[1]) == types.TupleType: if type(sys.exc_info()[1]) == tuple:
exc = sys.exc_info()[1][1] exc = sys.exc_info()[1][1]
else: else:
exc = sys.exc_info()[1] exc = sys.exc_info()[1]
@ -796,20 +804,20 @@ if __name__ == '__main__':
self.c.start() self.c.start()
def __print_async(self, frame_type, headers, body): def __print_async(self, frame_type, headers, body):
print "\r \r", print("\r \r",)
print frame_type print(frame_type)
for header_key in headers.keys(): for header_key in list(headers.keys()):
print '%s: %s' % (header_key, headers[header_key]) print('%s: %s' % (header_key, headers[header_key]))
print print("")
print body print(body)
print '> ', print('> ',)
sys.stdout.flush() sys.stdout.flush()
def on_connecting(self, host_and_port): def on_connecting(self, host_and_port):
self.c.connect(wait=True) self.c.connect(wait=True)
def on_disconnected(self): def on_disconnected(self):
print "lost connection" print("lost connection")
def on_message(self, headers, body): def on_message(self, headers, body):
self.__print_async("MESSAGE", headers, body) self.__print_async("MESSAGE", headers, body)
@ -833,13 +841,13 @@ if __name__ == '__main__':
self.c.abort(transaction=args[1]) self.c.abort(transaction=args[1])
def begin(self, args): def begin(self, args):
print 'transaction id: %s' % self.c.begin() print('transaction id: %s' % self.c.begin())
def commit(self, args): def commit(self, args):
if len(args) < 2: if len(args) < 2:
print 'expecting: commit <transid>' print('expecting: commit <transid>')
else: else:
print 'committing %s' % args[1] print('committing %s' % args[1])
self.c.commit(transaction=args[1]) self.c.commit(transaction=args[1])
def disconnect(self, args): def disconnect(self, args):
@ -850,35 +858,35 @@ if __name__ == '__main__':
def send(self, args): def send(self, args):
if len(args) < 3: if len(args) < 3:
print 'expecting: send <destination> <message>' print('expecting: send <destination> <message>')
else: else:
self.c.send(destination=args[1], message=' '.join(args[2:])) self.c.send(destination=args[1], message=' '.join(args[2:]))
def sendtrans(self, args): def sendtrans(self, args):
if len(args) < 3: if len(args) < 3:
print 'expecting: sendtrans <destination> <transid> <message>' print('expecting: sendtrans <destination> <transid> <message>')
else: else:
self.c.send(destination=args[1], message="%s\n" % ' '.join(args[3:]), transaction=args[2]) self.c.send(destination=args[1], message="%s\n" % ' '.join(args[3:]), transaction=args[2])
def subscribe(self, args): def subscribe(self, args):
if len(args) < 2: if len(args) < 2:
print 'expecting: subscribe <destination> [ack]' print('expecting: subscribe <destination> [ack]')
elif len(args) > 2: elif len(args) > 2:
print 'subscribing to "%s" with acknowledge set to "%s"' % (args[1], args[2]) print('subscribing to "%s" with acknowledge set to "%s"' % (args[1], args[2]))
self.c.subscribe(destination=args[1], ack=args[2]) self.c.subscribe(destination=args[1], ack=args[2])
else: else:
print 'subscribing to "%s" with auto acknowledge' % args[1] print('subscribing to "%s" with auto acknowledge' % args[1])
self.c.subscribe(destination=args[1], ack='auto') self.c.subscribe(destination=args[1], ack='auto')
def unsubscribe(self, args): def unsubscribe(self, args):
if len(args) < 2: if len(args) < 2:
print 'expecting: unsubscribe <destination>' print('expecting: unsubscribe <destination>')
else: else:
print 'unsubscribing from "%s"' % args[1] print('unsubscribing from "%s"' % args[1])
self.c.unsubscribe(destination=args[1]) self.c.unsubscribe(destination=args[1])
if len(sys.argv) > 5: if len(sys.argv) > 5:
print 'USAGE: stomp.py [host] [port] [user] [passcode]' print('USAGE: stomp.py [host] [port] [user] [passcode]')
sys.exit(1) sys.exit(1)
if len(sys.argv) >= 2: if len(sys.argv) >= 2:
@ -900,7 +908,7 @@ if __name__ == '__main__':
st = StompTester(host, port, user, passcode) st = StompTester(host, port, user, passcode)
try: try:
while True: while True:
line = raw_input("\r> ") line = input("\r> ")
if not line or line.lstrip().rstrip() == '': if not line or line.lstrip().rstrip() == '':
continue continue
elif 'quit' in line or 'disconnect' in line: elif 'quit' in line or 'disconnect' in line:
@ -910,7 +918,7 @@ if __name__ == '__main__':
if not command.startswith("on_") and hasattr(st, command): if not command.startswith("on_") and hasattr(st, command):
getattr(st, command)(split) getattr(st, command)(split)
else: else:
print 'unrecognized command' print('unrecognized command')
finally: finally:
st.disconnect(None) st.disconnect(None)

View file

@ -1965,7 +1965,7 @@ upgradeHazardsDict = {
def checkForUpgrade(pPhen, pSig, cPhen, cSig): def checkForUpgrade(pPhen, pSig, cPhen, cSig):
proposed = pPhen + "." + pSig proposed = pPhen + "." + pSig
current = cPhen + "." + cSig current = cPhen + "." + cSig
if upgradeHazardsDict.has_key(proposed): if proposed in upgradeHazardsDict:
if current in upgradeHazardsDict[proposed]: if current in upgradeHazardsDict[proposed]:
return 1 return 1
else: else:
@ -2016,7 +2016,7 @@ downgradeHazardsDict = {
def checkForDowngrade(pPhen, pSig, cPhen, cSig): def checkForDowngrade(pPhen, pSig, cPhen, cSig):
proposed = pPhen + "." + pSig proposed = pPhen + "." + pSig
current = cPhen + "." + cSig current = cPhen + "." + cSig
if downgradeHazardsDict.has_key(proposed): if proposed in downgradeHazardsDict:
if current in downgradeHazardsDict[proposed]: if current in downgradeHazardsDict[proposed]:
return 1 return 1
else: else:

View file

@ -23,7 +23,7 @@
import os import os
import logging import logging
from awips import AlertVizHandler from awips import AlertVizHandler
import Record from . import Record
avh = AlertVizHandler.AlertVizHandler(host=os.getenv("BROKER_ADDR","localhost"), port=9581, category='LOCAL', source='ANNOUNCER', level=logging.NOTSET) avh = AlertVizHandler.AlertVizHandler(host=os.getenv("BROKER_ADDR","localhost"), port=9581, category='LOCAL', source='ANNOUNCER', level=logging.NOTSET)
record = Record.Record(10) record = Record.Record(10)

View file

@ -99,7 +99,7 @@ class BaseRadarTestCase(baseDafTestCase.DafTestCase):
self.assertEqual(record.getAttribute('icao'), 1000) self.assertEqual(record.getAttribute('icao'), 1000)
def testGetDataWithEqualsLong(self): def testGetDataWithEqualsLong(self):
gridData = self.runConstraintTest('icao', '=', 1000L) gridData = self.runConstraintTest('icao', '=', 1000)
for record in gridData: for record in gridData:
self.assertEqual(record.getAttribute('icao'), 1000) self.assertEqual(record.getAttribute('icao'), 1000)

View file

@ -103,7 +103,7 @@ class BinLightningTestCase(baseDafTestCase.DafTestCase):
self.assertEqual(record.getAttribute('source'), 1000) self.assertEqual(record.getAttribute('source'), 1000)
def testGetDataWithEqualsLong(self): def testGetDataWithEqualsLong(self):
geomData = self._runConstraintTest('source', '=', 1000L) geomData = self._runConstraintTest('source', '=', 1000)
for record in geomData: for record in geomData:
self.assertEqual(record.getAttribute('source'), 1000) self.assertEqual(record.getAttribute('source'), 1000)

View file

@ -120,7 +120,7 @@ class BufrUaTestCase(baseDafTestCase.DafTestCase):
self.assertEqual(record.getString('rptType'), '2022') self.assertEqual(record.getString('rptType'), '2022')
def testGetDataWithEqualsLong(self): def testGetDataWithEqualsLong(self):
geometryData = self._runConstraintTest('reportType', '=', 2022L) geometryData = self._runConstraintTest('reportType', '=', 2022)
for record in geometryData: for record in geometryData:
self.assertEqual(record.getString('rptType'), '2022') self.assertEqual(record.getString('rptType'), '2022')

View file

@ -255,7 +255,7 @@ class ClimateTestCase(baseDafTestCase.DafTestCase):
self.assertEqual(record.getNumber('avg_daily_max'), 70) self.assertEqual(record.getNumber('avg_daily_max'), 70)
def testGetDataWithEqualsLong(self): def testGetDataWithEqualsLong(self):
geometryData = self._runConstraintTest('avg_daily_max', '=', 70L) geometryData = self._runConstraintTest('avg_daily_max', '=', 70)
for record in geometryData: for record in geometryData:
self.assertEqual(record.getNumber('avg_daily_max'), 70) self.assertEqual(record.getNumber('avg_daily_max'), 70)

View file

@ -81,7 +81,7 @@ class CommonObsSpatialTestCase(baseDafTestCase.DafTestCase):
self.assertEqual(record.getNumber('catalogtype'), 32) self.assertEqual(record.getNumber('catalogtype'), 32)
def testGetDataWithEqualsLong(self): def testGetDataWithEqualsLong(self):
geometryData = self._runConstraintTest('elevation', '=', 0L) geometryData = self._runConstraintTest('elevation', '=', 0)
for record in geometryData: for record in geometryData:
self.assertEqual(record.getNumber('elevation'), 0) self.assertEqual(record.getNumber('elevation'), 0)

View file

@ -138,7 +138,7 @@ class GridTestCase(baseDafTestCase.DafTestCase):
self.assertEqual(record.getAttribute('info.level.levelonevalue'), 2000) self.assertEqual(record.getAttribute('info.level.levelonevalue'), 2000)
def testGetDataWithEqualsLong(self): def testGetDataWithEqualsLong(self):
gridData = self._runConstraintTest('info.level.levelonevalue', '=', 2000L) gridData = self._runConstraintTest('info.level.levelonevalue', '=', 2000)
for record in gridData: for record in gridData:
self.assertEqual(record.getAttribute('info.level.levelonevalue'), 2000) self.assertEqual(record.getAttribute('info.level.levelonevalue'), 2000)

View file

@ -152,9 +152,9 @@ class HydroTestCase(baseDafTestCase.DafTestCase):
self.assertEqual(record.getNumber('value'), 3) self.assertEqual(record.getNumber('value'), 3)
def testGetDataWithEqualsLong(self): def testGetDataWithEqualsLong(self):
geometryData = self._runConstraintTest('value', '=', 3L) geometryData = self._runConstraintTest('value', '=', 3)
for record in geometryData: for record in geometryData:
self.assertEqual(record.getNumber('value'), 3L) self.assertEqual(record.getNumber('value'), 3)
def testGetDataWithEqualsFloat(self): def testGetDataWithEqualsFloat(self):
geometryData = self._runConstraintTest('value', '=', 3.0) geometryData = self._runConstraintTest('value', '=', 3.0)

View file

@ -120,7 +120,7 @@ class MapsTestCase(baseDafTestCase.DafTestCase):
self.assertEqual(record.getNumber('reservoir'), 1) self.assertEqual(record.getNumber('reservoir'), 1)
def testGetDataWithEqualsLong(self): def testGetDataWithEqualsLong(self):
geometryData = self._runConstraintTest('reservoir', '=', 1L) geometryData = self._runConstraintTest('reservoir', '=', 1)
for record in geometryData: for record in geometryData:
self.assertEqual(record.getNumber('reservoir'), 1) self.assertEqual(record.getNumber('reservoir'), 1)

View file

@ -81,7 +81,7 @@ class RadarSpatialTestCase(baseDafTestCase.DafTestCase):
self.assertEqual(record.getNumber('immutablex'), 57) self.assertEqual(record.getNumber('immutablex'), 57)
def testGetDataWithEqualsLong(self): def testGetDataWithEqualsLong(self):
geometryData = self._runConstraintTest('immutablex', '=', 57L) geometryData = self._runConstraintTest('immutablex', '=', 57)
for record in geometryData: for record in geometryData:
self.assertEqual(record.getNumber('immutablex'), 57) self.assertEqual(record.getNumber('immutablex'), 57)

View file

@ -30,7 +30,7 @@ class RequestConstraintTestCase(unittest.TestCase):
self.assertTrue(new('=', 3).evaluate(3)) self.assertTrue(new('=', 3).evaluate(3))
self.assertTrue(new('=', 3).evaluate('3')) self.assertTrue(new('=', 3).evaluate('3'))
self.assertTrue(new('=', '3').evaluate(3)) self.assertTrue(new('=', '3').evaluate(3))
self.assertTrue(new('=', 12345).evaluate(12345L)) self.assertTrue(new('=', 12345).evaluate(12345))
self.assertTrue(new('=', 'a').evaluate('a')) self.assertTrue(new('=', 'a').evaluate('a'))
self.assertTrue(new('=', 'a').evaluate(u'a')) self.assertTrue(new('=', 'a').evaluate(u'a'))
self.assertTrue(new('=', 1.0001).evaluate(2.0 - 0.999999)) self.assertTrue(new('=', 1.0001).evaluate(2.0 - 0.999999))
@ -51,7 +51,7 @@ class RequestConstraintTestCase(unittest.TestCase):
self.assertFalse(new('!=', 3).evaluate('3')) self.assertFalse(new('!=', 3).evaluate('3'))
self.assertFalse(new('!=', '3').evaluate(3)) self.assertFalse(new('!=', '3').evaluate(3))
self.assertFalse(new('!=', 3).evaluate(3)) self.assertFalse(new('!=', 3).evaluate(3))
self.assertFalse(new('!=', 12345).evaluate(12345L)) self.assertFalse(new('!=', 12345).evaluate(12345))
self.assertFalse(new('!=', 'a').evaluate('a')) self.assertFalse(new('!=', 'a').evaluate('a'))
self.assertFalse(new('!=', 'a').evaluate(u'a')) self.assertFalse(new('!=', 'a').evaluate(u'a'))
self.assertFalse(new('!=', 1.0001).evaluate(2.0 - 0.9999)) self.assertFalse(new('!=', 1.0001).evaluate(2.0 - 0.9999))
@ -62,7 +62,7 @@ class RequestConstraintTestCase(unittest.TestCase):
self.assertTrue(new('>', 'a').evaluate('b')) self.assertTrue(new('>', 'a').evaluate('b'))
self.assertTrue(new('>', 3).evaluate(4)) self.assertTrue(new('>', 3).evaluate(4))
self.assertFalse(new('>', 20).evaluate(3)) self.assertFalse(new('>', 20).evaluate(3))
self.assertFalse(new('>', 12345).evaluate(12345L)) self.assertFalse(new('>', 12345).evaluate(12345))
self.assertFalse(new('>', 'a').evaluate('a')) self.assertFalse(new('>', 'a').evaluate('a'))
self.assertFalse(new('>', 'z').evaluate('a')) self.assertFalse(new('>', 'z').evaluate('a'))
self.assertFalse(new('>', 4).evaluate(3)) self.assertFalse(new('>', 4).evaluate(3))
@ -70,7 +70,7 @@ class RequestConstraintTestCase(unittest.TestCase):
def testEvaluateGreaterThanEquals(self): def testEvaluateGreaterThanEquals(self):
new = RequestConstraint.new new = RequestConstraint.new
self.assertTrue(new('>=', 3).evaluate(3)) self.assertTrue(new('>=', 3).evaluate(3))
self.assertTrue(new('>=', 12345).evaluate(12345L)) self.assertTrue(new('>=', 12345).evaluate(12345))
self.assertTrue(new('>=', 'a').evaluate('a')) self.assertTrue(new('>=', 'a').evaluate('a'))
self.assertTrue(new('>=', 1.0001).evaluate(1.0002)) self.assertTrue(new('>=', 1.0001).evaluate(1.0002))
self.assertTrue(new('>=', 'a').evaluate('b')) self.assertTrue(new('>=', 'a').evaluate('b'))
@ -84,7 +84,7 @@ class RequestConstraintTestCase(unittest.TestCase):
self.assertTrue(new('<', 'z').evaluate('a')) self.assertTrue(new('<', 'z').evaluate('a'))
self.assertTrue(new('<', 30).evaluate(4)) self.assertTrue(new('<', 30).evaluate(4))
self.assertFalse(new('<', 3).evaluate(3)) self.assertFalse(new('<', 3).evaluate(3))
self.assertFalse(new('<', 12345).evaluate(12345L)) self.assertFalse(new('<', 12345).evaluate(12345))
self.assertFalse(new('<', 'a').evaluate('a')) self.assertFalse(new('<', 'a').evaluate('a'))
self.assertFalse(new('<', 1.0001).evaluate(1.0002)) self.assertFalse(new('<', 1.0001).evaluate(1.0002))
self.assertFalse(new('<', 'a').evaluate('b')) self.assertFalse(new('<', 'a').evaluate('b'))
@ -95,7 +95,7 @@ class RequestConstraintTestCase(unittest.TestCase):
self.assertTrue(new('<=', 'z').evaluate('a')) self.assertTrue(new('<=', 'z').evaluate('a'))
self.assertTrue(new('<=', 20).evaluate(3)) self.assertTrue(new('<=', 20).evaluate(3))
self.assertTrue(new('<=', 3).evaluate(3)) self.assertTrue(new('<=', 3).evaluate(3))
self.assertTrue(new('<=', 12345).evaluate(12345L)) self.assertTrue(new('<=', 12345).evaluate(12345))
self.assertTrue(new('<=', 'a').evaluate('a')) self.assertTrue(new('<=', 'a').evaluate('a'))
self.assertFalse(new('<=', 1.0001).evaluate(1.0002)) self.assertFalse(new('<=', 1.0001).evaluate(1.0002))
self.assertFalse(new('<=', 'a').evaluate('b')) self.assertFalse(new('<=', 'a').evaluate('b'))

View file

@ -89,7 +89,7 @@ class SatelliteTestCase(baseDafTestCase.DafTestCase):
self.assertEqual(record.getAttribute('creatingEntity'), 1000) self.assertEqual(record.getAttribute('creatingEntity'), 1000)
def testGetDataWithEqualsLong(self): def testGetDataWithEqualsLong(self):
gridData = self._runConstraintTest('creatingEntity', '=', 1000L) gridData = self._runConstraintTest('creatingEntity', '=', 1000)
for record in gridData: for record in gridData:
self.assertEqual(record.getAttribute('creatingEntity'), 1000) self.assertEqual(record.getAttribute('creatingEntity'), 1000)

View file

@ -91,7 +91,7 @@ class SfcObsTestCase(baseDafTestCase.DafTestCase):
self.assertEqual(record.getString('reportType'), '1004') self.assertEqual(record.getString('reportType'), '1004')
def testGetDataWithEqualsLong(self): def testGetDataWithEqualsLong(self):
geometryData = self._runConstraintTest('reportType', '=', 1004L) geometryData = self._runConstraintTest('reportType', '=', 1004)
for record in geometryData: for record in geometryData:
self.assertEqual(record.getString('reportType'), '1004') self.assertEqual(record.getString('reportType'), '1004')

View file

@ -129,7 +129,7 @@ class WarningTestCase(baseDafTestCase.DafTestCase):
self.assertEqual(record.getString('etn'), '1000') self.assertEqual(record.getString('etn'), '1000')
def testGetDataWithEqualsLong(self): def testGetDataWithEqualsLong(self):
geometryData = self._runConstraintTest('etn', '=', 1000L) geometryData = self._runConstraintTest('etn', '=', 1000)
for record in geometryData: for record in geometryData:
self.assertEqual(record.getString('etn'), '1000') self.assertEqual(record.getString('etn'), '1000')

View file

@ -40,7 +40,7 @@ class ListenThread(threading.Thread):
self.qs.topicSubscribe(self.topicName, self.receivedMessage) self.qs.topicSubscribe(self.topicName, self.receivedMessage)
def receivedMessage(self, msg): def receivedMessage(self, msg):
print "Received message" print("Received message")
self.nMessagesReceived += 1 self.nMessagesReceived += 1
if self.waitSecond == 0: if self.waitSecond == 0:
fmsg = open('/tmp/rawMessage', 'w') fmsg = open('/tmp/rawMessage', 'w')
@ -49,21 +49,21 @@ class ListenThread(threading.Thread):
while self.waitSecond < TIME_TO_SLEEP and not self.stopped: while self.waitSecond < TIME_TO_SLEEP and not self.stopped:
if self.waitSecond % 60 == 0: if self.waitSecond % 60 == 0:
print time.strftime('%H:%M:%S'), "Sleeping and stuck in not so infinite while loop" print(time.strftime('%H:%M:%S'), "Sleeping and stuck in not so infinite while loop")
self.waitSecond += 1 self.waitSecond += 1
time.sleep(1) time.sleep(1)
print time.strftime('%H:%M:%S'), "Received", self.nMessagesReceived, "messages" print(time.strftime('%H:%M:%S'), "Received", self.nMessagesReceived, "messages")
def stop(self): def stop(self):
print "Stopping" print("Stopping")
self.stopped = True self.stopped = True
self.qs.close() self.qs.close()
def main(): def main():
print "Starting up at", time.strftime('%H:%M:%S') print("Starting up at", time.strftime('%H:%M:%S'))
topic = 'edex.alerts' topic = 'edex.alerts'
host = 'localhost' host = 'localhost'

View file

@ -19,7 +19,7 @@
# #
from thrift.transport import TTransport from thrift.transport import TTransport
import SelfDescribingBinaryProtocol, ThriftSerializationContext from . import SelfDescribingBinaryProtocol, ThriftSerializationContext
class DynamicSerializationManager: class DynamicSerializationManager:

View file

@ -21,6 +21,7 @@
# writeObject(). # writeObject().
# Apr 24, 2015 4425 nabowle Add Double support # Apr 24, 2015 4425 nabowle Add Double support
# Oct 17, 2016 5919 njensen Optimized for speed # Oct 17, 2016 5919 njensen Optimized for speed
# Sep 06, 2018 mjames@ucar Python3 compliance
# #
# #
@ -29,10 +30,10 @@ import inspect
import sys import sys
import types import types
import time import time
import numpy
import dynamicserialize import dynamicserialize
from dynamicserialize import dstypes, adapters from dynamicserialize import dstypes, adapters
import SelfDescribingBinaryProtocol from . import SelfDescribingBinaryProtocol
import numpy
DS_LEN = len('dynamicserialize.dstypes.') DS_LEN = len('dynamicserialize.dstypes.')
@ -55,17 +56,18 @@ def buildObjMap(module):
buildObjMap(dstypes) buildObjMap(dstypes)
pythonToThriftMap = { pythonToThriftMap = {
types.StringType: TType.STRING, bytes: TType.STRING,
types.IntType: TType.I32, int: TType.I32,
types.LongType: TType.I64, int: TType.I64,
types.ListType: TType.LIST, list: TType.LIST,
types.DictionaryType: TType.MAP, dict: TType.MAP,
type(set([])): TType.SET, type(set([])): TType.SET,
types.FloatType: SelfDescribingBinaryProtocol.FLOAT, float: SelfDescribingBinaryProtocol.FLOAT,
# types.FloatType: TType.DOUBLE, # types.FloatType: TType.DOUBLE,
types.BooleanType: TType.BOOL, bool: TType.BOOL,
types.InstanceType: TType.STRUCT, object: TType.STRUCT,
types.NoneType: TType.VOID, str: TType.STRING,
type(None): TType.VOID,
numpy.float32: SelfDescribingBinaryProtocol.FLOAT, numpy.float32: SelfDescribingBinaryProtocol.FLOAT,
numpy.int32: TType.I32, numpy.int32: TType.I32,
numpy.ndarray: TType.LIST, numpy.ndarray: TType.LIST,
@ -142,19 +144,19 @@ class ThriftSerializationContext(object):
def deserializeMessage(self): def deserializeMessage(self):
name = self.protocol.readStructBegin() name = self.protocol.readStructBegin()
name = name.decode('cp437')
name = name.replace('_', '.')
if name.isdigit(): if name.isdigit():
obj = self._deserializeType(int(name)) obj = self._deserializeType(int(name))
return obj return obj
name = name.replace('_', '.')
if name in adapters.classAdapterRegistry: if name in adapters.classAdapterRegistry:
return adapters.classAdapterRegistry[name].deserialize(self) return adapters.classAdapterRegistry[name].deserialize(self)
elif '$' in name: elif '$' in name:
# it's an inner class, we're going to hope it's an enum, treat it # it's an inner class, we're going to hope it's an enum, treat it
# special # special
fieldName, fieldType, fieldId = self.protocol.readFieldBegin() fieldName, fieldType, fieldId = self.protocol.readFieldBegin()
if fieldName != '__enumValue__': if fieldName.decode('utf8') != '__enumValue__':
raise dynamiceserialize.SerializationException( raise dynamicserialize.SerializationException("Expected to find enum payload. Found: " + fieldName)
"Expected to find enum payload. Found: " + fieldName)
obj = self.protocol.readString() obj = self.protocol.readString()
self.protocol.readFieldEnd() self.protocol.readFieldEnd()
return obj return obj
@ -181,7 +183,8 @@ class ThriftSerializationContext(object):
return False return False
elif fieldType != TType.VOID: elif fieldType != TType.VOID:
result = self._deserializeType(fieldType) result = self._deserializeType(fieldType)
lookingFor = "set" + fieldName[0].upper() + fieldName[1:] fn_str = bytes.decode(fieldName)
lookingFor = "set" + fn_str[0].upper() + fn_str[1:]
try: try:
setMethod = getattr(obj, lookingFor) setMethod = getattr(obj, lookingFor)
@ -199,7 +202,7 @@ class ThriftSerializationContext(object):
if size: if size:
if listType not in primitiveSupport: if listType not in primitiveSupport:
m = self.typeDeserializationMethod[listType] m = self.typeDeserializationMethod[listType]
result = [m() for n in xrange(size)] result = [m() for n in range(size)]
else: else:
result = self.listDeserializationMethod[listType](size) result = self.listDeserializationMethod[listType](size)
self.protocol.readListEnd() self.protocol.readListEnd()
@ -208,7 +211,7 @@ class ThriftSerializationContext(object):
def _deserializeMap(self): def _deserializeMap(self):
keyType, valueType, size = self.protocol.readMapBegin() keyType, valueType, size = self.protocol.readMapBegin()
result = {} result = {}
for n in xrange(size): for n in range(size):
# can't go off the type, due to java generics limitations dynamic serialize is # can't go off the type, due to java generics limitations dynamic serialize is
# serializing keys and values as void # serializing keys and values as void
key = self.typeDeserializationMethod[TType.STRUCT]() key = self.typeDeserializationMethod[TType.STRUCT]()
@ -220,7 +223,7 @@ class ThriftSerializationContext(object):
def _deserializeSet(self): def _deserializeSet(self):
setType, setSize = self.protocol.readSetBegin() setType, setSize = self.protocol.readSetBegin()
result = set([]) result = set([])
for n in xrange(setSize): for n in range(setSize):
result.add(self.typeDeserializationMethod[TType.STRUCT]()) result.add(self.typeDeserializationMethod[TType.STRUCT]())
self.protocol.readSetEnd() self.protocol.readSetEnd()
return result return result
@ -230,7 +233,7 @@ class ThriftSerializationContext(object):
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[types.InstanceType] return pythonToThriftMap[object]
else: else:
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))
@ -253,11 +256,14 @@ class ThriftSerializationContext(object):
self.protocol.writeStructBegin(fqn) self.protocol.writeStructBegin(fqn)
methods = inspect.getmembers(obj, inspect.ismethod) methods = inspect.getmembers(obj, inspect.ismethod)
fid = 1 fid = 1
#print(methods);
for m in methods: for m in methods:
methodName = m[0] methodName = m[0]
if methodName.startswith('get'): if methodName.startswith('get'):
fieldname = methodName[3].lower() + methodName[4:] fieldname = methodName[3].lower() + methodName[4:]
val = m[1]() val = m[1]()
#print(val);
dir(val);
ft = self._lookupType(val) ft = self._lookupType(val)
if ft == TType.STRUCT: if ft == TType.STRUCT:
fc = val.__module__[DS_LEN:] fc = val.__module__[DS_LEN:]

View file

@ -18,8 +18,8 @@
__all__ = [ __all__ = [
] ]
import dstypes, adapters from . import dstypes, adapters
import DynamicSerializationManager from . import DynamicSerializationManager
class SerializationException(Exception): class SerializationException(Exception):

View file

@ -35,6 +35,6 @@ def deserialize(context):
setSize = context.readI32() setSize = context.readI32()
enumClassName = context.readString() enumClassName = context.readString()
valList = [] valList = []
for i in xrange(setSize): for i in range(setSize):
valList.append(context.readString()) valList.append(context.readString())
return EnumSet(enumClassName, valList) return EnumSet(enumClassName, valList)

View file

@ -59,13 +59,13 @@ def serialize(context, resp):
def deserialize(context): def deserialize(context):
size = context.readI32() size = context.readI32()
wkbs = [] wkbs = []
for i in xrange(size): for i in range(size):
wkb = context.readBinary() wkb = context.readBinary()
wkbs.append(wkb) wkbs.append(wkb)
geoData = [] geoData = []
size = context.readI32() size = context.readI32()
for i in xrange(size): for i in range(size):
data = GeometryResponseData() data = GeometryResponseData()
# wkb index # wkb index
wkbIndex = context.readI32() wkbIndex = context.readI32()
@ -83,7 +83,7 @@ def deserialize(context):
# parameters # parameters
paramSize = context.readI32() paramSize = context.readI32()
paramMap = {} paramMap = {}
for k in xrange(paramSize): for k in range(paramSize):
paramName = context.readString() paramName = context.readString()
value = context.readObject() value = context.readObject()
tName = context.readString() tName = context.readString()

View file

@ -29,7 +29,7 @@ def serialize(context, lockTable):
for lock in locks: for lock in locks:
wsIdString = str(lock.getWsId()) wsIdString = str(lock.getWsId())
if wsIds.has_key(wsIdString): if wsIdString in wsIds:
lockWsIdIndex.append(wsIds[wsIdString]) lockWsIdIndex.append(wsIds[wsIdString])
else: else:
lockWsIdIndex.append(index) lockWsIdIndex.append(index)
@ -52,12 +52,12 @@ def deserialize(context):
parmId = context.readObject() parmId = context.readObject()
numWsIds = context.readI32() numWsIds = context.readI32()
wsIds = [] wsIds = []
for x in xrange(numWsIds): for x in range(numWsIds):
wsIds.append(context.readObject()) wsIds.append(context.readObject())
numLocks = context.readI32() numLocks = context.readI32()
locks = [] locks = []
for x in xrange(numLocks): for x in range(numLocks):
startTime = context.readI64() startTime = context.readI64()
endTime = context.readI64() endTime = context.readI64()
wsId = wsIds[context.readI32()] wsId = wsIds[context.readI32()]

View file

@ -35,7 +35,7 @@ def deserialize(context):
wsId.setUserName(wsIdParts[1]) wsId.setUserName(wsIdParts[1])
wsId.setProgName(wsIdParts[2]) wsId.setProgName(wsIdParts[2])
wsId.setPid(wsIdParts[3]) wsId.setPid(wsIdParts[3])
wsId.setThreadId(long(wsIdParts[4])) wsId.setThreadId(int(wsIdParts[4]))
return wsId return wsId

View file

@ -76,10 +76,10 @@ def registerAdapters(package, modules):
if not package.endswith('.'): if not package.endswith('.'):
package += '.' package += '.'
for x in modules: for x in modules:
exec 'import ' + package + x exec('import ' + package + x)
m = sys.modules[package + x] m = sys.modules[package + x]
d = m.__dict__ d = m.__dict__
if d.has_key('ClassAdapter'): if 'ClassAdapter' in d:
if isinstance(m.ClassAdapter, list): if isinstance(m.ClassAdapter, list):
for clz in m.ClassAdapter: for clz in m.ClassAdapter:
classAdapterRegistry[clz] = m classAdapterRegistry[clz] = m

View file

@ -11,12 +11,11 @@
# #
## ##
import ActiveTableKey
import abc import abc
from six import with_metaclass
from . import ActiveTableKey
class ActiveTableRecord(object): class ActiveTableRecord(with_metaclass(abc.ABCMeta, object)):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __init__(self): def __init__(self):
self.key = ActiveTableKey.ActiveTableKey() self.key = ActiveTableKey.ActiveTableKey()

View file

@ -9,9 +9,9 @@
# #
## ##
import ActiveTableRecord from . import ActiveTableRecord
class OperationalActiveTableRecord(ActiveTableRecord.ActiveTableRecord): class OperationalActiveTableRecord(ActiveTableRecord):
def __init__(self): def __init__(self):
super(OperationalActiveTableRecord, self).__init__() super(OperationalActiveTableRecord, self).__init__()

View file

@ -9,9 +9,9 @@
# #
## ##
import ActiveTableRecord from . import ActiveTableRecord
class PracticeActiveTableRecord(ActiveTableRecord.ActiveTableRecord): class PracticeActiveTableRecord(ActiveTableRecord):
def __init__(self): def __init__(self):
super(PracticeActiveTableRecord, self).__init__() super(PracticeActiveTableRecord, self).__init__()

View file

@ -24,20 +24,20 @@ __all__ = [
'VTECTableChangeNotification' 'VTECTableChangeNotification'
] ]
from ActiveTableKey import ActiveTableKey from .ActiveTableKey import ActiveTableKey
from ActiveTableRecord import ActiveTableRecord from .ActiveTableRecord import ActiveTableRecord
from ActiveTableMode import ActiveTableMode from .ActiveTableMode import ActiveTableMode
from DumpActiveTableRequest import DumpActiveTableRequest from .DumpActiveTableRequest import DumpActiveTableRequest
from DumpActiveTableResponse import DumpActiveTableResponse from .DumpActiveTableResponse import DumpActiveTableResponse
from GetActiveTableDictRequest import GetActiveTableDictRequest from .GetActiveTableDictRequest import GetActiveTableDictRequest
from GetActiveTableDictResponse import GetActiveTableDictResponse from .GetActiveTableDictResponse import GetActiveTableDictResponse
from GetFourCharSitesRequest import GetFourCharSitesRequest from .GetFourCharSitesRequest import GetFourCharSitesRequest
from GetFourCharSitesResponse import GetFourCharSitesResponse from .GetFourCharSitesResponse import GetFourCharSitesResponse
from GetVtecAttributeRequest import GetVtecAttributeRequest from .GetVtecAttributeRequest import GetVtecAttributeRequest
from GetVtecAttributeResponse import GetVtecAttributeResponse from .GetVtecAttributeResponse import GetVtecAttributeResponse
from OperationalActiveTableRecord import OperationalActiveTableRecord from .OperationalActiveTableRecord import OperationalActiveTableRecord
from PracticeActiveTableRecord import PracticeActiveTableRecord from .PracticeActiveTableRecord import PracticeActiveTableRecord
from SendPracticeProductRequest import SendPracticeProductRequest from .SendPracticeProductRequest import SendPracticeProductRequest
from VTECChange import VTECChange from .VTECChange import VTECChange
from VTECTableChangeNotification import VTECTableChangeNotification from .VTECTableChangeNotification import VTECTableChangeNotification

View file

@ -10,8 +10,8 @@ __all__ = [
'SendActiveTableRequest' 'SendActiveTableRequest'
] ]
from ClearPracticeVTECTableRequest import ClearPracticeVTECTableRequest from .ClearPracticeVTECTableRequest import ClearPracticeVTECTableRequest
from MergeActiveTableRequest import MergeActiveTableRequest from .MergeActiveTableRequest import MergeActiveTableRequest
from RetrieveRemoteActiveTableRequest import RetrieveRemoteActiveTableRequest from .RetrieveRemoteActiveTableRequest import RetrieveRemoteActiveTableRequest
from SendActiveTableRequest import SendActiveTableRequest from .SendActiveTableRequest import SendActiveTableRequest

View file

@ -7,5 +7,5 @@ __all__ = [
'ActiveTableSharingResponse' 'ActiveTableSharingResponse'
] ]
from ActiveTableSharingResponse import ActiveTableSharingResponse from .ActiveTableSharingResponse import ActiveTableSharingResponse

View file

@ -57,7 +57,7 @@ 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(filters.has_key(None) or filters.values().count(None)>0 or filters.has_key('') 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 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)

View file

@ -7,5 +7,5 @@ __all__ = [
'AlertVizRequest' 'AlertVizRequest'
] ]
from AlertVizRequest import AlertVizRequest from .AlertVizRequest import AlertVizRequest

View file

@ -3,12 +3,11 @@
# File auto-generated against equivalent DynamicSerialize Java class # File auto-generated against equivalent DynamicSerialize Java class
from six import with_metaclass
import abc import abc
class AbstractFailedResponse(object): class AbstractFailedResponse(with_metaclass(abc.ABCMeta, object)):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __init__(self): def __init__(self):
self.request = None self.request = None

View file

@ -10,8 +10,8 @@ __all__ = [
'UserNotAuthorized' 'UserNotAuthorized'
] ]
from AbstractFailedResponse import AbstractFailedResponse 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

View file

@ -8,5 +8,5 @@ __all__ = [
'UserId' 'UserId'
] ]
from User import User from .User import User
from UserId import UserId from .UserId import UserId

View file

@ -40,10 +40,10 @@ class DefaultDataRequest(IDataRequest):
del self.identifiers[key] del self.identifiers[key]
def setParameters(self, *params): def setParameters(self, *params):
self.parameters = map(str, params) self.parameters = list(map(str, params))
def setLevels(self, *levels): def setLevels(self, *levels):
self.levels = map(self.__makeLevel, levels) self.levels = list(map(self.__makeLevel, levels))
def __makeLevel(self, level): def __makeLevel(self, level):
if type(level) is Level: if type(level) is Level:
@ -57,7 +57,7 @@ class DefaultDataRequest(IDataRequest):
self.envelope = Envelope(env.envelope) self.envelope = Envelope(env.envelope)
def setLocationNames(self, *locationNames): def setLocationNames(self, *locationNames):
self.locationNames = map(str, locationNames) self.locationNames = list(map(str, locationNames))
def getDatatype(self): def getDatatype(self):
return self.datatype return self.datatype

View file

@ -8,5 +8,5 @@ __all__ = [
'DefaultNotificationFilter' 'DefaultNotificationFilter'
] ]
from DefaultDataRequest import DefaultDataRequest from .DefaultDataRequest import DefaultDataRequest
from DefaultNotificationFilter import DefaultNotificationFilter from .DefaultNotificationFilter import DefaultNotificationFilter

View file

@ -12,12 +12,11 @@
# #
# #
from six import with_metaclass
import abc import abc
class AbstractDataAccessRequest(object): class AbstractDataAccessRequest(with_metaclass(abc.ABCMeta, object)):
__metaclass__ = abc.ABCMeta
def __init__(self): def __init__(self):
self.requestParameters = None self.requestParameters = None

View file

@ -14,11 +14,10 @@
# #
# #
from six import with_metaclass
import abc import abc
class AbstractIdentifierRequest(object): class AbstractIdentifierRequest(with_metaclass(abc.ABCMeta, object)):
__metaclass__ = abc.ABCMeta
def __init__(self): def __init__(self):
self.request = None self.request = None

View file

@ -20,18 +20,18 @@ __all__ = [
'GetSupportedDatatypesRequest' 'GetSupportedDatatypesRequest'
] ]
from AbstractDataAccessRequest import AbstractDataAccessRequest from .AbstractDataAccessRequest import AbstractDataAccessRequest
from AbstractIdentifierRequest import AbstractIdentifierRequest from .AbstractIdentifierRequest import AbstractIdentifierRequest
from GetAvailableLevelsRequest import GetAvailableLevelsRequest from .GetAvailableLevelsRequest import GetAvailableLevelsRequest
from GetAvailableLocationNamesRequest import GetAvailableLocationNamesRequest from .GetAvailableLocationNamesRequest import GetAvailableLocationNamesRequest
from GetAvailableParametersRequest import GetAvailableParametersRequest from .GetAvailableParametersRequest import GetAvailableParametersRequest
from GetAvailableTimesRequest import GetAvailableTimesRequest from .GetAvailableTimesRequest import GetAvailableTimesRequest
from GetGeometryDataRequest import GetGeometryDataRequest from .GetGeometryDataRequest import GetGeometryDataRequest
from GetGridDataRequest import GetGridDataRequest from .GetGridDataRequest import GetGridDataRequest
from GetGridLatLonRequest import GetGridLatLonRequest from .GetGridLatLonRequest import GetGridLatLonRequest
from GetIdentifierValuesRequest import GetIdentifierValuesRequest from .GetIdentifierValuesRequest import GetIdentifierValuesRequest
from GetNotificationFilterRequest import GetNotificationFilterRequest from .GetNotificationFilterRequest import GetNotificationFilterRequest
from GetOptionalIdentifiersRequest import GetOptionalIdentifiersRequest from .GetOptionalIdentifiersRequest import GetOptionalIdentifiersRequest
from GetRequiredIdentifiersRequest import GetRequiredIdentifiersRequest from .GetRequiredIdentifiersRequest import GetRequiredIdentifiersRequest
from GetSupportedDatatypesRequest import GetSupportedDatatypesRequest from .GetSupportedDatatypesRequest import GetSupportedDatatypesRequest

View file

@ -4,11 +4,9 @@
# File auto-generated against equivalent DynamicSerialize Java class # File auto-generated against equivalent DynamicSerialize Java class
import abc import abc
from six import with_metaclass
class AbstractResponseData(with_metaclass(abc.ABCMeta, object)):
class AbstractResponseData(object):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __init__(self): def __init__(self):
self.time = None self.time = None

View file

@ -13,11 +13,11 @@ __all__ = [
'GridResponseData' 'GridResponseData'
] ]
from AbstractResponseData import AbstractResponseData from .AbstractResponseData import AbstractResponseData
from GeometryResponseData import GeometryResponseData from .GeometryResponseData import GeometryResponseData
from GetGeometryDataResponse import GetGeometryDataResponse from .GetGeometryDataResponse import GetGeometryDataResponse
from GetGridDataResponse import GetGridDataResponse from .GetGridDataResponse import GetGridDataResponse
from GetGridLatLonResponse import GetGridLatLonResponse from .GetGridLatLonResponse import GetGridLatLonResponse
from GetNotificationFilterResponse import GetNotificationFilterResponse from .GetNotificationFilterResponse import GetNotificationFilterResponse
from GridResponseData import GridResponseData from .GridResponseData import GridResponseData

View file

@ -7,5 +7,5 @@ __all__ = [
'RegionLookupRequest' 'RegionLookupRequest'
] ]
from RegionLookupRequest import RegionLookupRequest from .RegionLookupRequest import RegionLookupRequest

View file

@ -22,5 +22,5 @@ __all__ = [
'GridDataHistory' 'GridDataHistory'
] ]
from GridDataHistory import GridDataHistory from .GridDataHistory import GridDataHistory

View file

@ -7,5 +7,5 @@ __all__ = [
'ProjectionData' 'ProjectionData'
] ]
from ProjectionData import ProjectionData from .ProjectionData import ProjectionData

View file

@ -12,10 +12,10 @@ __all__ = [
'TimeConstraints' 'TimeConstraints'
] ]
from DatabaseID import DatabaseID from .DatabaseID import DatabaseID
from GFERecord import GFERecord from .GFERecord import GFERecord
from GridLocation import GridLocation 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

View file

@ -7,5 +7,5 @@ __all__ = [
'DiscreteKey' 'DiscreteKey'
] ]
from DiscreteKey import DiscreteKey from .DiscreteKey import DiscreteKey

View file

@ -8,6 +8,6 @@ __all__ = [
'Grid2DFloat' 'Grid2DFloat'
] ]
from Grid2DByte import Grid2DByte from .Grid2DByte import Grid2DByte
from Grid2DFloat import Grid2DFloat from .Grid2DFloat import Grid2DFloat

View file

@ -4,11 +4,9 @@
# File auto-generated against equivalent DynamicSerialize Java class # File auto-generated against equivalent DynamicSerialize Java class
import abc import abc
from six import with_metaclass
class AbstractGfeRequest(with_metaclass(abc.ABCMeta, object)):
class AbstractGfeRequest(object):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __init__(self): def __init__(self):
self.siteID = None self.siteID = None

View file

@ -4,13 +4,11 @@
# File auto-generated against equivalent DynamicSerialize Java class # File auto-generated against equivalent DynamicSerialize Java class
import abc import abc
from six import with_metaclass
from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.request import GetGridRequest from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.request import GetGridRequest
class GetGridDataRequest(object): class GetGridDataRequest(with_metaclass(abc.ABCMeta, object)):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __init__(self): def __init__(self):
self.requests = [] self.requests = []

View file

@ -38,31 +38,31 @@ __all__ = [
'SmartInitRequest' 'SmartInitRequest'
] ]
from AbstractGfeRequest import AbstractGfeRequest from .AbstractGfeRequest import AbstractGfeRequest
from CommitGridsRequest import CommitGridsRequest from .CommitGridsRequest import CommitGridsRequest
from ConfigureTextProductsRequest import ConfigureTextProductsRequest from .ConfigureTextProductsRequest import ConfigureTextProductsRequest
from ExecuteIfpNetCDFGridRequest import ExecuteIfpNetCDFGridRequest from .ExecuteIfpNetCDFGridRequest import ExecuteIfpNetCDFGridRequest
from ExecuteIscMosaicRequest import ExecuteIscMosaicRequest from .ExecuteIscMosaicRequest import ExecuteIscMosaicRequest
from ExportGridsRequest import ExportGridsRequest from .ExportGridsRequest import ExportGridsRequest
from GetASCIIGridsRequest import GetASCIIGridsRequest from .GetASCIIGridsRequest import GetASCIIGridsRequest
from GetGridDataRequest import GetGridDataRequest from .GetGridDataRequest import GetGridDataRequest
from GetGridInventoryRequest import GetGridInventoryRequest from .GetGridInventoryRequest import GetGridInventoryRequest
from GetLatestDbTimeRequest import GetLatestDbTimeRequest from .GetLatestDbTimeRequest import GetLatestDbTimeRequest
from GetLatestModelDbIdRequest import GetLatestModelDbIdRequest from .GetLatestModelDbIdRequest import GetLatestModelDbIdRequest
from GetLockTablesRequest import GetLockTablesRequest from .GetLockTablesRequest import GetLockTablesRequest
from GetOfficialDbNameRequest import GetOfficialDbNameRequest from .GetOfficialDbNameRequest import GetOfficialDbNameRequest
from GetParmListRequest import GetParmListRequest from .GetParmListRequest import GetParmListRequest
from GetSelectTimeRangeRequest import GetSelectTimeRangeRequest from .GetSelectTimeRangeRequest import GetSelectTimeRangeRequest
from GetSingletonDbIdsRequest import GetSingletonDbIdsRequest from .GetSingletonDbIdsRequest import GetSingletonDbIdsRequest
from GetSiteTimeZoneInfoRequest import GetSiteTimeZoneInfoRequest from .GetSiteTimeZoneInfoRequest import GetSiteTimeZoneInfoRequest
from GfeClientRequest import GfeClientRequest from .GfeClientRequest import GfeClientRequest
from GridLocRequest import GridLocRequest from .GridLocRequest import GridLocRequest
from IscDataRecRequest import IscDataRecRequest from .IscDataRecRequest import IscDataRecRequest
from LockChangeRequest import LockChangeRequest from .LockChangeRequest import LockChangeRequest
from ProcessReceivedConfRequest import ProcessReceivedConfRequest from .ProcessReceivedConfRequest import ProcessReceivedConfRequest
from ProcessReceivedDigitalDataRequest import ProcessReceivedDigitalDataRequest from .ProcessReceivedDigitalDataRequest import ProcessReceivedDigitalDataRequest
from PurgeGfeGridsRequest import PurgeGfeGridsRequest 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

View file

@ -8,6 +8,6 @@ __all__ = [
'LockTable' 'LockTable'
] ]
from Lock import Lock from .Lock import Lock
from LockTable import LockTable from .LockTable import LockTable

View file

@ -8,6 +8,6 @@ __all__ = [
'ServerResponse' 'ServerResponse'
] ]
from ServerMsg import ServerMsg from .ServerMsg import ServerMsg
from ServerResponse import ServerResponse from .ServerResponse import ServerResponse

View file

@ -9,7 +9,7 @@
# #
## ##
import GfeNotification from . import GfeNotification
class CombinationsFileChangedNotification(GfeNotification.GfeNotification): class CombinationsFileChangedNotification(GfeNotification.GfeNotification):

View file

@ -11,7 +11,7 @@
# #
## ##
import GfeNotification from . import GfeNotification
class DBInvChangeNotification(GfeNotification.GfeNotification): class DBInvChangeNotification(GfeNotification.GfeNotification):

View file

@ -8,10 +8,9 @@
# #
## ##
import abc import abc
from six import with_metaclass
class GfeNotification(object): class GfeNotification(with_metaclass(abc.ABCMeta, object)):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __init__(self): def __init__(self):
self.siteID = None self.siteID = None

View file

@ -9,9 +9,9 @@
# #
## ##
import GfeNotification from . import GfeNotification
class GridHistoryUpdateNotification(GfeNotification.GfeNotification): class GridHistoryUpdateNotification(GfeNotification):
def __init__(self): def __init__(self):
super(GridHistoryUpdateNotification, self).__init__() super(GridHistoryUpdateNotification, self).__init__()

View file

@ -10,9 +10,9 @@
# #
## ##
import GfeNotification from . import GfeNotification
class GridUpdateNotification(GfeNotification.GfeNotification): class GridUpdateNotification(GfeNotification):
def __init__(self): def __init__(self):
super(GridUpdateNotification, self).__init__() super(GridUpdateNotification, self).__init__()

View file

@ -10,9 +10,9 @@
# #
## ##
import GfeNotification from . import GfeNotification
class LockNotification(GfeNotification.GfeNotification): class LockNotification(GfeNotification):
def __init__(self): def __init__(self):
super(LockNotification, self).__init__() super(LockNotification, self).__init__()

View file

@ -9,9 +9,9 @@
# #
## ##
import GfeNotification from . import GfeNotification
class ServiceBackupJobStatusNotification(GfeNotification.GfeNotification): class ServiceBackupJobStatusNotification(GfeNotification):
def __init__(self): def __init__(self):
super(ServiceBackupJobStatusNotification, self).__init__() super(ServiceBackupJobStatusNotification, self).__init__()

View file

@ -9,9 +9,9 @@
# #
## ##
import GfeNotification from . import GfeNotification
class UserMessageNotification(GfeNotification.GfeNotification): class UserMessageNotification(GfeNotification):
def __init__(self): def __init__(self):
super(UserMessageNotification, self).__init__() super(UserMessageNotification, self).__init__()

View file

@ -10,8 +10,8 @@ __all__ = [
'LockTableRequest' 'LockTableRequest'
] ]
from CommitGridRequest import CommitGridRequest from .CommitGridRequest import CommitGridRequest
from GetGridRequest import GetGridRequest from .GetGridRequest import GetGridRequest
from LockRequest import LockRequest from .LockRequest import LockRequest
from LockTableRequest import LockTableRequest from .LockTableRequest import LockTableRequest

View file

@ -2,11 +2,9 @@
## ##
import abc import abc
from six import with_metaclass
class AbstractGridSlice(with_metaclass(abc.ABCMeta, object)):
class AbstractGridSlice(object):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __init__(self): def __init__(self):
self.validTime = None self.validTime = None

View file

@ -11,9 +11,9 @@ __all__ = [
'WeatherGridSlice' 'WeatherGridSlice'
] ]
from AbstractGridSlice import AbstractGridSlice from .AbstractGridSlice import AbstractGridSlice
from DiscreteGridSlice import DiscreteGridSlice from .DiscreteGridSlice import DiscreteGridSlice
from ScalarGridSlice import ScalarGridSlice from .ScalarGridSlice import ScalarGridSlice
from VectorGridSlice import VectorGridSlice from .VectorGridSlice import VectorGridSlice
from WeatherGridSlice import WeatherGridSlice from .WeatherGridSlice import WeatherGridSlice

View file

@ -13,4 +13,4 @@ __all__ = [
'JobProgress' 'JobProgress'
] ]
from JobProgress import JobProgress from .JobProgress import JobProgress

View file

@ -8,6 +8,6 @@ __all__ = [
'WeatherSubKey' 'WeatherSubKey'
] ]
from WeatherKey import WeatherKey from .WeatherKey import WeatherKey
from WeatherSubKey import WeatherSubKey from .WeatherSubKey import WeatherSubKey

View file

@ -7,5 +7,5 @@ __all__ = [
'DeleteAllGridDataRequest' 'DeleteAllGridDataRequest'
] ]
from DeleteAllGridDataRequest import DeleteAllGridDataRequest from .DeleteAllGridDataRequest import DeleteAllGridDataRequest

View file

@ -28,7 +28,7 @@ INVALID_VALUE = numpy.float64(-999999)
class Level(object): class Level(object):
def __init__(self, levelString=None): def __init__(self, levelString=None):
self.id = 0L self.id = 0
self.identifier = None self.identifier = None
self.masterLevel = None self.masterLevel = None
self.levelonevalue = INVALID_VALUE self.levelonevalue = INVALID_VALUE

View file

@ -8,6 +8,6 @@ __all__ = [
'MasterLevel' 'MasterLevel'
] ]
from Level import Level from .Level import Level
from MasterLevel import MasterLevel from .MasterLevel import MasterLevel

View file

@ -7,5 +7,5 @@ __all__ = [
'DataURINotificationMessage' 'DataURINotificationMessage'
] ]
from DataURINotificationMessage import DataURINotificationMessage from .DataURINotificationMessage import DataURINotificationMessage

View file

@ -7,5 +7,5 @@ __all__ = [
'GetRadarDataRecordRequest' 'GetRadarDataRecordRequest'
] ]
from GetRadarDataRecordRequest import GetRadarDataRecordRequest from .GetRadarDataRecordRequest import GetRadarDataRecordRequest

View file

@ -8,6 +8,6 @@ __all__ = [
'RadarDataRecord' 'RadarDataRecord'
] ]
from GetRadarDataRecordResponse import GetRadarDataRecordResponse from .GetRadarDataRecordResponse import GetRadarDataRecordResponse
from RadarDataRecord import RadarDataRecord from .RadarDataRecord import RadarDataRecord

View file

@ -7,5 +7,5 @@ __all__ = [
'TextDBRequest' 'TextDBRequest'
] ]
from TextDBRequest import TextDBRequest from .TextDBRequest import TextDBRequest

View file

@ -7,5 +7,5 @@ __all__ = [
'SubscriptionRequest' 'SubscriptionRequest'
] ]
from SubscriptionRequest import SubscriptionRequest from .SubscriptionRequest import SubscriptionRequest

View file

@ -13,7 +13,7 @@
# #
import re import re
from ...time import DataTime from dynamicserialize.dstypes.com.raytheon.uf.common.time import DataTime
class RequestConstraint(object): class RequestConstraint(object):
@ -210,7 +210,7 @@ class RequestConstraint(object):
@staticmethod @staticmethod
def _stringify(value): def _stringify(value):
if type(value) in {str, int, long, bool, float, unicode}: if type(value) in {str, int, int, bool, float, unicode}:
return str(value) return str(value)
else: else:
# Collections are not allowed; they are handled separately. # Collections are not allowed; they are handled separately.
@ -263,7 +263,7 @@ class RequestConstraint(object):
"""Build a new RequestConstraint.""" """Build a new RequestConstraint."""
try: try:
constraintType = cls.CONSTRAINT_MAP[operator.upper()] constraintType = cls.CONSTRAINT_MAP[operator.upper()]
except KeyError, AttributeError: except KeyError as AttributeError:
errmsg = '{} is not a valid operator. Valid operators are: {}' errmsg = '{} is not a valid operator. Valid operators are: {}'
validOperators = list(sorted(cls.CONSTRAINT_MAP.keys())) validOperators = list(sorted(cls.CONSTRAINT_MAP.keys()))
raise ValueError(errmsg.format(operator, validOperators)) raise ValueError(errmsg.format(operator, validOperators))

View file

@ -7,5 +7,5 @@ __all__ = [
'RequestConstraint' 'RequestConstraint'
] ]
from RequestConstraint import RequestConstraint from .RequestConstraint import RequestConstraint

View file

@ -23,6 +23,6 @@ __all__ = [
'StorageStatus' 'StorageStatus'
] ]
from Request import Request from .Request import Request
from StorageProperties import StorageProperties from .StorageProperties import StorageProperties
from StorageStatus import StorageStatus from .StorageStatus import StorageStatus

View file

@ -26,11 +26,11 @@ __all__ = [
'StringDataRecord' 'StringDataRecord'
] ]
from ByteDataRecord import ByteDataRecord from .ByteDataRecord import ByteDataRecord
from DoubleDataRecord import DoubleDataRecord from .DoubleDataRecord import DoubleDataRecord
from FloatDataRecord import FloatDataRecord from .FloatDataRecord import FloatDataRecord
from IntegerDataRecord import IntegerDataRecord from .IntegerDataRecord import IntegerDataRecord
from LongDataRecord import LongDataRecord from .LongDataRecord import LongDataRecord
from ShortDataRecord import ShortDataRecord from .ShortDataRecord import ShortDataRecord
from StringDataRecord import StringDataRecord from .StringDataRecord import StringDataRecord

View file

@ -26,7 +26,7 @@ knownLevels = {"BASE": {"text" : "BASE",
class LocalizationLevel(object): class LocalizationLevel(object):
def __init__(self, level, order=750, systemLevel=False): def __init__(self, level, order=750, systemLevel=False):
if knownLevels.has_key(level.upper()): if level.upper() in knownLevels:
self.text = level.upper() self.text = level.upper()
self.order = knownLevels[self.text]["order"] self.order = knownLevels[self.text]["order"]
self.systemLevel = knownLevels[self.text]["systemLevel"] self.systemLevel = knownLevels[self.text]["systemLevel"]

View file

@ -11,7 +11,7 @@ __all__ = [
'LocalizationType' 'LocalizationType'
] ]
from LocalizationContext import LocalizationContext from .LocalizationContext import LocalizationContext
from LocalizationLevel import LocalizationLevel from .LocalizationLevel import LocalizationLevel
from LocalizationType import LocalizationType from .LocalizationType import LocalizationType

View file

@ -14,12 +14,12 @@ __all__ = [
'UtilityResponseMessage' 'UtilityResponseMessage'
] ]
from DeleteUtilityCommand import DeleteUtilityCommand from .DeleteUtilityCommand import DeleteUtilityCommand
from DeleteUtilityResponse import DeleteUtilityResponse from .DeleteUtilityResponse import DeleteUtilityResponse
from ListResponseEntry import ListResponseEntry from .ListResponseEntry import ListResponseEntry
from ListUtilityCommand import ListUtilityCommand from .ListUtilityCommand import ListUtilityCommand
from ListUtilityResponse import ListUtilityResponse from .ListUtilityResponse import ListUtilityResponse
from PrivilegedUtilityRequestMessage import PrivilegedUtilityRequestMessage from .PrivilegedUtilityRequestMessage import PrivilegedUtilityRequestMessage
from UtilityRequestMessage import UtilityRequestMessage from .UtilityRequestMessage import UtilityRequestMessage
from UtilityResponseMessage import UtilityResponseMessage from .UtilityResponseMessage import UtilityResponseMessage

View file

@ -3,13 +3,12 @@
# File auto-generated against equivalent DynamicSerialize Java class # File auto-generated against equivalent DynamicSerialize Java class
from six import with_metaclass
import abc import abc
import os import os
from dynamicserialize.dstypes.com.raytheon.uf.common.auth.user import User from dynamicserialize.dstypes.com.raytheon.uf.common.auth.user import User
class AbstractLocalizationStreamRequest(object): class AbstractLocalizationStreamRequest(with_metaclass(abc.ABCMeta, object)):
__metaclass__ = abc.ABCMeta
@abc.abstractmethod @abc.abstractmethod
def __init__(self): def __init__(self):
self.context = None self.context = None

View file

@ -9,7 +9,7 @@ __all__ = [
'LocalizationStreamPutRequest' 'LocalizationStreamPutRequest'
] ]
from AbstractLocalizationStreamRequest import AbstractLocalizationStreamRequest from .AbstractLocalizationStreamRequest import AbstractLocalizationStreamRequest
from LocalizationStreamGetRequest import LocalizationStreamGetRequest from .LocalizationStreamGetRequest import LocalizationStreamGetRequest
from LocalizationStreamPutRequest import LocalizationStreamPutRequest from .LocalizationStreamPutRequest import LocalizationStreamPutRequest

View file

@ -9,6 +9,6 @@ __all__ = [
'PassThroughRequest' 'PassThroughRequest'
] ]
from ChangeContextRequest import ChangeContextRequest from .ChangeContextRequest import ChangeContextRequest
from PassThroughRequest import PassThroughRequest from .PassThroughRequest import PassThroughRequest

View file

@ -9,7 +9,7 @@ __all__ = [
'StatusRequest' 'StatusRequest'
] ]
from GetClusterMembersRequest import GetClusterMembersRequest from .GetClusterMembersRequest import GetClusterMembersRequest
from GetContextsRequest import GetContextsRequest from .GetContextsRequest import GetContextsRequest
from StatusRequest import StatusRequest from .StatusRequest import StatusRequest

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