From 25aeba52248758e797db45d3b3cdb70996ae83df Mon Sep 17 00:00:00 2001 From: freemansw1 Date: Sat, 16 Apr 2016 16:59:29 -0600 Subject: [PATCH 1/7] Revert b9a9ac7..8748091 This rolls back to commit b9a9ac784e97970b0a9c18a306e3028bad5e7651. --- .gitignore | 2 -- awips/dataaccess/DataAccessLayer.py | 2 +- dynamicserialize/__init__.py | 2 +- dynamicserialize/adapters/__init__.py | 4 +-- .../common/activetable/ActiveTableRecord.py | 2 +- .../OperationalActiveTableRecord.py | 4 +-- .../activetable/PracticeActiveTableRecord.py | 4 +-- .../uf/common/activetable/__init__.py | 32 +++++++++---------- .../uf/common/dataaccess/impl/__init__.py | 2 +- .../uf/common/dataplugin/level/Level.py | 2 +- .../uf/common/dataplugin/level/__init__.py | 4 +-- .../uf/common/localization/__init__.py | 6 ++-- .../com/raytheon/uf/common/message/Header.py | 2 +- .../com/raytheon/uf/common/message/WsId.py | 6 +--- .../raytheon/uf/common/message/__init__.py | 10 +++--- .../com/raytheon/uf/common/time/DataTime.py | 6 +--- .../com/raytheon/uf/common/time/__init__.py | 4 +-- .../com/vividsolutions/jts/geom/__init__.py | 6 ++-- dynamicserialize/dstypes/java/awt/__init__.py | 2 +- .../dstypes/java/lang/__init__.py | 2 +- .../dstypes/java/util/__init__.py | 8 ++--- 21 files changed, 51 insertions(+), 61 deletions(-) diff --git a/.gitignore b/.gitignore index b496937..3d978be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,2 @@ .ipynb_checkpoints docs/build/ - -*.pyc diff --git a/awips/dataaccess/DataAccessLayer.py b/awips/dataaccess/DataAccessLayer.py index b6d7b59..4ab02b7 100644 --- a/awips/dataaccess/DataAccessLayer.py +++ b/awips/dataaccess/DataAccessLayer.py @@ -47,7 +47,7 @@ import subprocess THRIFT_HOST = "edex" USING_NATIVE_THRIFT = False -if 'jep' in sys.modules: +if sys.modules.has_key('jep'): # intentionally do not catch if this fails to import, we want it to # be obvious that something is configured wrong when running from within # Java instead of allowing false confidence and fallback behavior diff --git a/dynamicserialize/__init__.py b/dynamicserialize/__init__.py index d3a487b..c7a94fd 100644 --- a/dynamicserialize/__init__.py +++ b/dynamicserialize/__init__.py @@ -35,7 +35,7 @@ __all__ = [ ] -import dynamicserialize.adapters as adapters +import dstypes, adapters import DynamicSerializationManager class SerializationException(Exception): diff --git a/dynamicserialize/adapters/__init__.py b/dynamicserialize/adapters/__init__.py index f7ad667..26cbdcd 100644 --- a/dynamicserialize/adapters/__init__.py +++ b/dynamicserialize/adapters/__init__.py @@ -66,10 +66,10 @@ classAdapterRegistry = {} def getAdapterRegistry(): import sys for x in __all__: - exec('import dynamicserialize.adapters.' + x) + exec 'import ' + x m = sys.modules['dynamicserialize.adapters.' + x] d = m.__dict__ - if 'ClassAdapter' in d: + if d.has_key('ClassAdapter'): if isinstance(m.ClassAdapter, list): for clz in m.ClassAdapter: classAdapterRegistry[clz] = m diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/ActiveTableRecord.py b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/ActiveTableRecord.py index 236dac1..25c19fc 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/ActiveTableRecord.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/ActiveTableRecord.py @@ -26,7 +26,7 @@ # ## -from .ActiveTableKey import ActiveTableKey +import ActiveTableKey import abc class ActiveTableRecord(object): diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/OperationalActiveTableRecord.py b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/OperationalActiveTableRecord.py index 94486cf..86a959c 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/OperationalActiveTableRecord.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/OperationalActiveTableRecord.py @@ -26,9 +26,9 @@ # ## -from .ActiveTableRecord import ActiveTableRecord +import ActiveTableRecord -class OperationalActiveTableRecord(ActiveTableRecord): +class OperationalActiveTableRecord(ActiveTableRecord.ActiveTableRecord): def __init__(self): super(OperationalActiveTableRecord, self).__init__() diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/PracticeActiveTableRecord.py b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/PracticeActiveTableRecord.py index 91a9b09..d60e78a 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/PracticeActiveTableRecord.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/PracticeActiveTableRecord.py @@ -26,9 +26,9 @@ # ## -from .ActiveTableRecord import ActiveTableRecord +import ActiveTableRecord -class PracticeActiveTableRecord(ActiveTableRecord): +class PracticeActiveTableRecord(ActiveTableRecord.ActiveTableRecord): def __init__(self): super(PracticeActiveTableRecord, self).__init__() diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/__init__.py index a209f1f..6dce1e6 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/__init__.py @@ -41,20 +41,20 @@ __all__ = [ 'response' ] -from .ActiveTableKey import ActiveTableKey -from .ActiveTableRecord import ActiveTableRecord -from .ActiveTableMode import ActiveTableMode -from .DumpActiveTableRequest import DumpActiveTableRequest -from .DumpActiveTableResponse import DumpActiveTableResponse -from .GetActiveTableDictRequest import GetActiveTableDictRequest -from .GetActiveTableDictResponse import GetActiveTableDictResponse -from .GetFourCharSitesRequest import GetFourCharSitesRequest -from .GetFourCharSitesResponse import GetFourCharSitesResponse -from .GetVtecAttributeRequest import GetVtecAttributeRequest -from .GetVtecAttributeResponse import GetVtecAttributeResponse -from .OperationalActiveTableRecord import OperationalActiveTableRecord -from .PracticeActiveTableRecord import PracticeActiveTableRecord -from .SendPracticeProductRequest import SendPracticeProductRequest -from .VTECChange import VTECChange -from .VTECTableChangeNotification import VTECTableChangeNotification +from ActiveTableKey import ActiveTableKey +from ActiveTableRecord import ActiveTableRecord +from ActiveTableMode import ActiveTableMode +from DumpActiveTableRequest import DumpActiveTableRequest +from DumpActiveTableResponse import DumpActiveTableResponse +from GetActiveTableDictRequest import GetActiveTableDictRequest +from GetActiveTableDictResponse import GetActiveTableDictResponse +from GetFourCharSitesRequest import GetFourCharSitesRequest +from GetFourCharSitesResponse import GetFourCharSitesResponse +from GetVtecAttributeRequest import GetVtecAttributeRequest +from GetVtecAttributeResponse import GetVtecAttributeResponse +from OperationalActiveTableRecord import OperationalActiveTableRecord +from PracticeActiveTableRecord import PracticeActiveTableRecord +from SendPracticeProductRequest import SendPracticeProductRequest +from VTECChange import VTECChange +from VTECTableChangeNotification import VTECTableChangeNotification diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/__init__.py index 5d57bfb..f9a76ac 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/__init__.py @@ -24,5 +24,5 @@ __all__ = [ 'DefaultDataRequest' ] -from .DefaultDataRequest import DefaultDataRequest +from DefaultDataRequest import DefaultDataRequest diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py index 14b658f..e5b56c0 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py @@ -45,7 +45,7 @@ INVALID_VALUE = numpy.float64(-999999) class Level(object): def __init__(self, levelString=None): - self.id = 0 + self.id = 0L self.identifier = None self.masterLevel = None self.levelonevalue = INVALID_VALUE diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/__init__.py index 97b4729..9e5a9fb 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/__init__.py @@ -25,6 +25,6 @@ __all__ = [ 'MasterLevel' ] -from .Level import Level -from .MasterLevel import MasterLevel +from Level import Level +from MasterLevel import MasterLevel diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/__init__.py index 3a13605..d2f66b4 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/__init__.py @@ -28,7 +28,7 @@ __all__ = [ 'stream' ] -from .LocalizationContext import LocalizationContext -from .LocalizationLevel import LocalizationLevel -from .LocalizationType import LocalizationType +from LocalizationContext import LocalizationContext +from LocalizationLevel import LocalizationLevel +from LocalizationType import LocalizationType diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/message/Header.py b/dynamicserialize/dstypes/com/raytheon/uf/common/message/Header.py index 6b3e028..04f3163 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/message/Header.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/message/Header.py @@ -20,7 +20,7 @@ # File auto-generated against equivalent DynamicSerialize Java class -from .Property import Property +from Property import Property class Header(object): diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/message/WsId.py b/dynamicserialize/dstypes/com/raytheon/uf/common/message/WsId.py index 6b9a3d0..15930ea 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/message/WsId.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/message/WsId.py @@ -31,11 +31,7 @@ import struct import socket import os import pwd -try: - import thread -except ImportError: - #this means that we are in python 3. - import _thread as thread +import thread class WsId(object): diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/message/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/message/__init__.py index 7f0ab80..02c3271 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/message/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/message/__init__.py @@ -40,8 +40,8 @@ __all__ = [ # -from .Body import Body -from .Header import Header -from .Message import Message -from .Property import Property -from .WsId import WsId +from Body import Body +from Header import Header +from Message import Message +from Property import Property +from WsId import WsId diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/time/DataTime.py b/dynamicserialize/dstypes/com/raytheon/uf/common/time/DataTime.py index 1219dbb..7b20af8 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/time/DataTime.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/time/DataTime.py @@ -40,11 +40,7 @@ import calendar import datetime import numpy import time -try: - import StringIO -except ImportError: - #python2->3 - import io.StringIO as StringIO +import StringIO from dynamicserialize.dstypes.java.util import Date from dynamicserialize.dstypes.java.util import EnumSet diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/time/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/time/__init__.py index 5f570f5..a31aacc 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/time/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/time/__init__.py @@ -25,6 +25,6 @@ __all__ = [ 'TimeRange' ] -from .DataTime import DataTime -from .TimeRange import TimeRange +from DataTime import DataTime +from TimeRange import TimeRange diff --git a/dynamicserialize/dstypes/com/vividsolutions/jts/geom/__init__.py b/dynamicserialize/dstypes/com/vividsolutions/jts/geom/__init__.py index 18d2f36..95449c8 100644 --- a/dynamicserialize/dstypes/com/vividsolutions/jts/geom/__init__.py +++ b/dynamicserialize/dstypes/com/vividsolutions/jts/geom/__init__.py @@ -26,7 +26,7 @@ __all__ = [ 'Geometry' ] -from .Coordinate import Coordinate -from .Envelope import Envelope -from .Geometry import Geometry +from Coordinate import Coordinate +from Envelope import Envelope +from Geometry import Geometry diff --git a/dynamicserialize/dstypes/java/awt/__init__.py b/dynamicserialize/dstypes/java/awt/__init__.py index 7fd9f01..1a2a8b5 100644 --- a/dynamicserialize/dstypes/java/awt/__init__.py +++ b/dynamicserialize/dstypes/java/awt/__init__.py @@ -37,4 +37,4 @@ __all__ = [ 'Point', ] -from .Point import Point +from Point import Point diff --git a/dynamicserialize/dstypes/java/lang/__init__.py b/dynamicserialize/dstypes/java/lang/__init__.py index 47f0e2e..ffa213f 100644 --- a/dynamicserialize/dstypes/java/lang/__init__.py +++ b/dynamicserialize/dstypes/java/lang/__init__.py @@ -24,5 +24,5 @@ __all__ = [ 'StackTraceElement' ] -from .StackTraceElement import StackTraceElement +from StackTraceElement import StackTraceElement diff --git a/dynamicserialize/dstypes/java/util/__init__.py b/dynamicserialize/dstypes/java/util/__init__.py index 9068645..2126103 100644 --- a/dynamicserialize/dstypes/java/util/__init__.py +++ b/dynamicserialize/dstypes/java/util/__init__.py @@ -27,8 +27,8 @@ __all__ = [ 'GregorianCalendar' ] -from .Calendar import Calendar -from .Date import Date -from .EnumSet import EnumSet -from .GregorianCalendar import GregorianCalendar +from Calendar import Calendar +from Date import Date +from EnumSet import EnumSet +from GregorianCalendar import GregorianCalendar From 6a2db72ffdda5c2635aa5b0565f11b1a7dbf77d6 Mon Sep 17 00:00:00 2001 From: freemansw1 Date: Sat, 16 Apr 2016 17:00:50 -0600 Subject: [PATCH 2/7] after running 2to3 --- awips/AlertVizHandler.py | 2 +- awips/AlertVizHandler.py.bak | 69 ++ awips/DateTimeConverter.py | 4 +- awips/DateTimeConverter.py.bak | 107 ++ awips/NotificationMessage.py | 38 +- awips/NotificationMessage.py.bak | 178 ++++ awips/QpidSubscriber.py | 8 +- awips/QpidSubscriber.py.bak | 97 ++ awips/ThriftClient.py | 8 +- awips/ThriftClient.py.bak | 101 ++ awips/TimeUtil.py | 2 +- awips/TimeUtil.py.bak | 108 ++ awips/dataaccess/DataAccessLayer.py | 2 +- awips/dataaccess/DataAccessLayer.py.bak | 215 ++++ awips/dataaccess/PyData.py | 2 +- awips/dataaccess/PyData.py.bak | 57 ++ awips/dataaccess/PyGeometryData.py | 6 +- awips/dataaccess/PyGeometryData.py.bak | 79 ++ awips/dataaccess/SoundingsSupport.py | 4 +- awips/dataaccess/SoundingsSupport.py.bak | 283 ++++++ awips/dataaccess/ThriftClientRouter.py | 4 +- awips/dataaccess/ThriftClientRouter.py.bak | 176 ++++ awips/dataaccess/__init__.py | 6 +- awips/dataaccess/__init__.py.bak | 353 +++++++ awips/qpidingest.py | 6 +- awips/qpidingest.py.bak | 111 +++ awips/stomp.py | 73 +- awips/stomp.py.bak | 934 ++++++++++++++++++ awips/test/testQpidTimeToLive.py | 10 +- awips/test/testQpidTimeToLive.py.bak | 99 ++ docs/source/conf.py | 16 +- docs/source/conf.py.bak | 303 ++++++ .../DynamicSerializationManager.py | 2 +- .../DynamicSerializationManager.py.bak | 69 ++ .../ThriftSerializationContext.py | 41 +- .../ThriftSerializationContext.py.bak | 420 ++++++++ dynamicserialize/__init__.py | 4 +- dynamicserialize/__init__.py.bak | 58 ++ dynamicserialize/adapters/EnumSetAdapter.py | 2 +- .../adapters/EnumSetAdapter.py.bak | 57 ++ dynamicserialize/adapters/LockTableAdapter.py | 6 +- .../adapters/LockTableAdapter.py.bak | 88 ++ dynamicserialize/adapters/WsIdAdapter.py | 2 +- dynamicserialize/adapters/WsIdAdapter.py.bak | 58 ++ dynamicserialize/adapters/__init__.py | 4 +- dynamicserialize/adapters/__init__.py.bak | 85 ++ .../common/activetable/ActiveTableRecord.py | 6 +- .../activetable/ActiveTableRecord.py.bak | 291 ++++++ .../OperationalActiveTableRecord.py | 2 +- .../OperationalActiveTableRecord.py.bak | 34 + .../activetable/PracticeActiveTableRecord.py | 2 +- .../PracticeActiveTableRecord.py.bak | 34 + .../uf/common/activetable/__init__.py | 32 +- .../uf/common/activetable/__init__.py.bak | 60 ++ .../uf/common/activetable/request/__init__.py | 8 +- .../activetable/request/__init__.py.bak | 34 + .../common/activetable/response/__init__.py | 2 +- .../activetable/response/__init__.py.bak | 28 + .../raytheon/uf/common/alertviz/__init__.py | 2 +- .../uf/common/alertviz/__init__.py.bak | 28 + .../auth/resp/AbstractFailedResponse.py | 4 +- .../auth/resp/AbstractFailedResponse.py.bak | 38 + .../raytheon/uf/common/auth/resp/__init__.py | 8 +- .../uf/common/auth/resp/__init__.py.bak | 34 + .../raytheon/uf/common/auth/user/__init__.py | 2 +- .../uf/common/auth/user/__init__.py.bak | 27 + .../dataaccess/impl/DefaultDataRequest.py | 6 +- .../dataaccess/impl/DefaultDataRequest.py.bak | 94 ++ .../uf/common/dataaccess/impl/__init__.py | 2 +- .../uf/common/dataaccess/impl/__init__.py.bak | 28 + .../request/AbstractDataAccessRequest.py | 4 +- .../request/AbstractDataAccessRequest.py.bak | 46 + .../request/AbstractIdentifierRequest.py | 4 +- .../request/AbstractIdentifierRequest.py.bak | 45 + .../uf/common/dataaccess/request/__init__.py | 22 +- .../common/dataaccess/request/__init__.py.bak | 48 + .../response/AbstractResponseData.py | 4 +- .../response/AbstractResponseData.py.bak | 59 ++ .../uf/common/dataaccess/response/__init__.py | 10 +- .../dataaccess/response/__init__.py.bak | 36 + .../events/hazards/requests/__init__.py | 2 +- .../events/hazards/requests/__init__.py.bak | 28 + .../uf/common/dataplugin/gfe/__init__.py | 2 +- .../uf/common/dataplugin/gfe/__init__.py.bak | 43 + .../common/dataplugin/gfe/config/__init__.py | 2 +- .../dataplugin/gfe/config/__init__.py.bak | 28 + .../dataplugin/gfe/db/objects/__init__.py | 12 +- .../dataplugin/gfe/db/objects/__init__.py.bak | 38 + .../dataplugin/gfe/discrete/__init__.py | 2 +- .../dataplugin/gfe/discrete/__init__.py.bak | 28 + .../uf/common/dataplugin/gfe/grid/__init__.py | 4 +- .../dataplugin/gfe/grid/__init__.py.bak | 30 + .../gfe/request/AbstractGfeRequest.py | 4 +- .../gfe/request/AbstractGfeRequest.py.bak | 44 + .../gfe/request/GetGridDataRequest.py | 4 +- .../gfe/request/GetGridDataRequest.py.bak | 63 ++ .../common/dataplugin/gfe/request/__init__.py | 52 +- .../dataplugin/gfe/request/__init__.py.bak | 83 ++ .../dataplugin/gfe/server/lock/__init__.py | 4 +- .../gfe/server/lock/__init__.py.bak | 30 + .../gfe/server/message/ServerResponse.py | 2 +- .../gfe/server/message/ServerResponse.py.bak | 65 ++ .../dataplugin/gfe/server/message/__init__.py | 4 +- .../gfe/server/message/__init__.py.bak | 30 + .../CombinationsFileChangedNotification.py | 2 +- ...CombinationsFileChangedNotification.py.bak | 53 + .../server/notify/DBInvChangeNotification.py | 2 +- .../notify/DBInvChangeNotification.py.bak | 56 ++ .../gfe/server/notify/GfeNotification.py | 4 +- .../gfe/server/notify/GfeNotification.py.bak | 48 + .../notify/GridHistoryUpdateNotification.py | 2 +- .../GridHistoryUpdateNotification.py.bak | 61 ++ .../server/notify/GridUpdateNotification.py | 2 +- .../notify/GridUpdateNotification.py.bak | 70 ++ .../gfe/server/notify/LockNotification.py | 2 +- .../gfe/server/notify/LockNotification.py.bak | 46 + .../ServiceBackupJobStatusNotification.py | 2 +- .../ServiceBackupJobStatusNotification.py.bak | 53 + .../server/notify/UserMessageNotification.py | 2 +- .../notify/UserMessageNotification.py.bak | 62 ++ .../dataplugin/gfe/server/notify/__init__.py | 16 +- .../gfe/server/notify/__init__.py.bak | 42 + .../dataplugin/gfe/server/request/__init__.py | 8 +- .../gfe/server/request/__init__.py.bak | 34 + .../dataplugin/gfe/slice/AbstractGridSlice.py | 4 +- .../gfe/slice/AbstractGridSlice.py.bak | 53 + .../common/dataplugin/gfe/slice/__init__.py | 10 +- .../dataplugin/gfe/slice/__init__.py.bak | 36 + .../common/dataplugin/gfe/svcbu/__init__.py | 2 +- .../dataplugin/gfe/svcbu/__init__.py.bak | 33 + .../common/dataplugin/gfe/weather/__init__.py | 4 +- .../dataplugin/gfe/weather/__init__.py.bak | 30 + .../dataplugin/grid/request/__init__.py | 2 +- .../dataplugin/grid/request/__init__.py.bak | 28 + .../uf/common/dataplugin/level/Level.py | 2 +- .../uf/common/dataplugin/level/Level.py.bak | 205 ++++ .../uf/common/dataplugin/level/__init__.py | 4 +- .../common/dataplugin/level/__init__.py.bak | 30 + .../uf/common/dataplugin/message/__init__.py | 2 +- .../common/dataplugin/message/__init__.py.bak | 28 + .../dataplugin/radar/request/__init__.py | 2 +- .../dataplugin/radar/request/__init__.py.bak | 28 + .../dataplugin/radar/response/__init__.py | 4 +- .../dataplugin/radar/response/__init__.py.bak | 30 + .../common/dataplugin/text/dbsrv/__init__.py | 2 +- .../dataplugin/text/dbsrv/__init__.py.bak | 28 + .../dataplugin/text/request/__init__.py | 2 +- .../dataplugin/text/request/__init__.py.bak | 28 + .../uf/common/datastorage/__init__.py | 6 +- .../uf/common/datastorage/__init__.py.bak | 45 + .../uf/common/datastorage/records/__init__.py | 14 +- .../datastorage/records/__init__.py.bak | 53 + .../common/localization/LocalizationLevel.py | 2 +- .../localization/LocalizationLevel.py.bak | 75 ++ .../uf/common/localization/__init__.py | 6 +- .../uf/common/localization/__init__.py.bak | 34 + .../uf/common/localization/msgs/__init__.py | 16 +- .../common/localization/msgs/__init__.py.bak | 42 + .../AbstractLocalizationStreamRequest.py | 4 +- .../AbstractLocalizationStreamRequest.py.bak | 62 ++ .../uf/common/localization/stream/__init__.py | 6 +- .../localization/stream/__init__.py.bak | 32 + .../uf/common/management/request/__init__.py | 4 +- .../common/management/request/__init__.py.bak | 31 + .../management/request/diagnostic/__init__.py | 6 +- .../request/diagnostic/__init__.py.bak | 32 + .../response/diagnostic/__init__.py | 6 +- .../response/diagnostic/__init__.py.bak | 32 + .../com/raytheon/uf/common/message/Header.py | 4 +- .../raytheon/uf/common/message/Header.py.bak | 43 + .../com/raytheon/uf/common/message/WsId.py | 4 +- .../raytheon/uf/common/message/WsId.py.bak | 96 ++ .../raytheon/uf/common/message/__init__.py | 10 +- .../uf/common/message/__init__.py.bak | 47 + .../uf/common/plugin/nwsauth/user/__init__.py | 4 +- .../plugin/nwsauth/user/__init__.py.bak | 30 + .../uf/common/pointdata/requests/__init__.py | 2 +- .../common/pointdata/requests/__init__.py.bak | 28 + .../com/raytheon/uf/common/pypies/__init__.py | 2 +- .../raytheon/uf/common/pypies/__init__.py.bak | 30 + .../uf/common/pypies/request/__init__.py | 20 +- .../uf/common/pypies/request/__init__.py.bak | 45 + .../uf/common/pypies/response/__init__.py | 10 +- .../uf/common/pypies/response/__init__.py.bak | 35 + .../uf/common/serialization/__init__.py | 2 +- .../uf/common/serialization/__init__.py.bak | 41 + .../serialization/comm/response/__init__.py | 2 +- .../comm/response/__init__.py.bak | 40 + .../notify/ClusterActivationNotification.py | 2 +- .../ClusterActivationNotification.py.bak | 58 ++ .../uf/common/site/notify/__init__.py | 4 +- .../uf/common/site/notify/__init__.py.bak | 30 + .../uf/common/site/requests/__init__.py | 6 +- .../uf/common/site/requests/__init__.py.bak | 32 + .../com/raytheon/uf/common/time/DataTime.py | 16 +- .../raytheon/uf/common/time/DataTime.py.bak | 226 +++++ .../com/raytheon/uf/common/time/TimeRange.py | 8 +- .../raytheon/uf/common/time/TimeRange.py.bak | 161 +++ .../com/raytheon/uf/common/time/__init__.py | 4 +- .../raytheon/uf/common/time/__init__.py.bak | 30 + .../com/vividsolutions/jts/geom/__init__.py | 6 +- .../vividsolutions/jts/geom/__init__.py.bak | 32 + .../dataplugin/gempak/request/__init__.py | 16 +- .../dataplugin/gempak/request/__init__.py.bak | 22 + .../common/dataplugin/gpd/query/__init__.py | 2 +- .../dataplugin/gpd/query/__init__.py.bak | 8 + .../ncep/common/dataplugin/pgen/__init__.py | 6 +- .../common/dataplugin/pgen/__init__.py.bak | 14 + .../dataplugin/pgen/request/__init__.py | 6 +- .../dataplugin/pgen/request/__init__.py.bak | 13 + dynamicserialize/dstypes/java/awt/__init__.py | 2 +- .../dstypes/java/awt/__init__.py.bak | 40 + .../dstypes/java/lang/__init__.py | 2 +- .../dstypes/java/lang/__init__.py.bak | 28 + dynamicserialize/dstypes/java/sql/__init__.py | 2 +- .../dstypes/java/sql/__init__.py.bak | 27 + .../dstypes/java/util/__init__.py | 8 +- .../dstypes/java/util/__init__.py.bak | 34 + thrift/TSCons.py | 2 +- thrift/TSCons.py.bak | 35 + thrift/TSerialization.py | 4 +- thrift/TSerialization.py.bak | 38 + thrift/protocol/TBase.py | 10 +- thrift/protocol/TBase.py.bak | 81 ++ thrift/protocol/TBinaryProtocol.py | 2 +- thrift/protocol/TBinaryProtocol.py.bak | 260 +++++ thrift/protocol/TCompactProtocol.py | 4 +- thrift/protocol/TCompactProtocol.py.bak | 403 ++++++++ thrift/protocol/TProtocol.py | 12 +- thrift/protocol/TProtocol.py.bak | 406 ++++++++ thrift/server/THttpServer.py | 6 +- thrift/server/THttpServer.py.bak | 87 ++ thrift/server/TNonblockingServer.py | 10 +- thrift/server/TNonblockingServer.py.bak | 346 +++++++ thrift/server/TProcessPoolServer.py | 9 +- thrift/server/TProcessPoolServer.py.bak | 118 +++ thrift/server/TServer.py | 16 +- thrift/server/TServer.py.bak | 269 +++++ thrift/transport/THttpClient.py | 24 +- thrift/transport/THttpClient.py.bak | 149 +++ thrift/transport/TSocket.py | 10 +- thrift/transport/TSocket.py.bak | 176 ++++ thrift/transport/TTransport.py | 2 +- thrift/transport/TTransport.py.bak | 330 +++++++ thrift/transport/TTwisted.py | 4 +- thrift/transport/TTwisted.py.bak | 221 +++++ thrift/transport/TZlibTransport.py | 6 +- thrift/transport/TZlibTransport.py.bak | 248 +++++ 248 files changed, 11891 insertions(+), 454 deletions(-) create mode 100644 awips/AlertVizHandler.py.bak create mode 100644 awips/DateTimeConverter.py.bak create mode 100644 awips/NotificationMessage.py.bak create mode 100644 awips/QpidSubscriber.py.bak create mode 100644 awips/ThriftClient.py.bak create mode 100644 awips/TimeUtil.py.bak create mode 100644 awips/dataaccess/DataAccessLayer.py.bak create mode 100644 awips/dataaccess/PyData.py.bak create mode 100644 awips/dataaccess/PyGeometryData.py.bak create mode 100644 awips/dataaccess/SoundingsSupport.py.bak create mode 100644 awips/dataaccess/ThriftClientRouter.py.bak create mode 100644 awips/dataaccess/__init__.py.bak create mode 100644 awips/qpidingest.py.bak create mode 100644 awips/stomp.py.bak create mode 100644 awips/test/testQpidTimeToLive.py.bak create mode 100644 docs/source/conf.py.bak create mode 100644 dynamicserialize/DynamicSerializationManager.py.bak create mode 100644 dynamicserialize/ThriftSerializationContext.py.bak create mode 100644 dynamicserialize/__init__.py.bak create mode 100644 dynamicserialize/adapters/EnumSetAdapter.py.bak create mode 100644 dynamicserialize/adapters/LockTableAdapter.py.bak create mode 100644 dynamicserialize/adapters/WsIdAdapter.py.bak create mode 100644 dynamicserialize/adapters/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/activetable/ActiveTableRecord.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/activetable/OperationalActiveTableRecord.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/activetable/PracticeActiveTableRecord.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/activetable/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/activetable/request/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/activetable/response/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/alertviz/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/AbstractFailedResponse.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/auth/user/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/DefaultDataRequest.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractDataAccessRequest.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractIdentifierRequest.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/AbstractResponseData.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/events/hazards/requests/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/config/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/discrete/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/grid/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfeRequest.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/GetGridDataRequest.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/lock/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/ServerResponse.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/CombinationsFileChangedNotification.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/DBInvChangeNotification.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GfeNotification.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridHistoryUpdateNotification.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridUpdateNotification.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/LockNotification.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/ServiceBackupJobStatusNotification.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/UserMessageNotification.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/request/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/AbstractGridSlice.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/svcbu/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/weather/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grid/request/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/message/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/request/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/response/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/text/dbsrv/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/text/request/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/datastorage/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/datastorage/records/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/localization/LocalizationLevel.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/localization/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/localization/msgs/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/AbstractLocalizationStreamRequest.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/management/request/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/management/request/diagnostic/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/management/response/diagnostic/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/message/Header.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/message/WsId.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/message/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/plugin/nwsauth/user/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/pointdata/requests/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/pypies/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/pypies/request/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/pypies/response/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/serialization/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/serialization/comm/response/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/site/notify/ClusterActivationNotification.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/site/notify/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/site/requests/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/time/DataTime.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/time/TimeRange.py.bak create mode 100644 dynamicserialize/dstypes/com/raytheon/uf/common/time/__init__.py.bak create mode 100644 dynamicserialize/dstypes/com/vividsolutions/jts/geom/__init__.py.bak create mode 100644 dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/gempak/request/__init__.py.bak create mode 100644 dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/gpd/query/__init__.py.bak create mode 100644 dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/pgen/__init__.py.bak create mode 100644 dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/pgen/request/__init__.py.bak create mode 100644 dynamicserialize/dstypes/java/awt/__init__.py.bak create mode 100644 dynamicserialize/dstypes/java/lang/__init__.py.bak create mode 100644 dynamicserialize/dstypes/java/sql/__init__.py.bak create mode 100644 dynamicserialize/dstypes/java/util/__init__.py.bak create mode 100644 thrift/TSCons.py.bak create mode 100644 thrift/TSerialization.py.bak create mode 100644 thrift/protocol/TBase.py.bak create mode 100644 thrift/protocol/TBinaryProtocol.py.bak create mode 100644 thrift/protocol/TCompactProtocol.py.bak create mode 100644 thrift/protocol/TProtocol.py.bak create mode 100644 thrift/server/THttpServer.py.bak create mode 100644 thrift/server/TNonblockingServer.py.bak create mode 100644 thrift/server/TProcessPoolServer.py.bak create mode 100644 thrift/server/TServer.py.bak create mode 100644 thrift/transport/THttpClient.py.bak create mode 100644 thrift/transport/TSocket.py.bak create mode 100644 thrift/transport/TTransport.py.bak create mode 100644 thrift/transport/TTwisted.py.bak create mode 100644 thrift/transport/TZlibTransport.py.bak diff --git a/awips/AlertVizHandler.py b/awips/AlertVizHandler.py index 9ecabf4..b20f911 100644 --- a/awips/AlertVizHandler.py +++ b/awips/AlertVizHandler.py @@ -35,7 +35,7 @@ # import logging -import NotificationMessage +from . import NotificationMessage class AlertVizHandler(logging.Handler): diff --git a/awips/AlertVizHandler.py.bak b/awips/AlertVizHandler.py.bak new file mode 100644 index 0000000..9ecabf4 --- /dev/null +++ b/awips/AlertVizHandler.py.bak @@ -0,0 +1,69 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + + +# +# Pure python logging mechanism for logging to AlertViz from +# pure python (ie not JEP). DO NOT USE IN PYTHON CALLED +# FROM JAVA. +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 08/18/10 njensen Initial Creation. +# +# +# + +import logging +import NotificationMessage + +class AlertVizHandler(logging.Handler): + + def __init__(self, host='localhost', port=61999, category='LOCAL', source='ANNOUNCER', level=logging.NOTSET): + logging.Handler.__init__(self, level) + self._category = category + self._host = host + self._port = port + self._source = source + + def emit(self, record): + "Implements logging.Handler's interface. Record argument is a logging.LogRecord." + priority = None + if record.levelno >= 50: + priority = 'CRITICAL' + elif record.levelno >= 40: + priority = 'SIGNIFICANT' + elif record.levelno >= 30: + priority = 'PROBLEM' + elif record.levelno >= 20: + priority = 'EVENTA' + elif record.levelno >= 10: + priority = 'EVENTB' + else: + priority = 'VERBOSE' + + msg = self.format(record) + + notify = NotificationMessage.NotificationMessage(self._host, self._port, msg, priority, self._category, self._source) + notify.send() + diff --git a/awips/DateTimeConverter.py b/awips/DateTimeConverter.py index db9d2a1..6f40eeb 100644 --- a/awips/DateTimeConverter.py +++ b/awips/DateTimeConverter.py @@ -63,10 +63,10 @@ def convertToDateTime(timeArg): return datetime.datetime(*timeArg[:6]) elif isinstance(timeArg, float): # seconds as float, should be avoided due to floating point errors - totalSecs = long(timeArg) + totalSecs = int(timeArg) micros = int((timeArg - totalSecs) * MICROS_IN_SECOND) return _convertSecsAndMicros(totalSecs, micros) - elif isinstance(timeArg, (int, long)): + elif isinstance(timeArg, int): # seconds as integer totalSecs = timeArg return _convertSecsAndMicros(totalSecs, 0) diff --git a/awips/DateTimeConverter.py.bak b/awips/DateTimeConverter.py.bak new file mode 100644 index 0000000..db9d2a1 --- /dev/null +++ b/awips/DateTimeConverter.py.bak @@ -0,0 +1,107 @@ +# # +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +# # + +# +# Functions for converting between the various "Java" dynamic serialize types +# used by EDEX to the native python time datetime. +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 06/24/15 #4480 dgilling Initial Creation. +# + +import datetime +import time + +from dynamicserialize.dstypes.java.util import Date +from dynamicserialize.dstypes.java.sql import Timestamp +from dynamicserialize.dstypes.com.raytheon.uf.common.time import TimeRange + + +MAX_TIME = pow(2, 31) - 1 +MICROS_IN_SECOND = 1000000 + + +def convertToDateTime(timeArg): + """ + Converts the given object to a python datetime object. Supports native + python representations like datetime and struct_time, but also + the dynamicserialize types like Date and Timestamp. Raises TypeError + if no conversion can be performed. + + Args: + timeArg: a python object representing a date and time. Supported + types include datetime, struct_time, float, int, long and the + dynamicserialize types Date and Timestamp. + + Returns: + A datetime that represents the same date/time as the passed in object. + """ + if isinstance(timeArg, datetime.datetime): + return timeArg + elif isinstance(timeArg, time.struct_time): + return datetime.datetime(*timeArg[:6]) + elif isinstance(timeArg, float): + # seconds as float, should be avoided due to floating point errors + totalSecs = long(timeArg) + micros = int((timeArg - totalSecs) * MICROS_IN_SECOND) + return _convertSecsAndMicros(totalSecs, micros) + elif isinstance(timeArg, (int, long)): + # seconds as integer + totalSecs = timeArg + return _convertSecsAndMicros(totalSecs, 0) + elif isinstance(timeArg, (Date, Timestamp)): + totalSecs = timeArg.getTime() + return _convertSecsAndMicros(totalSecs, 0) + else: + objType = str(type(timeArg)) + raise TypeError("Cannot convert object of type " + objType + " to datetime.") + +def _convertSecsAndMicros(seconds, micros): + if seconds < MAX_TIME: + rval = datetime.datetime.utcfromtimestamp(seconds) + else: + extraTime = datetime.timedelta(seconds=(seconds - MAX_TIME)) + rval = datetime.datetime.utcfromtimestamp(MAX_TIME) + extraTime + return rval.replace(microsecond=micros) + +def constructTimeRange(*args): + """ + Builds a python dynamicserialize TimeRange object from the given + arguments. + + Args: + args*: must be a TimeRange or a pair of objects that can be + converted to a datetime via convertToDateTime(). + + Returns: + A TimeRange. + """ + + if len(args) == 1 and isinstance(args[0], TimeRange): + return args[0] + if len(args) != 2: + raise TypeError("constructTimeRange takes exactly 2 arguments, " + str(len(args)) + " provided.") + startTime = convertToDateTime(args[0]) + endTime = convertToDateTime(args[1]) + return TimeRange(startTime, endTime) diff --git a/awips/NotificationMessage.py b/awips/NotificationMessage.py index 47cd4c8..9d0b7ce 100644 --- a/awips/NotificationMessage.py +++ b/awips/NotificationMessage.py @@ -1,19 +1,19 @@ ## # This software was developed and / or modified by Raytheon Company, -# pursuant to Contract DG133W-05-CQ-1067 with the US Government. -# -# U.S. EXPORT CONTROLLED TECHNICAL DATA +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA # This software product contains export-restricted data whose # export/transfer/disclosure is restricted by U.S. law. Dissemination # to non-U.S. persons whether in the United States or abroad requires # an export license or other authorization. # -# Contractor Name: Raytheon Company -# Contractor Address: 6825 Pine Street, Suite 340 -# Mail Stop B8 -# Omaha, NE 68106 -# 402.291.0100 -# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# # See the AWIPS II Master Rights File ("Master Rights File.pdf") for # further licensing information. ## @@ -21,14 +21,14 @@ from string import Template import ctypes -import stomp +from . import stomp import socket import sys import time import threading import xml.etree.ElementTree as ET -import ThriftClient +from . import ThriftClient from dynamicserialize.dstypes.com.raytheon.uf.common.alertviz import AlertVizRequest from dynamicserialize import DynamicSerializationManager @@ -89,8 +89,8 @@ class NotificationMessage: priorityInt = int(5) if (priorityInt < 0 or priorityInt > 5): - print "Error occurred, supplied an invalid Priority value: " + str(priorityInt) - print "Priority values are 0, 1, 2, 3, 4 and 5." + print("Error occurred, supplied an invalid Priority value: " + str(priorityInt)) + print("Priority values are 0, 1, 2, 3, 4 and 5.") sys.exit(1) if priorityInt is not None: @@ -100,8 +100,8 @@ class NotificationMessage: def connection_timeout(self, connection): if (connection is not None and not connection.is_connected()): - print "Connection Retry Timeout" - for tid, tobj in threading._active.items(): + print("Connection Retry Timeout") + for tid, tobj in list(threading._active.items()): if tobj.name is "MainThread": res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(SystemExit)) if res != 0 and res != 1: @@ -150,14 +150,14 @@ class NotificationMessage: serverResponse = None try: serverResponse = thriftClient.sendRequest(alertVizRequest) - except Exception, ex: - print "Caught exception submitting AlertVizRequest: ", str(ex) + except Exception as ex: + print("Caught exception submitting AlertVizRequest: ", str(ex)) if (serverResponse != "None"): - print "Error occurred submitting Notification Message to AlertViz receiver: ", serverResponse + print("Error occurred submitting Notification Message to AlertViz receiver: ", serverResponse) sys.exit(1) else: - print "Response: " + str(serverResponse) + print("Response: " + str(serverResponse)) def createRequest(message, priority, source, category, audioFile): obj = AlertVizRequest() diff --git a/awips/NotificationMessage.py.bak b/awips/NotificationMessage.py.bak new file mode 100644 index 0000000..47cd4c8 --- /dev/null +++ b/awips/NotificationMessage.py.bak @@ -0,0 +1,178 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +from string import Template + +import ctypes +import stomp +import socket +import sys +import time +import threading +import xml.etree.ElementTree as ET + +import ThriftClient +from dynamicserialize.dstypes.com.raytheon.uf.common.alertviz import AlertVizRequest +from dynamicserialize import DynamicSerializationManager + +# +# Provides a capability of constructing notification messages and sending +# them to a STOMP data source. +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 09/30/08 chammack Initial Creation. +# 11/03/10 5849 cjeanbap Moved to awips package from +# com.raytheon.uf.tools.cli +# 01/07/11 5645 cjeanbap Added audio file to Status Message. +# 05/27/11 3050 cjeanbap Added if-statement to check Priority +# value +# +class NotificationMessage: + + priorityMap = { + 0: 'CRITICAL', + 1: 'SIGNIFICANT', + 2: 'PROBLEM', + 3: 'EVENTA', + 4: 'EVENTB', + 5: 'VERBOSE'} + + def __init__(self, host='localhost', port=61999, message='', priority='PROBLEM', category="LOCAL", source="ANNOUNCER", audioFile="NONE"): + self.host = host + self.port = port + self.message = message + self.audioFile = audioFile + self.source = source + self.category = category + + priorityInt = None + + try: + priorityInt = int(priority) + except: + pass + + if priorityInt is None: + #UFStatus.java contains mapping of Priority to Logging level mapping + if priority == 'CRITICAL' or priority == 'FATAL': + priorityInt = int(0) + elif priority == 'SIGNIFICANT' or priority == 'ERROR': + priorityInt = int(1) + elif priority == 'PROBLEM' or priority == 'WARN': + priorityInt = int(2) + elif priority == 'EVENTA' or priority == 'INFO': + priorityInt = int(3) + elif priority == 'EVENTB': + priorityInt = int(4) + elif priority == 'VERBOSE' or priority == 'DEBUG': + priorityInt = int(5) + + if (priorityInt < 0 or priorityInt > 5): + print "Error occurred, supplied an invalid Priority value: " + str(priorityInt) + print "Priority values are 0, 1, 2, 3, 4 and 5." + sys.exit(1) + + if priorityInt is not None: + self.priority = self.priorityMap[priorityInt] + else: + self.priority = priority + + def connection_timeout(self, connection): + if (connection is not None and not connection.is_connected()): + print "Connection Retry Timeout" + for tid, tobj in threading._active.items(): + if tobj.name is "MainThread": + res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(SystemExit)) + if res != 0 and res != 1: + # problem, reset state + ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, 0) + + def send(self): + # depending on the value of the port number indicates the distribution + # of the message to AlertViz + # 9581 is global distribution thru ThriftClient to Edex + # 61999 is local distribution + if (self.port == 61999): + # use stomp.py + conn = stomp.Connection(host_and_ports=[(self.host, self.port)]) + timeout = threading.Timer(5.0, self.connection_timeout, [conn]) + + try: + timeout.start(); + conn.start() + finally: + timeout.cancel() + + conn.connect() + + sm = ET.Element("statusMessage") + sm.set("machine", socket.gethostname()) + sm.set("priority", self.priority) + sm.set("category", self.category) + sm.set("sourceKey", self.source) + sm.set("audioFile", self.audioFile) + msg = ET.SubElement(sm, "message") + msg.text = self.message + details = ET.SubElement(sm, "details") + msg = ET.tostring(sm, "UTF-8") + + try : + conn.send(msg, destination='/queue/messages') + time.sleep(2) + finally: + conn.stop() + else: + # use ThriftClient + alertVizRequest = createRequest(self.message, self.priority, self.source, self.category, self.audioFile) + thriftClient = ThriftClient.ThriftClient(self.host, self.port, "/services") + + serverResponse = None + try: + serverResponse = thriftClient.sendRequest(alertVizRequest) + except Exception, ex: + print "Caught exception submitting AlertVizRequest: ", str(ex) + + if (serverResponse != "None"): + print "Error occurred submitting Notification Message to AlertViz receiver: ", serverResponse + sys.exit(1) + else: + print "Response: " + str(serverResponse) + +def createRequest(message, priority, source, category, audioFile): + obj = AlertVizRequest() + + obj.setMachine(socket.gethostname()) + obj.setPriority(priority) + obj.setCategory(category) + obj.setSourceKey(source) + obj.setMessage(message) + if (audioFile is not None): + obj.setAudioFile(audioFile) + else: + obj.setAudioFile('\0') + + return obj + +if __name__ == '__main__': + main() diff --git a/awips/QpidSubscriber.py b/awips/QpidSubscriber.py index 9a3d5c7..6a9c78c 100644 --- a/awips/QpidSubscriber.py +++ b/awips/QpidSubscriber.py @@ -35,7 +35,7 @@ import qpid import zlib -from Queue import Empty +from queue import Empty from qpid.exceptions import Closed class QpidSubscriber: @@ -56,7 +56,7 @@ class QpidSubscriber: if (topicName == 'edex.alerts'): self.decompress = True - print "Establishing connection to broker on", self.host + print("Establishing connection to broker on", self.host) queueName = topicName + self.__session.name self.__session.queue_declare(queue=queueName, exclusive=True, auto_delete=True, arguments={'qpid.max_count':100, 'qpid.policy_type':'ring'}) self.__session.exchange_bind(exchange='amq.topic', queue=queueName, binding_key=topicName) @@ -67,7 +67,7 @@ class QpidSubscriber: queue = self.__session.incoming(local_queue_name) self.__session.message_subscribe(serverQueueName, destination=local_queue_name) queue.start() - print "Connection complete to broker on", self.host + print("Connection complete to broker on", self.host) while self.subscribed: try: @@ -75,7 +75,7 @@ class QpidSubscriber: content = message.body self.__session.message_accept(qpid.datatypes.RangedSet(message.id)) if (self.decompress): - print "Decompressing received content" + print("Decompressing received content") try: # http://stackoverflow.com/questions/2423866/python-decompressing-gzip-chunk-by-chunk d = zlib.decompressobj(16+zlib.MAX_WBITS) diff --git a/awips/QpidSubscriber.py.bak b/awips/QpidSubscriber.py.bak new file mode 100644 index 0000000..9a3d5c7 --- /dev/null +++ b/awips/QpidSubscriber.py.bak @@ -0,0 +1,97 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# +# Provides a Python-based interface for subscribing to qpid queues and topics. +# +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 11/17/10 njensen Initial Creation. +# 08/15/13 2169 bkowal Optionally gzip decompress any data that is read. +# +# + +import qpid +import zlib + +from Queue import Empty +from qpid.exceptions import Closed + +class QpidSubscriber: + + def __init__(self, host='127.0.0.1', port=5672, decompress=False): + self.host = host + self.port = port + self.decompress = decompress; + socket = qpid.util.connect(host, port) + self.__connection = qpid.connection.Connection(sock=socket, username='guest', password='guest') + self.__connection.start() + self.__session = self.__connection.session(str(qpid.datatypes.uuid4())) + self.subscribed = True + + def topicSubscribe(self, topicName, callback): + # if the queue is edex.alerts, set decompress to true always for now to + # maintain compatibility with existing python scripts. + if (topicName == 'edex.alerts'): + self.decompress = True + + print "Establishing connection to broker on", self.host + queueName = topicName + self.__session.name + self.__session.queue_declare(queue=queueName, exclusive=True, auto_delete=True, arguments={'qpid.max_count':100, 'qpid.policy_type':'ring'}) + self.__session.exchange_bind(exchange='amq.topic', queue=queueName, binding_key=topicName) + self.__innerSubscribe(queueName, callback) + + def __innerSubscribe(self, serverQueueName, callback): + local_queue_name = 'local_queue_' + serverQueueName + queue = self.__session.incoming(local_queue_name) + self.__session.message_subscribe(serverQueueName, destination=local_queue_name) + queue.start() + print "Connection complete to broker on", self.host + + while self.subscribed: + try: + message = queue.get(timeout=10) + content = message.body + self.__session.message_accept(qpid.datatypes.RangedSet(message.id)) + if (self.decompress): + print "Decompressing received content" + try: + # http://stackoverflow.com/questions/2423866/python-decompressing-gzip-chunk-by-chunk + d = zlib.decompressobj(16+zlib.MAX_WBITS) + content = d.decompress(content) + except: + # decompression failed, return the original content + pass + callback(content) + except Empty: + pass + except Closed: + self.close() + + def close(self): + self.subscribed = False + try: + self.__session.close(timeout=10) + except: + pass diff --git a/awips/ThriftClient.py b/awips/ThriftClient.py index 93dd762..94b24d9 100644 --- a/awips/ThriftClient.py +++ b/awips/ThriftClient.py @@ -18,7 +18,7 @@ # further licensing information. ## -import httplib +import http.client from dynamicserialize import DynamicSerializationManager from dynamicserialize.dstypes.com.raytheon.uf.common.serialization.comm.response import ServerErrorResponse from dynamicserialize.dstypes.com.raytheon.uf.common.serialization import SerializableExceptionWrapper @@ -54,12 +54,12 @@ class ThriftClient: if (len(hostParts) > 1): hostString = hostParts[0] self.__uri = "/" + hostParts[1] - self.__httpConn = httplib.HTTPConnection(hostString) + self.__httpConn = http.client.HTTPConnection(hostString) else: if (port is None): - self.__httpConn = httplib.HTTPConnection(host) + self.__httpConn = http.client.HTTPConnection(host) else: - self.__httpConn = httplib.HTTPConnection(host, port) + self.__httpConn = http.client.HTTPConnection(host, port) self.__uri = uri diff --git a/awips/ThriftClient.py.bak b/awips/ThriftClient.py.bak new file mode 100644 index 0000000..93dd762 --- /dev/null +++ b/awips/ThriftClient.py.bak @@ -0,0 +1,101 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +import httplib +from dynamicserialize import DynamicSerializationManager +from dynamicserialize.dstypes.com.raytheon.uf.common.serialization.comm.response import ServerErrorResponse +from dynamicserialize.dstypes.com.raytheon.uf.common.serialization import SerializableExceptionWrapper + +# +# Provides a Python-based interface for executing Thrift requests. +# +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 09/20/10 dgilling Initial Creation. +# +# +# + +class ThriftClient: + + # How to call this constructor: + # 1. Pass in all arguments separately (e.g., + # ThriftClient.ThriftClient("localhost", 9581, "/services")) + # will return a Thrift client pointed at http://localhost:9581/services. + # 2. Pass in all arguments through the host string (e.g., + # ThriftClient.ThriftClient("localhost:9581/services")) + # will return a Thrift client pointed at http://localhost:9581/services. + # 3. Pass in host/port arguments through the host string (e.g., + # ThriftClient.ThriftClient("localhost:9581", "/services")) + # will return a Thrift client pointed at http://localhost:9581/services. + def __init__(self, host, port=9581, uri="/services"): + hostParts = host.split("/", 1) + if (len(hostParts) > 1): + hostString = hostParts[0] + self.__uri = "/" + hostParts[1] + self.__httpConn = httplib.HTTPConnection(hostString) + else: + if (port is None): + self.__httpConn = httplib.HTTPConnection(host) + else: + self.__httpConn = httplib.HTTPConnection(host, port) + + self.__uri = uri + + self.__dsm = DynamicSerializationManager.DynamicSerializationManager() + + def sendRequest(self, request, uri="/thrift"): + message = self.__dsm.serializeObject(request) + + self.__httpConn.connect() + self.__httpConn.request("POST", self.__uri + uri, message) + + response = self.__httpConn.getresponse() + if (response.status != 200): + raise ThriftRequestException("Unable to post request to server") + + rval = self.__dsm.deserializeBytes(response.read()) + self.__httpConn.close() + + # let's verify we have an instance of ServerErrorResponse + # IF we do, through an exception up to the caller along + # with the original Java stack trace + # ELSE: we have a valid response and pass it back + try: + forceError = rval.getException() + raise ThriftRequestException(forceError) + except AttributeError: + pass + + return rval + + +class ThriftRequestException(Exception): + def __init__(self, value): + self.parameter = value + + def __str__(self): + return repr(self.parameter) + + diff --git a/awips/TimeUtil.py b/awips/TimeUtil.py index 13b3a5c..db50bba 100644 --- a/awips/TimeUtil.py +++ b/awips/TimeUtil.py @@ -87,7 +87,7 @@ def determineDrtOffset(timeStr): #print "gmtime", gm if synch: cur_t = time.mktime((gm[0], gm[1], gm[2], gm[3], 0, 0, 0, 0, 0)) - curStr = '%4s%2s%2s_%2s00\n' % (`gm[0]`,`gm[1]`,`gm[2]`,`gm[3]`) + curStr = '%4s%2s%2s_%2s00\n' % (repr(gm[0]),repr(gm[1]),repr(gm[2]),repr(gm[3])) curStr = curStr.replace(' ','0') launchStr = timeStr + "," + curStr diff --git a/awips/TimeUtil.py.bak b/awips/TimeUtil.py.bak new file mode 100644 index 0000000..13b3a5c --- /dev/null +++ b/awips/TimeUtil.py.bak @@ -0,0 +1,108 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +# ---------------------------------------------------------------------------- +# This software is in the public domain, furnished "as is", without technical +# support, and with no warranty, express or implied, as to its usefulness for +# any purpose. +# +# offsetTime.py +# Handles Displaced Real Time for various applications +# +# Author: hansen/romberg +# ---------------------------------------------------------------------------- + +import string +import time + +# Given the timeStr, return the offset (in seconds) +# from the current time. +# Also return the launchStr i.e. Programs launched from this +# offset application will use the launchStr as the -z argument. +# The offset will be positive for time in the future, +# negative for time in the past. +# +# May still want it to be normalized to the most recent midnight. +# +# NOTES about synchronizing: +# --With synchronizing on, the "current time" for all processes started +# within a given hour will be the same. +# This guarantees that GFE's have the same current time and ISC grid +# time stamps are syncrhonized and can be exchanged. +# Formatters launched from the GFE in this mode will be synchronized as +# well by setting the launchStr to use the time difference format +# (YYYYMMDD_HHMM,YYYYMMDD_HHMM). +# --This does not solve the problem in the general case. +# For example, if someone starts the GFE at 12:59 and someone +# else starts it at 1:01, they will have different offsets and +# current times. +# --With synchronizing off, when the process starts, the current time +# matches the drtTime in the command line. However, with synchronizing +# on, the current time will be offset by the fraction of the hour at +# which the process was started. Examples: +# Actual Starting time: 20040617_1230 +# drtTime 20040616_0000 +# Synchronizing off: +# GFE Spatial Editor at StartUp: 20040616_0000 +# Synchronizing on: +# GFE Spatial Editor at StartUp: 20040616_0030 +# +def determineDrtOffset(timeStr): + launchStr = timeStr + # Check for time difference + if timeStr.find(",") >=0: + times = timeStr.split(",") + t1 = makeTime(times[0]) + t2 = makeTime(times[1]) + #print "time offset", t1-t2, (t1-t2)/3600 + return t1-t2, launchStr + # Check for synchronized mode + synch = 0 + if timeStr[0] == "S": + timeStr = timeStr[1:] + synch = 1 + drt_t = makeTime(timeStr) + #print "input", year, month, day, hour, minute + gm = time.gmtime() + cur_t = time.mktime(gm) + + # Synchronize to most recent hour + # i.e. "truncate" cur_t to most recent hour. + #print "gmtime", gm + if synch: + cur_t = time.mktime((gm[0], gm[1], gm[2], gm[3], 0, 0, 0, 0, 0)) + curStr = '%4s%2s%2s_%2s00\n' % (`gm[0]`,`gm[1]`,`gm[2]`,`gm[3]`) + curStr = curStr.replace(' ','0') + launchStr = timeStr + "," + curStr + + #print "drt, cur", drt_t, cur_t + offset = drt_t - cur_t + #print "offset", offset, offset/3600, launchStr + return int(offset), launchStr + +def makeTime(timeStr): + year = string.atoi(timeStr[0:4]) + month = string.atoi(timeStr[4:6]) + day = string.atoi(timeStr[6:8]) + hour = string.atoi(timeStr[9:11]) + minute = string.atoi(timeStr[11:13]) + # Do not use daylight savings because gmtime is not in daylight + # savings time. + return time.mktime((year, month, day, hour, minute, 0, 0, 0, 0)) + diff --git a/awips/dataaccess/DataAccessLayer.py b/awips/dataaccess/DataAccessLayer.py index 4ab02b7..b6d7b59 100644 --- a/awips/dataaccess/DataAccessLayer.py +++ b/awips/dataaccess/DataAccessLayer.py @@ -47,7 +47,7 @@ import subprocess THRIFT_HOST = "edex" USING_NATIVE_THRIFT = False -if sys.modules.has_key('jep'): +if 'jep' in sys.modules: # intentionally do not catch if this fails to import, we want it to # be obvious that something is configured wrong when running from within # Java instead of allowing false confidence and fallback behavior diff --git a/awips/dataaccess/DataAccessLayer.py.bak b/awips/dataaccess/DataAccessLayer.py.bak new file mode 100644 index 0000000..4ab02b7 --- /dev/null +++ b/awips/dataaccess/DataAccessLayer.py.bak @@ -0,0 +1,215 @@ +# # +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +# # + + +# +# Published interface for awips.dataaccess package +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 12/10/12 njensen Initial Creation. +# Feb 14, 2013 1614 bsteffen refactor data access framework +# to use single request. +# 04/10/13 1871 mnash move getLatLonCoords to JGridData and add default args +# 05/29/13 2023 dgilling Hook up ThriftClientRouter. +# 03/03/14 2673 bsteffen Add ability to query only ref times. +# 07/22/14 3185 njensen Added optional/default args to newDataRequest +# 07/30/14 3185 njensen Renamed valid identifiers to optional +# Apr 26, 2015 4259 njensen Updated for new JEP API +# +# +# + + +import sys +import subprocess + +THRIFT_HOST = "edex" +USING_NATIVE_THRIFT = False + +if sys.modules.has_key('jep'): + # intentionally do not catch if this fails to import, we want it to + # be obvious that something is configured wrong when running from within + # Java instead of allowing false confidence and fallback behavior + import JepRouter + router = JepRouter +else: + from awips.dataaccess import ThriftClientRouter + router = ThriftClientRouter.ThriftClientRouter(THRIFT_HOST) + USING_NATIVE_THRIFT = True + + +def getAvailableTimes(request, refTimeOnly=False): + """ + Get the times of available data to the request. + + Args: + request: the IDataRequest to get data for + refTimeOnly: optional, use True if only unique refTimes should be + returned (without a forecastHr) + + Returns: + a list of DataTimes + """ + return router.getAvailableTimes(request, refTimeOnly) + +def getGridData(request, times=[]): + """ + Gets the grid data that matches the request at the specified times. Each + combination of parameter, level, and dataTime will be returned as a + separate IGridData. + + Args: + request: the IDataRequest to get data for + times: a list of DataTimes, a TimeRange, or None if the data is time + agnostic + + Returns: + a list of IGridData + """ + return router.getGridData(request, times) + +def getGeometryData(request, times=[]): + """ + Gets the geometry data that matches the request at the specified times. + Each combination of geometry, level, and dataTime will be returned as a + separate IGeometryData. + + Args: + request: the IDataRequest to get data for + times: a list of DataTimes, a TimeRange, or None if the data is time + agnostic + + Returns: + a list of IGeometryData + """ + return router.getGeometryData(request, times) + +def getAvailableLocationNames(request): + """ + Gets the available location names that match the request without actually + requesting the data. + + Args: + request: the request to find matching location names for + + Returns: + a list of strings of available location names. + """ + return router.getAvailableLocationNames(request) + +def getAvailableParameters(request): + """ + Gets the available parameters names that match the request without actually + requesting the data. + + Args: + request: the request to find matching parameter names for + + Returns: + a list of strings of available parameter names. + """ + return router.getAvailableParameters(request) + +def getAvailableLevels(request): + """ + Gets the available levels that match the request without actually + requesting the data. + + Args: + request: the request to find matching levels for + + Returns: + a list of strings of available levels. + """ + return router.getAvailableLevels(request) + +def getRequiredIdentifiers(datatype): + """ + Gets the required identifiers for this datatype. These identifiers + must be set on a request for the request of this datatype to succeed. + + Args: + datatype: the datatype to find required identifiers for + + Returns: + a list of strings of required identifiers + """ + return router.getRequiredIdentifiers(datatype) + +def getOptionalIdentifiers(datatype): + """ + Gets the optional identifiers for this datatype. + + Args: + datatype: the datatype to find optional identifiers for + + Returns: + a list of strings of optional identifiers + """ + return router.getOptionalIdentifiers(datatype) + +def newDataRequest(datatype=None, **kwargs): + """" + Creates a new instance of IDataRequest suitable for the runtime environment. + All args are optional and exist solely for convenience. + + Args: + datatype: the datatype to create a request for + parameters: a list of parameters to set on the request + levels: a list of levels to set on the request + locationNames: a list of locationNames to set on the request + envelope: an envelope to limit the request + **kwargs: any leftover kwargs will be set as identifiers + + Returns: + a new IDataRequest + """ + return router.newDataRequest(datatype, **kwargs) + +def getSupportedDatatypes(): + """ + Gets the datatypes that are supported by the framework + + Returns: + a list of strings of supported datatypes + """ + return router.getSupportedDatatypes() + + +def changeEDEXHost(newHostName): + """ + Changes the EDEX host the Data Access Framework is communicating with. Only + works if using the native Python client implementation, otherwise, this + method will throw a TypeError. + + Args: + newHostHame: the EDEX host to connect to + """ + if USING_NATIVE_THRIFT: + global THRIFT_HOST + THRIFT_HOST = newHostName + global router + router = ThriftClientRouter.ThriftClientRouter(THRIFT_HOST) + else: + raise TypeError("Cannot call changeEDEXHost when using JepRouter.") diff --git a/awips/dataaccess/PyData.py b/awips/dataaccess/PyData.py index 2ccd767..47a36e9 100644 --- a/awips/dataaccess/PyData.py +++ b/awips/dataaccess/PyData.py @@ -45,7 +45,7 @@ class PyData(IData): return self.__attributes[key] def getAttributes(self): - return self.__attributes.keys() + return list(self.__attributes.keys()) def getDataTime(self): return self.__time diff --git a/awips/dataaccess/PyData.py.bak b/awips/dataaccess/PyData.py.bak new file mode 100644 index 0000000..2ccd767 --- /dev/null +++ b/awips/dataaccess/PyData.py.bak @@ -0,0 +1,57 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# +# Implements IData for use by native Python clients to the Data Access +# Framework. +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 06/03/13 dgilling Initial Creation. +# +# + +from awips.dataaccess import IData + +class PyData(IData): + + def __init__(self, dataRecord): + self.__time = dataRecord.getTime() + self.__level = dataRecord.getLevel() + self.__locationName = dataRecord.getLocationName() + self.__attributes = dataRecord.getAttributes() + + def getAttribute(self, key): + return self.__attributes[key] + + def getAttributes(self): + return self.__attributes.keys() + + def getDataTime(self): + return self.__time + + def getLevel(self): + return self.__level + + def getLocationName(self): + return self.__locationName diff --git a/awips/dataaccess/PyGeometryData.py b/awips/dataaccess/PyGeometryData.py index 1692867..6debd3d 100644 --- a/awips/dataaccess/PyGeometryData.py +++ b/awips/dataaccess/PyGeometryData.py @@ -45,14 +45,14 @@ class PyGeometryData(IGeometryData, PyData.PyData): self.__geometry = geometry self.__dataMap = {} tempDataMap = geoDataRecord.getDataMap() - for key, value in tempDataMap.items(): + for key, value in list(tempDataMap.items()): self.__dataMap[key] = (value[0], value[1], value[2]) def getGeometry(self): return self.__geometry def getParameters(self): - return self.__dataMap.keys() + return list(self.__dataMap.keys()) def getString(self, param): value = self.__dataMap[param][0] @@ -64,7 +64,7 @@ class PyGeometryData(IGeometryData, PyData.PyData): if t == 'INT': return int(value) elif t == 'LONG': - return long(value) + return int(value) elif t == 'FLOAT': return float(value) elif t == 'DOUBLE': diff --git a/awips/dataaccess/PyGeometryData.py.bak b/awips/dataaccess/PyGeometryData.py.bak new file mode 100644 index 0000000..1692867 --- /dev/null +++ b/awips/dataaccess/PyGeometryData.py.bak @@ -0,0 +1,79 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# +# Implements IGeometryData for use by native Python clients to the Data Access +# Framework. +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 06/03/13 dgilling Initial Creation. +# 01/06/14 #2537 bsteffen Share geometry WKT. +# 03/19/14 #2882 dgilling Raise an exception when getNumber() +# is called for data that is not a +# numeric Type. +# +# + +from awips.dataaccess import IGeometryData +from awips.dataaccess import PyData + +class PyGeometryData(IGeometryData, PyData.PyData): + + def __init__(self, geoDataRecord, geometry): + PyData.PyData.__init__(self, geoDataRecord) + self.__geometry = geometry + self.__dataMap = {} + tempDataMap = geoDataRecord.getDataMap() + for key, value in tempDataMap.items(): + self.__dataMap[key] = (value[0], value[1], value[2]) + + def getGeometry(self): + return self.__geometry + + def getParameters(self): + return self.__dataMap.keys() + + def getString(self, param): + value = self.__dataMap[param][0] + return str(value) + + def getNumber(self, param): + value = self.__dataMap[param][0] + t = self.getType(param) + if t == 'INT': + return int(value) + elif t == 'LONG': + return long(value) + elif t == 'FLOAT': + return float(value) + elif t == 'DOUBLE': + return float(value) + else: + raise TypeError("Data for parameter " + param + " is not a numeric type.") + + def getUnit(self, param): + return self.__dataMap[param][2] + + def getType(self, param): + return self.__dataMap[param][1] diff --git a/awips/dataaccess/SoundingsSupport.py b/awips/dataaccess/SoundingsSupport.py index 7e043c5..15ea14f 100644 --- a/awips/dataaccess/SoundingsSupport.py +++ b/awips/dataaccess/SoundingsSupport.py @@ -128,7 +128,7 @@ def __buildStringList(param): return [str(param)] def __notStringIter(iterable): - if not isinstance(iterable, basestring): + if not isinstance(iterable, str): try: iter(iterable) return True @@ -226,7 +226,7 @@ class _SoundingTimeLayer(object): A list containing the valid levels for this sounding in order of closest to surface to highest from surface. """ - sortedLevels = [Level(level) for level in self._dataDict.keys()] + sortedLevels = [Level(level) for level in list(self._dataDict.keys())] sortedLevels.sort() return [str(level) for level in sortedLevels] diff --git a/awips/dataaccess/SoundingsSupport.py.bak b/awips/dataaccess/SoundingsSupport.py.bak new file mode 100644 index 0000000..7e043c5 --- /dev/null +++ b/awips/dataaccess/SoundingsSupport.py.bak @@ -0,0 +1,283 @@ +# # +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +# # + +# +# Classes for retrieving soundings based on gridded data from the Data Access +# Framework +# +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 06/24/15 #4480 dgilling Initial Creation. +# + +from collections import defaultdict +from shapely.geometry import Point + +from awips import DateTimeConverter +from awips.dataaccess import DataAccessLayer + +from dynamicserialize.dstypes.com.raytheon.uf.common.time import DataTime +from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.level import Level + + +def getSounding(modelName, weatherElements, levels, samplePoint, refTime=None, timeRange=None): + """" + Performs a series of Data Access Framework requests to retrieve a sounding object + based on the specified request parameters. + + Args: + modelName: the grid model datasetid to use as the basis of the sounding. + weatherElements: a list of parameters to return in the sounding. + levels: a list of levels to sample the given weather elements at + samplePoint: a lat/lon pair to perform the sampling of data at. + refTime: (optional) the grid model reference time to use for the sounding. + If not specified, the latest ref time in the system will be used. + timeRange: (optional) a TimeRange to specify which forecast hours to use. + If not specified, will default to all forecast hours. + + Returns: + A _SoundingCube instance, which acts a 3-tiered dictionary, keyed + by DataTime, then by level and finally by weather element. If no + data is available for the given request parameters, None is returned. + """ + + (locationNames, parameters, levels, envelope, refTime, timeRange) = \ + __sanitizeInputs(modelName, weatherElements, levels, samplePoint, refTime, timeRange) + + requestArgs = { 'datatype' : 'grid', + 'locationNames' : locationNames, + 'parameters' : parameters, + 'levels' : levels, + 'envelope' : envelope, + } + + req = DataAccessLayer.newDataRequest(**requestArgs) + + forecastHours = __determineForecastHours(req, refTime, timeRange) + if not forecastHours: + return None + + response = DataAccessLayer.getGeometryData(req, forecastHours) + soundingObject = _SoundingCube(response) + + return soundingObject + +def setEDEXHost(host): + """ + Changes the EDEX host the Data Access Framework is communicating with. + + Args: + host: the EDEX host to connect to + """ + + if host: + DataAccessLayer.changeEDEXHost(str(host)) + +def __sanitizeInputs(modelName, weatherElements, levels, samplePoint, refTime, timeRange): + locationNames = [str(modelName)] + parameters = __buildStringList(weatherElements) + levels = __buildStringList(levels) + envelope = Point(samplePoint) + if refTime is not None: + refTime = DataTime(refTime=DateTimeConverter.convertToDateTime(refTime)) + if timeRange is not None: + timeRange = DateTimeConverter.constructTimeRange(*timeRange) + return (locationNames, parameters, levels, envelope, refTime, timeRange) + +def __determineForecastHours(request, refTime, timeRange): + dataTimes = DataAccessLayer.getAvailableTimes(request, False) + timesGen = [(DataTime(refTime=dataTime.getRefTime()), dataTime) for dataTime in dataTimes] + dataTimesMap = defaultdict(list) + for baseTime, dataTime in timesGen: + dataTimesMap[baseTime].append(dataTime) + + if refTime is None: + refTime = max(dataTimesMap.keys()) + + forecastHours = dataTimesMap[refTime] + if timeRange is None: + return forecastHours + else: + return [forecastHour for forecastHour in forecastHours if timeRange.contains(forecastHour.getValidPeriod())] + +def __buildStringList(param): + if __notStringIter(param): + return [str(item) for item in param] + else: + return [str(param)] + +def __notStringIter(iterable): + if not isinstance(iterable, basestring): + try: + iter(iterable) + return True + except TypeError: + return False + + + +class _SoundingCube(object): + """ + The top-level sounding object returned when calling SoundingsSupport.getSounding. + + This object acts as a 3-tiered dict which is keyed by time then level + then parameter name. Calling times() will return all valid keys into this + object. + """ + + def __init__(self, geometryDataObjects): + self._dataDict = {} + self._sortedTimes = [] + if geometryDataObjects: + for geometryData in geometryDataObjects: + dataTime = geometryData.getDataTime() + level = geometryData.getLevel() + for parameter in geometryData.getParameters(): + self.__addItem(parameter, dataTime, level, geometryData.getNumber(parameter)) + + def __addItem(self, parameter, dataTime, level, value): + timeLayer = self._dataDict.get(dataTime, _SoundingTimeLayer(dataTime)) + self._dataDict[dataTime] = timeLayer + timeLayer._addItem(parameter, level, value) + if dataTime not in self._sortedTimes: + self._sortedTimes.append(dataTime) + self._sortedTimes.sort() + + def __getitem__(self, key): + return self._dataDict[key] + + def __len__(self): + return len(self._dataDict) + + def times(self): + """ + Returns the valid times for this sounding. + + Returns: + A list containing the valid DataTimes for this sounding in order. + """ + return self._sortedTimes + + +class _SoundingTimeLayer(object): + """ + The second-level sounding object returned when calling SoundingsSupport.getSounding. + + This object acts as a 2-tiered dict which is keyed by level then parameter + name. Calling levels() will return all valid keys into this + object. Calling time() will return the DataTime for this particular layer. + """ + + def __init__(self, dataTime): + self._dataTime = dataTime + self._dataDict = {} + + def _addItem(self, parameter, level, value): + asString = str(level) + levelLayer = self._dataDict.get(asString, _SoundingTimeAndLevelLayer(self._dataTime, asString)) + levelLayer._addItem(parameter, value) + self._dataDict[asString] = levelLayer + + def __getitem__(self, key): + asString = str(key) + if asString in self._dataDict: + return self._dataDict[asString] + else: + raise KeyError("Level " + str(key) + " is not a valid level for this sounding.") + + def __len__(self): + return len(self._dataDict) + + def time(self): + """ + Returns the DataTime for this sounding cube layer. + + Returns: + The DataTime for this sounding layer. + """ + return self._dataTime + + def levels(self): + """ + Returns the valid levels for this sounding. + + Returns: + A list containing the valid levels for this sounding in order of + closest to surface to highest from surface. + """ + sortedLevels = [Level(level) for level in self._dataDict.keys()] + sortedLevels.sort() + return [str(level) for level in sortedLevels] + + +class _SoundingTimeAndLevelLayer(object): + """ + The bottom-level sounding object returned when calling SoundingsSupport.getSounding. + + This object acts as a dict which is keyed by parameter name. Calling + parameters() will return all valid keys into this object. Calling time() + will return the DataTime for this particular layer. Calling level() will + return the level for this layer. + """ + + def __init__(self, time, level): + self._time = time + self._level = level + self._parameters = {} + + def _addItem(self, parameter, value): + self._parameters[parameter] = value + + def __getitem__(self, key): + return self._parameters[key] + + def __len__(self): + return len(self._parameters) + + def level(self): + """ + Returns the level for this sounding cube layer. + + Returns: + The level for this sounding layer. + """ + return self._level + + def parameters(self): + """ + Returns the valid parameters for this sounding. + + Returns: + A list containing the valid parameter names. + """ + return list(self._parameters.keys()) + + def time(self): + """ + Returns the DataTime for this sounding cube layer. + + Returns: + The DataTime for this sounding layer. + """ + return self._time diff --git a/awips/dataaccess/ThriftClientRouter.py b/awips/dataaccess/ThriftClientRouter.py index b568b56..da10421 100644 --- a/awips/dataaccess/ThriftClientRouter.py +++ b/awips/dataaccess/ThriftClientRouter.py @@ -83,7 +83,7 @@ class ThriftClientRouter(object): response = self._client.sendRequest(gridDataRequest) locSpecificData = {} - locNames = response.getSiteNxValues().keys() + locNames = list(response.getSiteNxValues().keys()) for location in locNames: nx = response.getSiteNxValues()[location] ny = response.getSiteNyValues()[location] @@ -114,7 +114,7 @@ class ThriftClientRouter(object): geometries = [] for wkb in response.getGeometryWKBs(): # convert the wkb to a bytearray with only positive values - byteArrWKB = bytearray(map(lambda x: x % 256,wkb.tolist())) + byteArrWKB = bytearray([x % 256 for x in wkb.tolist()]) # convert the bytearray to a byte string and load it. geometries.append(shapely.wkb.loads(str(byteArrWKB))) diff --git a/awips/dataaccess/ThriftClientRouter.py.bak b/awips/dataaccess/ThriftClientRouter.py.bak new file mode 100644 index 0000000..b568b56 --- /dev/null +++ b/awips/dataaccess/ThriftClientRouter.py.bak @@ -0,0 +1,176 @@ +# # +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +# # + +# +# Routes requests to the Data Access Framework through Python Thrift. +# +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 05/21/13 #2023 dgilling Initial Creation. +# 01/06/14 #2537 bsteffen Share geometry WKT. +# 03/03/14 #2673 bsteffen Add ability to query only ref times. +# 07/22/14 #3185 njensen Added optional/default args to newDataRequest +# 07/23/14 #3185 njensen Added new methods +# 07/30/14 #3185 njensen Renamed valid identifiers to optional +# 06/30/15 #4569 nabowle Use hex WKB for geometries. +# + + +import numpy +import shapely.wkb + +from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.impl import DefaultDataRequest +from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetAvailableLocationNamesRequest +from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetAvailableTimesRequest +from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetGeometryDataRequest +from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetGridDataRequest +from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetAvailableParametersRequest +from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetAvailableLevelsRequest +from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetRequiredIdentifiersRequest +from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetOptionalIdentifiersRequest +from dynamicserialize.dstypes.com.raytheon.uf.common.dataaccess.request import GetSupportedDatatypesRequest + +from awips import ThriftClient +from awips.dataaccess import PyGeometryData +from awips.dataaccess import PyGridData + + +class ThriftClientRouter(object): + + def __init__(self, host='localhost'): + self._client = ThriftClient.ThriftClient(host) + + def getAvailableTimes(self, request, refTimeOnly): + timesRequest = GetAvailableTimesRequest() + timesRequest.setRequestParameters(request) + timesRequest.setRefTimeOnly(refTimeOnly) + response = self._client.sendRequest(timesRequest) + return response + + def getGridData(self, request, times): + gridDataRequest = GetGridDataRequest() + gridDataRequest.setRequestParameters(request) + # if we have an iterable times instance, then the user must have asked + # for grid data with the List of DataTime objects + # else, we assume it was a single TimeRange that was meant for the + # request + try: + iter(times) + gridDataRequest.setRequestedTimes(times) + except TypeError: + gridDataRequest.setRequestedPeriod(times) + response = self._client.sendRequest(gridDataRequest) + + locSpecificData = {} + locNames = response.getSiteNxValues().keys() + for location in locNames: + nx = response.getSiteNxValues()[location] + ny = response.getSiteNyValues()[location] + latData = numpy.reshape(numpy.array(response.getSiteLatGrids()[location]), (nx, ny)) + lonData = numpy.reshape(numpy.array(response.getSiteLonGrids()[location]), (nx, ny)) + locSpecificData[location] = (nx, ny, (lonData, latData)) + + retVal = [] + for gridDataRecord in response.getGridData(): + locationName = gridDataRecord.getLocationName() + locData = locSpecificData[locationName] + retVal.append(PyGridData.PyGridData(gridDataRecord, locData[0], locData[1], locData[2])) + return retVal + + def getGeometryData(self, request, times): + geoDataRequest = GetGeometryDataRequest() + geoDataRequest.setRequestParameters(request) + # if we have an iterable times instance, then the user must have asked + # for geometry data with the List of DataTime objects + # else, we assume it was a single TimeRange that was meant for the + # request + try: + iter(times) + geoDataRequest.setRequestedTimes(times) + except TypeError: + geoDataRequest.setRequestedPeriod(times) + response = self._client.sendRequest(geoDataRequest) + geometries = [] + for wkb in response.getGeometryWKBs(): + # convert the wkb to a bytearray with only positive values + byteArrWKB = bytearray(map(lambda x: x % 256,wkb.tolist())) + # convert the bytearray to a byte string and load it. + geometries.append(shapely.wkb.loads(str(byteArrWKB))) + + retVal = [] + for geoDataRecord in response.getGeoData(): + geom = geometries[geoDataRecord.getGeometryWKBindex()] + retVal.append(PyGeometryData.PyGeometryData(geoDataRecord, geom)) + return retVal + + def getAvailableLocationNames(self, request): + locNamesRequest = GetAvailableLocationNamesRequest() + locNamesRequest.setRequestParameters(request) + response = self._client.sendRequest(locNamesRequest) + return response + + def getAvailableParameters(self, request): + paramReq = GetAvailableParametersRequest() + paramReq.setRequestParameters(request) + response = self._client.sendRequest(paramReq) + return response + + def getAvailableLevels(self, request): + levelReq = GetAvailableLevelsRequest() + levelReq.setRequestParameters(request) + response = self._client.sendRequest(levelReq) + return response + + def getRequiredIdentifiers(self, datatype): + idReq = GetRequiredIdentifiersRequest() + idReq.setDatatype(datatype) + response = self._client.sendRequest(idReq) + return response + + def getOptionalIdentifiers(self, datatype): + idReq = GetOptionalIdentifiersRequest() + idReq.setDatatype(datatype) + response = self._client.sendRequest(idReq) + return response + + def newDataRequest(self, datatype, parameters=[], levels=[], locationNames = [], envelope=None, **kwargs): + req = DefaultDataRequest() + if datatype: + req.setDatatype(datatype) + if parameters: + req.setParameters(*parameters) + if levels: + req.setLevels(*levels) + if locationNames: + req.setLocationNames(*locationNames) + if envelope: + req.setEnvelope(envelope) + if kwargs: + # any args leftover are assumed to be identifiers + req.identifiers = kwargs + return req + + def getSupportedDatatypes(self): + response = self._client.sendRequest(GetSupportedDatatypesRequest()) + return response diff --git a/awips/dataaccess/__init__.py b/awips/dataaccess/__init__.py index 1b39e77..389f6e4 100644 --- a/awips/dataaccess/__init__.py +++ b/awips/dataaccess/__init__.py @@ -42,11 +42,10 @@ __all__ = [ import abc -class IDataRequest(object): +class IDataRequest(object, metaclass=abc.ABCMeta): """ An IDataRequest to be submitted to the DataAccessLayer to retrieve data. """ - __metaclass__ = abc.ABCMeta @abc.abstractmethod def setDatatype(self, datatype): @@ -164,11 +163,10 @@ class IDataRequest(object): -class IData(object): +class IData(object, metaclass=abc.ABCMeta): """ An IData representing data returned from the DataAccessLayer. """ - __metaclass__ = abc.ABCMeta @abc.abstractmethod def getAttribute(self, key): diff --git a/awips/dataaccess/__init__.py.bak b/awips/dataaccess/__init__.py.bak new file mode 100644 index 0000000..1b39e77 --- /dev/null +++ b/awips/dataaccess/__init__.py.bak @@ -0,0 +1,353 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + + +# +# __init__.py for awips.dataaccess package +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 12/10/12 njensen Initial Creation. +# Feb 14, 2013 1614 bsteffen refactor data access framework +# to use single request. +# Apr 09, 2013 1871 njensen Add doc strings +# Jun 03, 2013 2023 dgilling Add getAttributes to IData, add +# getLatLonGrids() to IGridData. +# +# + +__all__ = [ + + ] + +import abc + +class IDataRequest(object): + """ + An IDataRequest to be submitted to the DataAccessLayer to retrieve data. + """ + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def setDatatype(self, datatype): + """ + Sets the datatype of the request. + + Args: + datatype: A string of the datatype, such as "grid", "radar", "gfe", "obs" + """ + return + + @abc.abstractmethod + def addIdentifier(self, key, value): + """ + Adds an identifier to the request. Identifiers are specific to the + datatype being requested. + + Args: + key: the string key of the identifier + value: the value of the identifier + """ + return + + @abc.abstractmethod + def setParameters(self, params): + """ + Sets the parameters of data to request. + + Args: + params: a list of strings of parameters to request + """ + return + + @abc.abstractmethod + def setLevels(self, levels): + """ + Sets the levels of data to request. Not all datatypes support levels. + + Args: + levels: a list of strings of level abbreviations to request + """ + return + + @abc.abstractmethod + def setEnvelope(self, env): + """ + Sets the envelope of the request. If supported by the datatype factory, + the data returned for the request will be constrained to only the data + within the envelope. + + Args: + env: a shapely geometry + """ + return + + @abc.abstractmethod + def setLocationNames(self, locationNames): + """ + Sets the location names of the request. + + Args: + locationNames: a list of strings of location names to request + """ + return + + @abc.abstractmethod + def getDatatype(self): + """ + Gets the datatype of the request + + Returns: + the datatype set on the request + """ + return + + @abc.abstractmethod + def getIdentifiers(self): + """ + Gets the identifiers on the request + + Returns: + a dictionary of the identifiers + """ + return + + @abc.abstractmethod + def getLevels(self): + """ + Gets the levels on the request + + Returns: + a list of strings of the levels + """ + return + + @abc.abstractmethod + def getLocationNames(self): + """ + Gets the location names on the request + + Returns: + a list of strings of the location names + """ + return + + @abc.abstractmethod + def getEnvelope(self): + """ + Gets the envelope on the request + + Returns: + a rectangular shapely geometry + """ + return + + + +class IData(object): + """ + An IData representing data returned from the DataAccessLayer. + """ + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def getAttribute(self, key): + """ + Gets an attribute of the data. + + Args: + key: the key of the attribute + + Returns: + the value of the attribute + """ + return + + @abc.abstractmethod + def getAttributes(self): + """ + Gets the valid attributes for the data. + + Returns: + a list of strings of the attribute names + """ + return + + @abc.abstractmethod + def getDataTime(self): + """ + Gets the data time of the data. + + Returns: + the data time of the data, or None if no time is associated + """ + return + + @abc.abstractmethod + def getLevel(self): + """ + Gets the level of the data. + + Returns: + the level of the data, or None if no level is associated + """ + return + + @abc.abstractmethod + def getLocationName(self, param): + """ + Gets the location name of the data. + + Returns: + the location name of the data, or None if no location name is + associated + """ + return + + + +class IGridData(IData): + """ + An IData representing grid data that is returned by the DataAccessLayer. + """ + + @abc.abstractmethod + def getParameter(self): + """ + Gets the parameter of the data. + + Returns: + the parameter of the data + """ + return + + @abc.abstractmethod + def getUnit(self): + """ + Gets the unit of the data. + + Returns: + the string abbreviation of the unit, or None if no unit is associated + """ + return + + @abc.abstractmethod + def getRawData(self): + """ + Gets the grid data as a numpy array. + + Returns: + a numpy array of the data + """ + return + + @abc.abstractmethod + def getLatLonCoords(self): + """ + Gets the lat/lon coordinates of the grid data. + + Returns: + a tuple where the first element is a numpy array of lons, and the + second element is a numpy array of lats + """ + return + + + +class IGeometryData(IData): + """ + An IData representing geometry data that is returned by the DataAccessLayer. + """ + + @abc.abstractmethod + def getGeometry(self): + """ + Gets the geometry of the data. + + Returns: + a shapely geometry + """ + return + + @abc.abstractmethod + def getParameters(self): + """Gets the parameters of the data. + + Returns: + a list of strings of the parameter names + """ + return + + @abc.abstractmethod + def getString(self, param): + """ + Gets the string value of the specified param. + + Args: + param: the string name of the param + + Returns: + the string value of the param + """ + return + + @abc.abstractmethod + def getNumber(self, param): + """ + Gets the number value of the specified param. + + Args: + param: the string name of the param + + Returns: + the number value of the param + """ + return + + @abc.abstractmethod + def getUnit(self, param): + """ + Gets the unit of the specified param. + + Args: + param: the string name of the param + + Returns: + the string abbreviation of the unit of the param + """ + return + + @abc.abstractmethod + def getType(self, param): + """ + Gets the type of the param. + + Args: + param: the string name of the param + + Returns: + a string of the type of the parameter, such as + "STRING", "INT", "LONG", "FLOAT", or "DOUBLE" + """ + return + diff --git a/awips/qpidingest.py b/awips/qpidingest.py index f5aa83f..1b876c5 100644 --- a/awips/qpidingest.py +++ b/awips/qpidingest.py @@ -85,9 +85,9 @@ class IngestViaQPID: self.connection.start() self.session = self.connection.session(str(uuid4())) self.session.exchange_bind(exchange='amq.direct', queue='external.dropbox', binding_key='external.dropbox') - print 'Connected to Qpid' + print('Connected to Qpid') except: - print 'Unable to connect to Qpid' + print('Unable to connect to Qpid') def sendmessage(self, filepath, header): ''' @@ -108,4 +108,4 @@ class IngestViaQPID: there are no threads left open ''' self.session.close(timeout=10) - print 'Connection to Qpid closed' + print('Connection to Qpid closed') diff --git a/awips/qpidingest.py.bak b/awips/qpidingest.py.bak new file mode 100644 index 0000000..f5aa83f --- /dev/null +++ b/awips/qpidingest.py.bak @@ -0,0 +1,111 @@ +#=============================================================================== +# qpidingest.py +# +# @author: Aaron Anderson +# @organization: NOAA/WDTB OU/CIMMS +# @version: 1.0 02/19/2010 +# @requires: QPID Python Client available from http://qpid.apache.org/download.html +# The Python Client is located under Single Component Package/Client +# +# From the README.txt Installation Instructions +# = INSTALLATION = +# Extract the release archive into a directory of your choice and set +# your PYTHONPATH accordingly: +# +# tar -xzf qpid-python-.tar.gz -C +# export PYTHONPATH=/qpid-/python +# +# ***EDEX and QPID must be running for this module to work*** +# +# DESCRIPTION: +# This module is used to connect to QPID and send messages to the external.dropbox queue +# which tells EDEX to ingest a data file from a specified path. This avoids having to copy +# a data file into an endpoint. Each message also contains a header which is used to determine +# which plugin should be used to decode the file. Each plugin has an xml file located in +# $EDEX_HOME/data/utility/edex_static/base/distribution that contains regular expressions +# that the header is compared to. When the header matches one of these regular expressions +# the file is decoded with that plugin. If you make changes to one of these xml files you +# must restart EDEX for the changes to take effect. +# +# NOTE: If the message is being sent but you do not see it being ingested in the EDEX log +# check the xml files to make sure the header you are passing matches one of the regular +# expressions. Beware of spaces, some regular expressions require spaces while others use +# a wildcard character so a space is optional. It seems you are better off having the space +# as this will be matched to both patterns. For the file in the example below, +# 20100218_185755_SAUS46KLOX.metar, I use SAUS46 KLOX as the header to make sure it matches. +# +# +# EXAMPLE: +# Simple example program: +# +#------------------------------------------------------------------------------ +# import qpidingest +# #Tell EDEX to ingest a metar file from data_store. The filepath is +# #/data_store/20100218/metar/00/standard/20100218_005920_SAUS46KSEW.metar +# +# conn=qpidingest.IngestViaQPID() #defaults to localhost port 5672 +# +# #If EDEX is not on the local machine you can make the connection as follows +# #conn=qpidingest.IngestViaQPID(host='',port=) +# +# conn.sendmessage('/data_store/20100218/metar/18/standard/20100218_185755_SAUS46KLOX.metar','SAUS46 KLOX') +# conn.close() +#------------------------------------------------------------------------------- +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# .... +# 06/13/2013 DR 16242 D. Friedman Add Qpid authentication info +# 03/06/2014 DR 17907 D. Friedman Workaround for issue QPID-5569 +# +#=============================================================================== + +import qpid +from qpid.util import connect +from qpid.connection import Connection +from qpid.datatypes import Message, uuid4 + +QPID_USERNAME = 'guest' +QPID_PASSWORD = 'guest' + +class IngestViaQPID: + def __init__(self, host='localhost', port=5672): + ''' + Connect to QPID and make bindings to route message to external.dropbox queue + @param host: string hostname of computer running EDEX and QPID (default localhost) + @param port: integer port used to connect to QPID (default 5672) + ''' + + try: + # + self.socket = connect(host, port) + self.connection = Connection (sock=self.socket, username=QPID_USERNAME, password=QPID_PASSWORD) + self.connection.start() + self.session = self.connection.session(str(uuid4())) + self.session.exchange_bind(exchange='amq.direct', queue='external.dropbox', binding_key='external.dropbox') + print 'Connected to Qpid' + except: + print 'Unable to connect to Qpid' + + def sendmessage(self, filepath, header): + ''' + This function sends a message to the external.dropbox queue providing the path + to the file to be ingested and a header to determine the plugin to be used to + decode the file. + @param filepath: string full path to file to be ingested + @param header: string header used to determine plugin decoder to use + ''' + props = self.session.delivery_properties(routing_key='external.dropbox') + head = self.session.message_properties(application_headers={'header':header}, + user_id=QPID_USERNAME) # For issue QPID-5569. Fixed in Qpid 0.27 + self.session.message_transfer(destination='amq.direct', message=Message(props, head, filepath)) + + def close(self): + ''' + After all messages are sent call this function to close connection and make sure + there are no threads left open + ''' + self.session.close(timeout=10) + print 'Connection to Qpid closed' diff --git a/awips/stomp.py b/awips/stomp.py index d5f94ec..219c369 100644 --- a/awips/stomp.py +++ b/awips/stomp.py @@ -87,12 +87,13 @@ import random import re import socket import sys -import thread +import _thread import threading import time import types import xml.dom.minidom -from cStringIO import StringIO +from io import StringIO +from functools import reduce # # stomp.py version number @@ -106,14 +107,14 @@ def _uuid( *args ): (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/213761) """ - t = long( time.time() * 1000 ) - r = long( random.random() * 100000000000000000L ) + t = int( time.time() * 1000 ) + r = int( random.random() * 100000000000000000 ) try: a = socket.gethostbyname( socket.gethostname() ) except: # if we can't get a network address, just imagine one - a = random.random() * 100000000000000000L + a = random.random() * 100000000000000000 data = str(t) + ' ' + str(r) + ' ' + str(a) + ' ' + str(args) md5 = hashlib.md5() md5.update(data) @@ -126,7 +127,7 @@ class DevNullLogger(object): dummy logging class for environments without the logging module """ def log(self, msg): - print msg + print(msg) def devnull(self, msg): pass @@ -371,7 +372,7 @@ class Connection(object): """ self.__running = True self.__attempt_connection() - thread.start_new_thread(self.__receiver_loop, ()) + _thread.start_new_thread(self.__receiver_loop, ()) def stop(self): """ @@ -434,7 +435,7 @@ class Connection(object): def begin(self, headers={}, **keyword_headers): use_headers = self.__merge_headers([headers, keyword_headers]) - if not 'transaction' in use_headers.keys(): + if not 'transaction' in list(use_headers.keys()): use_headers['transaction'] = _uuid() self.__send_frame_helper('BEGIN', '', use_headers, [ 'transaction' ]) return use_headers['transaction'] @@ -446,7 +447,7 @@ class Connection(object): self.__send_frame_helper('COMMIT', '', self.__merge_headers([headers, keyword_headers]), [ 'transaction' ]) def connect(self, headers={}, **keyword_headers): - if keyword_headers.has_key('wait') and keyword_headers['wait']: + if 'wait' in keyword_headers and keyword_headers['wait']: while not self.is_connected(): time.sleep(0.1) del keyword_headers['wait'] self.__send_frame_helper('CONNECT', '', self.__merge_headers([self.__connect_headers, headers, keyword_headers]), [ ]) @@ -490,7 +491,7 @@ class Connection(object): """ headers = {} for header_map in header_map_list: - for header_key in header_map.keys(): + for header_key in list(header_map.keys()): headers[header_key] = header_map[header_key] return headers @@ -532,11 +533,11 @@ class Connection(object): if type(required_header_key) == tuple: found_alternative = False for alternative in required_header_key: - if alternative in headers.keys(): + if alternative in list(headers.keys()): found_alternative = True if not found_alternative: raise KeyError("Command %s requires one of the following headers: %s" % (command, str(required_header_key))) - elif not required_header_key in headers.keys(): + elif not required_header_key in list(headers.keys()): raise KeyError("Command %s requires header %r" % (command, required_header_key)) self.__send_frame(command, headers, payload) @@ -550,7 +551,7 @@ class Connection(object): if self.__socket is not None: frame = '%s\n%s\n%s\x00' % (command, - reduce(lambda accu, key: accu + ('%s:%s\n' % (key, headers[key])), headers.keys(), ''), + reduce(lambda accu, key: accu + ('%s:%s\n' % (key, headers[key])), list(headers.keys()), ''), payload) self.__socket.sendall(frame) log.debug("Sent frame: type=%s, headers=%r, body=%r" % (command, headers, payload)) @@ -707,7 +708,7 @@ class Connection(object): assert len(pair) == 2 entries[pair[0]] = pair[1] return entries - except Exception, ex: + except Exception as ex: # unable to parse message. return original return body @@ -762,7 +763,7 @@ class Connection(object): break except socket.error: self.__socket = None - if type(sys.exc_info()[1]) == types.TupleType: + if type(sys.exc_info()[1]) == tuple: exc = sys.exc_info()[1][1] else: exc = sys.exc_info()[1] @@ -813,20 +814,20 @@ if __name__ == '__main__': self.c.start() def __print_async(self, frame_type, headers, body): - print "\r \r", - print frame_type - for header_key in headers.keys(): - print '%s: %s' % (header_key, headers[header_key]) - print - print body - print '> ', + print("\r \r", end=' ') + print(frame_type) + for header_key in list(headers.keys()): + print('%s: %s' % (header_key, headers[header_key])) + print() + print(body) + print('> ', end=' ') sys.stdout.flush() def on_connecting(self, host_and_port): self.c.connect(wait=True) def on_disconnected(self): - print "lost connection" + print("lost connection") def on_message(self, headers, body): self.__print_async("MESSAGE", headers, body) @@ -850,13 +851,13 @@ if __name__ == '__main__': self.c.abort(transaction=args[1]) def begin(self, args): - print 'transaction id: %s' % self.c.begin() + print('transaction id: %s' % self.c.begin()) def commit(self, args): if len(args) < 2: - print 'expecting: commit ' + print('expecting: commit ') else: - print 'committing %s' % args[1] + print('committing %s' % args[1]) self.c.commit(transaction=args[1]) def disconnect(self, args): @@ -867,35 +868,35 @@ if __name__ == '__main__': def send(self, args): if len(args) < 3: - print 'expecting: send ' + print('expecting: send ') else: self.c.send(destination=args[1], message=' '.join(args[2:])) def sendtrans(self, args): if len(args) < 3: - print 'expecting: sendtrans ' + print('expecting: sendtrans ') else: self.c.send(destination=args[1], message="%s\n" % ' '.join(args[3:]), transaction=args[2]) def subscribe(self, args): if len(args) < 2: - print 'expecting: subscribe [ack]' + print('expecting: subscribe [ack]') elif len(args) > 2: - print 'subscribing to "%s" with acknowledge set to "%s"' % (args[1], args[2]) + print('subscribing to "%s" with acknowledge set to "%s"' % (args[1], args[2])) self.c.subscribe(destination=args[1], ack=args[2]) else: - print 'subscribing to "%s" with auto acknowledge' % args[1] + print('subscribing to "%s" with auto acknowledge' % args[1]) self.c.subscribe(destination=args[1], ack='auto') def unsubscribe(self, args): if len(args) < 2: - print 'expecting: unsubscribe ' + print('expecting: unsubscribe ') else: - print 'unsubscribing from "%s"' % args[1] + print('unsubscribing from "%s"' % args[1]) self.c.unsubscribe(destination=args[1]) if len(sys.argv) > 5: - print 'USAGE: stomp.py [host] [port] [user] [passcode]' + print('USAGE: stomp.py [host] [port] [user] [passcode]') sys.exit(1) if len(sys.argv) >= 2: @@ -917,7 +918,7 @@ if __name__ == '__main__': st = StompTester(host, port, user, passcode) try: while True: - line = raw_input("\r> ") + line = input("\r> ") if not line or line.lstrip().rstrip() == '': continue elif 'quit' in line or 'disconnect' in line: @@ -927,7 +928,7 @@ if __name__ == '__main__': if not command.startswith("on_") and hasattr(st, command): getattr(st, command)(split) else: - print 'unrecognized command' + print('unrecognized command') finally: st.disconnect(None) diff --git a/awips/stomp.py.bak b/awips/stomp.py.bak new file mode 100644 index 0000000..d5f94ec --- /dev/null +++ b/awips/stomp.py.bak @@ -0,0 +1,934 @@ +#!/usr/bin/env python +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +"""Stomp Protocol Connectivity + + This provides basic connectivity to a message broker supporting the 'stomp' protocol. + At the moment ACK, SEND, SUBSCRIBE, UNSUBSCRIBE, BEGIN, ABORT, COMMIT, CONNECT and DISCONNECT operations + are supported. + + This changes the previous version which required a listener per subscription -- now a listener object + just calls the 'addlistener' method and will receive all messages sent in response to all/any subscriptions. + (The reason for the change is that the handling of an 'ack' becomes problematic unless the listener mechanism + is decoupled from subscriptions). + + Note that you must 'start' an instance of Connection to begin receiving messages. For example: + + conn = stomp.Connection([('localhost', 62003)], 'myuser', 'mypass') + conn.start() + + Meta-Data + --------- + Author: Jason R Briggs + License: http://www.apache.org/licenses/LICENSE-2.0 + Start Date: 2005/12/01 + Last Revision Date: $Date: 2008/09/11 00:16 $ + + Notes/Attribution + ----------------- + * uuid method courtesy of Carl Free Jr: + http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/213761 + * patch from Andreas Schobel + * patches from Julian Scheid of Rising Sun Pictures (http://open.rsp.com.au) + * patch from Fernando + * patches from Eugene Strulyov + + Updates + ------- + * 2007/03/31 : (Andreas Schobel) patch to fix newlines problem in ActiveMQ 4.1 + * 2007/09 : (JRB) updated to get stomp.py working in Jython as well as Python + * 2007/09/05 : (Julian Scheid) patch to allow sending custom headers + * 2007/09/18 : (JRB) changed code to use logging instead of just print. added logger for jython to work + * 2007/09/18 : (Julian Scheid) various updates, including: + - change incoming message handling so that callbacks are invoked on the listener not only for MESSAGE, but also for + CONNECTED, RECEIPT and ERROR frames. + - callbacks now get not only the payload but any headers specified by the server + - all outgoing messages now sent via a single method + - only one connection used + - change to use thread instead of threading + - sends performed on the calling thread + - receiver loop now deals with multiple messages in one received chunk of data + - added reconnection attempts and connection fail-over + - changed defaults for "user" and "passcode" to None instead of empty string (fixed transmission of those values) + - added readline support + * 2008/03/26 : (Fernando) added cStringIO for faster performance on large messages + * 2008/09/10 : (Eugene) remove lower() on headers to support case-sensitive header names + * 2008/09/11 : (JRB) fix incompatibilities with RabbitMQ, add wait for socket-connect + * 2008/10/28 : (Eugene) add jms map (from stomp1.1 ideas) + * 2008/11/25 : (Eugene) remove superfluous (incorrect) locking code + * 2009/02/05 : (JRB) remove code to replace underscores with dashes in header names (causes a problem in rabbit-mq) + * 2009/03/29 : (JRB) minor change to add logging config file + (JRB) minor change to add socket timeout, suggested by Israel + * 2009/04/01 : (Gavin) patch to change md5 to hashlib (for 2.6 compatibility) + * 2009/04/02 : (Fernando Ciciliati) fix overflow bug when waiting too long to connect to the broker + +""" + +import hashlib +import math +import random +import re +import socket +import sys +import thread +import threading +import time +import types +import xml.dom.minidom +from cStringIO import StringIO + +# +# stomp.py version number +# +_version = 1.8 + + +def _uuid( *args ): + """ + uuid courtesy of Carl Free Jr: + (http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/213761) + """ + + t = long( time.time() * 1000 ) + r = long( random.random() * 100000000000000000L ) + + try: + a = socket.gethostbyname( socket.gethostname() ) + except: + # if we can't get a network address, just imagine one + a = random.random() * 100000000000000000L + data = str(t) + ' ' + str(r) + ' ' + str(a) + ' ' + str(args) + md5 = hashlib.md5() + md5.update(data) + data = md5.hexdigest() + return data + + +class DevNullLogger(object): + """ + dummy logging class for environments without the logging module + """ + def log(self, msg): + print msg + + def devnull(self, msg): + pass + + debug = devnull + info = devnull + warning = log + error = log + critical = log + exception = log + + def isEnabledFor(self, lvl): + return False + + +# +# add logging if available +# +try: + import logging + import logging.config + logging.config.fileConfig("stomp.log.conf") + log = logging.getLogger('root') +except: + log = DevNullLogger() + + +class ConnectionClosedException(Exception): + """ + Raised in the receiver thread when the connection has been closed + by the server. + """ + pass + + +class NotConnectedException(Exception): + """ + Raised by Connection.__send_frame when there is currently no server + connection. + """ + pass + + +class ConnectionListener(object): + """ + This class should be used as a base class for objects registered + using Connection.add_listener(). + """ + def on_connecting(self, host_and_port): + """ + Called by the STOMP connection once a TCP/IP connection to the + STOMP server has been established or re-established. Note that + at this point, no connection has been established on the STOMP + protocol level. For this, you need to invoke the "connect" + method on the connection. + + \param host_and_port a tuple containing the host name and port + number to which the connection has been established. + """ + pass + + def on_connected(self, headers, body): + """ + Called by the STOMP connection when a CONNECTED frame is + received, that is after a connection has been established or + re-established. + + \param headers a dictionary containing all headers sent by the + server as key/value pairs. + + \param body the frame's payload. This is usually empty for + CONNECTED frames. + """ + pass + + def on_disconnected(self): + """ + Called by the STOMP connection when a TCP/IP connection to the + STOMP server has been lost. No messages should be sent via + the connection until it has been reestablished. + """ + pass + + def on_message(self, headers, body): + """ + Called by the STOMP connection when a MESSAGE frame is + received. + + \param headers a dictionary containing all headers sent by the + server as key/value pairs. + + \param body the frame's payload - the message body. + """ + pass + + def on_receipt(self, headers, body): + """ + Called by the STOMP connection when a RECEIPT frame is + received, sent by the server if requested by the client using + the 'receipt' header. + + \param headers a dictionary containing all headers sent by the + server as key/value pairs. + + \param body the frame's payload. This is usually empty for + RECEIPT frames. + """ + pass + + def on_error(self, headers, body): + """ + Called by the STOMP connection when an ERROR frame is + received. + + \param headers a dictionary containing all headers sent by the + server as key/value pairs. + + \param body the frame's payload - usually a detailed error + description. + """ + pass + + +class Connection(object): + """ + Represents a STOMP client connection. + """ + + def __init__(self, + host_and_ports = [ ('localhost', 61613) ], + user = None, + passcode = None, + prefer_localhost = True, + try_loopback_connect = True, + reconnect_sleep_initial = 0.1, + reconnect_sleep_increase = 0.5, + reconnect_sleep_jitter = 0.1, + reconnect_sleep_max = 60.0): + """ + Initialize and start this connection. + + \param host_and_ports + a list of (host, port) tuples. + + \param prefer_localhost + if True and the local host is mentioned in the (host, + port) tuples, try to connect to this first + + \param try_loopback_connect + if True and the local host is found in the host + tuples, try connecting to it using loopback interface + (127.0.0.1) + + \param reconnect_sleep_initial + + initial delay in seconds to wait before reattempting + to establish a connection if connection to any of the + hosts fails. + + \param reconnect_sleep_increase + + factor by which the sleep delay is increased after + each connection attempt. For example, 0.5 means + to wait 50% longer than before the previous attempt, + 1.0 means wait twice as long, and 0.0 means keep + the delay constant. + + \param reconnect_sleep_max + + maximum delay between connection attempts, regardless + of the reconnect_sleep_increase. + + \param reconnect_sleep_jitter + + random additional time to wait (as a percentage of + the time determined using the previous parameters) + between connection attempts in order to avoid + stampeding. For example, a value of 0.1 means to wait + an extra 0%-10% (randomly determined) of the delay + calculated using the previous three parameters. + """ + + sorted_host_and_ports = [] + sorted_host_and_ports.extend(host_and_ports) + + # If localhost is preferred, make sure all (host, port) tuples + # that refer to the local host come first in the list + if prefer_localhost: + def is_local_host(host): + return host in Connection.__localhost_names + + sorted_host_and_ports.sort(lambda x, y: (int(is_local_host(y[0])) + - int(is_local_host(x[0])))) + + # If the user wishes to attempt connecting to local ports + # using the loopback interface, for each (host, port) tuple + # referring to a local host, add an entry with the host name + # replaced by 127.0.0.1 if it doesn't exist already + loopback_host_and_ports = [] + if try_loopback_connect: + for host_and_port in sorted_host_and_ports: + if is_local_host(host_and_port[0]): + port = host_and_port[1] + if (not ("127.0.0.1", port) in sorted_host_and_ports + and not ("localhost", port) in sorted_host_and_ports): + loopback_host_and_ports.append(("127.0.0.1", port)) + + # Assemble the final, possibly sorted list of (host, port) tuples + self.__host_and_ports = [] + self.__host_and_ports.extend(loopback_host_and_ports) + self.__host_and_ports.extend(sorted_host_and_ports) + + self.__recvbuf = '' + + self.__listeners = [ ] + + self.__reconnect_sleep_initial = reconnect_sleep_initial + self.__reconnect_sleep_increase = reconnect_sleep_increase + self.__reconnect_sleep_jitter = reconnect_sleep_jitter + self.__reconnect_sleep_max = reconnect_sleep_max + + self.__connect_headers = {} + if user is not None and passcode is not None: + self.__connect_headers['login'] = user + self.__connect_headers['passcode'] = passcode + + self.__socket = None + self.__current_host_and_port = None + + self.__receiver_thread_exit_condition = threading.Condition() + self.__receiver_thread_exited = False + + # + # Manage the connection + # + + def start(self): + """ + Start the connection. This should be called after all + listeners have been registered. If this method is not called, + no frames will be received by the connection. + """ + self.__running = True + self.__attempt_connection() + thread.start_new_thread(self.__receiver_loop, ()) + + def stop(self): + """ + Stop the connection. This is equivalent to calling + disconnect() but will do a clean shutdown by waiting for the + receiver thread to exit. + """ + self.disconnect() + + self.__receiver_thread_exit_condition.acquire() + if not self.__receiver_thread_exited: + self.__receiver_thread_exit_condition.wait() + self.__receiver_thread_exit_condition.release() + + def get_host_and_port(self): + """ + Return a (host, port) tuple indicating which STOMP host and + port is currently connected, or None if there is currently no + connection. + """ + return self.__current_host_and_port + + def is_connected(self): + try: + return self.__socket is not None and self.__socket.getsockname()[1] != 0 + except socket.error: + return False + + # + # Manage objects listening to incoming frames + # + + def add_listener(self, listener): + self.__listeners.append(listener) + + def remove_listener(self, listener): + self.__listeners.remove(listener) + + # + # STOMP transmissions + # + + def subscribe(self, headers={}, **keyword_headers): + self.__send_frame_helper('SUBSCRIBE', '', self.__merge_headers([headers, keyword_headers]), [ 'destination' ]) + + def unsubscribe(self, headers={}, **keyword_headers): + self.__send_frame_helper('UNSUBSCRIBE', '', self.__merge_headers([headers, keyword_headers]), [ ('destination', 'id') ]) + + def send(self, message='', headers={}, **keyword_headers): + if '\x00' in message: + content_length_headers = {'content-length': len(message)} + else: + content_length_headers = {} + self.__send_frame_helper('SEND', message, self.__merge_headers([headers, + keyword_headers, + content_length_headers]), [ 'destination' ]) + + def ack(self, headers={}, **keyword_headers): + self.__send_frame_helper('ACK', '', self.__merge_headers([headers, keyword_headers]), [ 'message-id' ]) + + def begin(self, headers={}, **keyword_headers): + use_headers = self.__merge_headers([headers, keyword_headers]) + if not 'transaction' in use_headers.keys(): + use_headers['transaction'] = _uuid() + self.__send_frame_helper('BEGIN', '', use_headers, [ 'transaction' ]) + return use_headers['transaction'] + + def abort(self, headers={}, **keyword_headers): + self.__send_frame_helper('ABORT', '', self.__merge_headers([headers, keyword_headers]), [ 'transaction' ]) + + def commit(self, headers={}, **keyword_headers): + self.__send_frame_helper('COMMIT', '', self.__merge_headers([headers, keyword_headers]), [ 'transaction' ]) + + def connect(self, headers={}, **keyword_headers): + if keyword_headers.has_key('wait') and keyword_headers['wait']: + while not self.is_connected(): time.sleep(0.1) + del keyword_headers['wait'] + self.__send_frame_helper('CONNECT', '', self.__merge_headers([self.__connect_headers, headers, keyword_headers]), [ ]) + + def disconnect(self, headers={}, **keyword_headers): + self.__send_frame_helper('DISCONNECT', '', self.__merge_headers([self.__connect_headers, headers, keyword_headers]), [ ]) + self.__running = False + if hasattr(socket, 'SHUT_RDWR'): + self.__socket.shutdown(socket.SHUT_RDWR) + if self.__socket: + self.__socket.close() + self.__current_host_and_port = None + + # ========= PRIVATE MEMBERS ========= + + + # List of all host names (unqualified, fully-qualified, and IP + # addresses) that refer to the local host (both loopback interface + # and external interfaces). This is used for determining + # preferred targets. + __localhost_names = [ "localhost", + "127.0.0.1", + socket.gethostbyname(socket.gethostname()), + socket.gethostname(), + socket.getfqdn(socket.gethostname()) ] + # + # Used to parse STOMP header lines in the format "key:value", + # + __header_line_re = re.compile('(?P[^:]+)[:](?P.*)') + + # + # Used to parse the STOMP "content-length" header lines, + # + __content_length_re = re.compile('^content-length[:]\\s*(?P[0-9]+)', re.MULTILINE) + + def __merge_headers(self, header_map_list): + """ + Helper function for combining multiple header maps into one. + + Any underscores ('_') in header names (keys) will be replaced by dashes ('-'). + """ + headers = {} + for header_map in header_map_list: + for header_key in header_map.keys(): + headers[header_key] = header_map[header_key] + return headers + + def __convert_dict(self, payload): + """ + Encode python dictionary as ... structure. + """ + + xmlStr = "\n" + for key in payload: + xmlStr += "\n" + xmlStr += "%s" % key + xmlStr += "%s" % payload[key] + xmlStr += "\n" + xmlStr += "" + + return xmlStr + + def __send_frame_helper(self, command, payload, headers, required_header_keys): + """ + Helper function for sending a frame after verifying that a + given set of headers are present. + + \param command the command to send + + \param payload the frame's payload + + \param headers a dictionary containing the frame's headers + + \param required_header_keys a sequence enumerating all + required header keys. If an element in this sequence is itself + a tuple, that tuple is taken as a list of alternatives, one of + which must be present. + + \throws ArgumentError if one of the required header keys is + not present in the header map. + """ + for required_header_key in required_header_keys: + if type(required_header_key) == tuple: + found_alternative = False + for alternative in required_header_key: + if alternative in headers.keys(): + found_alternative = True + if not found_alternative: + raise KeyError("Command %s requires one of the following headers: %s" % (command, str(required_header_key))) + elif not required_header_key in headers.keys(): + raise KeyError("Command %s requires header %r" % (command, required_header_key)) + self.__send_frame(command, headers, payload) + + def __send_frame(self, command, headers={}, payload=''): + """ + Send a STOMP frame. + """ + if type(payload) == dict: + headers["transformation"] = "jms-map-xml" + payload = self.__convert_dict(payload) + + if self.__socket is not None: + frame = '%s\n%s\n%s\x00' % (command, + reduce(lambda accu, key: accu + ('%s:%s\n' % (key, headers[key])), headers.keys(), ''), + payload) + self.__socket.sendall(frame) + log.debug("Sent frame: type=%s, headers=%r, body=%r" % (command, headers, payload)) + else: + raise NotConnectedException() + + def __receiver_loop(self): + """ + Main loop listening for incoming data. + """ + try: + try: + threading.currentThread().setName("StompReceiver") + while self.__running: + log.debug('starting receiver loop') + + if self.__socket is None: + break + + try: + try: + for listener in self.__listeners: + if hasattr(listener, 'on_connecting'): + listener.on_connecting(self.__current_host_and_port) + + while self.__running: + frames = self.__read() + + for frame in frames: + (frame_type, headers, body) = self.__parse_frame(frame) + log.debug("Received frame: result=%r, headers=%r, body=%r" % (frame_type, headers, body)) + frame_type = frame_type.lower() + if frame_type in [ 'connected', + 'message', + 'receipt', + 'error' ]: + for listener in self.__listeners: + if hasattr(listener, 'on_%s' % frame_type): + eval('listener.on_%s(headers, body)' % frame_type) + else: + log.debug('listener %s has no such method on_%s' % (listener, frame_type)) + else: + log.warning('Unknown response frame type: "%s" (frame length was %d)' % (frame_type, len(frame))) + finally: + try: + self.__socket.close() + except: + pass # ignore errors when attempting to close socket + self.__socket = None + self.__current_host_and_port = None + except ConnectionClosedException: + if self.__running: + log.error("Lost connection") + # Notify listeners + for listener in self.__listeners: + if hasattr(listener, 'on_disconnected'): + listener.on_disconnected() + # Clear out any half-received messages after losing connection + self.__recvbuf = '' + continue + else: + break + except: + log.exception("An unhandled exception was encountered in the stomp receiver loop") + + finally: + self.__receiver_thread_exit_condition.acquire() + self.__receiver_thread_exited = True + self.__receiver_thread_exit_condition.notifyAll() + self.__receiver_thread_exit_condition.release() + + def __read(self): + """ + Read the next frame(s) from the socket. + """ + fastbuf = StringIO() + while self.__running: + try: + c = self.__socket.recv(1024) + except: + c = '' + if len(c) == 0: + raise ConnectionClosedException + fastbuf.write(c) + if '\x00' in c: + break + self.__recvbuf += fastbuf.getvalue() + fastbuf.close() + result = [] + + if len(self.__recvbuf) > 0 and self.__running: + while True: + pos = self.__recvbuf.find('\x00') + if pos >= 0: + frame = self.__recvbuf[0:pos] + preamble_end = frame.find('\n\n') + if preamble_end >= 0: + content_length_match = Connection.__content_length_re.search(frame[0:preamble_end]) + if content_length_match: + content_length = int(content_length_match.group('value')) + content_offset = preamble_end + 2 + frame_size = content_offset + content_length + if frame_size > len(frame): + # Frame contains NUL bytes, need to + # read more + if frame_size < len(self.__recvbuf): + pos = frame_size + frame = self.__recvbuf[0:pos] + else: + # Haven't read enough data yet, + # exit loop and wait for more to + # arrive + break + result.append(frame) + self.__recvbuf = self.__recvbuf[pos+1:] + else: + break + return result + + + def __transform(self, body, transType): + """ + Perform body transformation. Currently, the only supported transformation is + 'jms-map-xml', which converts a map into python dictionary. This can be extended + to support other transformation types. + + The body has the following format: + + + name + Dejan + + + city + Belgrade + + + + (see http://docs.codehaus.org/display/STOMP/Stomp+v1.1+Ideas) + """ + + if transType != 'jms-map-xml': + return body + + try: + entries = {} + doc = xml.dom.minidom.parseString(body) + rootElem = doc.documentElement + for entryElem in rootElem.getElementsByTagName("entry"): + pair = [] + for node in entryElem.childNodes: + if not isinstance(node, xml.dom.minidom.Element): continue + pair.append(node.firstChild.nodeValue) + assert len(pair) == 2 + entries[pair[0]] = pair[1] + return entries + except Exception, ex: + # unable to parse message. return original + return body + + + def __parse_frame(self, frame): + """ + Parse a STOMP frame into a (frame_type, headers, body) tuple, + where frame_type is the frame type as a string (e.g. MESSAGE), + headers is a map containing all header key/value pairs, and + body is a string containing the frame's payload. + """ + preamble_end = frame.find('\n\n') + preamble = frame[0:preamble_end] + preamble_lines = preamble.split('\n') + body = frame[preamble_end+2:] + + # Skip any leading newlines + first_line = 0 + while first_line < len(preamble_lines) and len(preamble_lines[first_line]) == 0: + first_line += 1 + + # Extract frame type + frame_type = preamble_lines[first_line] + + # Put headers into a key/value map + headers = {} + for header_line in preamble_lines[first_line+1:]: + header_match = Connection.__header_line_re.match(header_line) + if header_match: + headers[header_match.group('key')] = header_match.group('value') + + if 'transformation' in headers: + body = self.__transform(body, headers['transformation']) + + return (frame_type, headers, body) + + def __attempt_connection(self): + """ + Try connecting to the (host, port) tuples specified at construction time. + """ + + sleep_exp = 1 + while self.__running and self.__socket is None: + for host_and_port in self.__host_and_ports: + try: + log.debug("Attempting connection to host %s, port %s" % host_and_port) + self.__socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + self.__socket.settimeout(None) + self.__socket.connect(host_and_port) + self.__current_host_and_port = host_and_port + log.info("Established connection to host %s, port %s" % host_and_port) + break + except socket.error: + self.__socket = None + if type(sys.exc_info()[1]) == types.TupleType: + exc = sys.exc_info()[1][1] + else: + exc = sys.exc_info()[1] + log.warning("Could not connect to host %s, port %s: %s" % (host_and_port[0], host_and_port[1], exc)) + + if self.__socket is None: + sleep_duration = (min(self.__reconnect_sleep_max, + ((self.__reconnect_sleep_initial / (1.0 + self.__reconnect_sleep_increase)) + * math.pow(1.0 + self.__reconnect_sleep_increase, sleep_exp))) + * (1.0 + random.random() * self.__reconnect_sleep_jitter)) + sleep_end = time.time() + sleep_duration + log.debug("Sleeping for %.1f seconds before attempting reconnect" % sleep_duration) + while self.__running and time.time() < sleep_end: + time.sleep(0.2) + + if sleep_duration < self.__reconnect_sleep_max: + sleep_exp += 1 + +# +# command line testing +# +if __name__ == '__main__': + + # If the readline module is available, make command input easier + try: + import readline + def stomp_completer(text, state): + commands = [ 'subscribe', 'unsubscribe', + 'send', 'ack', + 'begin', 'abort', 'commit', + 'connect', 'disconnect' + ] + for command in commands[state:]: + if command.startswith(text): + return "%s " % command + return None + + readline.parse_and_bind("tab: complete") + readline.set_completer(stomp_completer) + readline.set_completer_delims("") + except ImportError: + pass # ignore unavailable readline module + + class StompTester(object): + def __init__(self, host='localhost', port=61613, user='', passcode=''): + self.c = Connection([(host, port)], user, passcode) + self.c.add_listener(self) + self.c.start() + + def __print_async(self, frame_type, headers, body): + print "\r \r", + print frame_type + for header_key in headers.keys(): + print '%s: %s' % (header_key, headers[header_key]) + print + print body + print '> ', + sys.stdout.flush() + + def on_connecting(self, host_and_port): + self.c.connect(wait=True) + + def on_disconnected(self): + print "lost connection" + + def on_message(self, headers, body): + self.__print_async("MESSAGE", headers, body) + + def on_error(self, headers, body): + self.__print_async("ERROR", headers, body) + + def on_receipt(self, headers, body): + self.__print_async("RECEIPT", headers, body) + + def on_connected(self, headers, body): + self.__print_async("CONNECTED", headers, body) + + def ack(self, args): + if len(args) < 3: + self.c.ack(message_id=args[1]) + else: + self.c.ack(message_id=args[1], transaction=args[2]) + + def abort(self, args): + self.c.abort(transaction=args[1]) + + def begin(self, args): + print 'transaction id: %s' % self.c.begin() + + def commit(self, args): + if len(args) < 2: + print 'expecting: commit ' + else: + print 'committing %s' % args[1] + self.c.commit(transaction=args[1]) + + def disconnect(self, args): + try: + self.c.disconnect() + except NotConnectedException: + pass # ignore if no longer connected + + def send(self, args): + if len(args) < 3: + print 'expecting: send ' + else: + self.c.send(destination=args[1], message=' '.join(args[2:])) + + def sendtrans(self, args): + if len(args) < 3: + print 'expecting: sendtrans ' + else: + self.c.send(destination=args[1], message="%s\n" % ' '.join(args[3:]), transaction=args[2]) + + def subscribe(self, args): + if len(args) < 2: + print 'expecting: subscribe [ack]' + elif len(args) > 2: + print 'subscribing to "%s" with acknowledge set to "%s"' % (args[1], args[2]) + self.c.subscribe(destination=args[1], ack=args[2]) + else: + print 'subscribing to "%s" with auto acknowledge' % args[1] + self.c.subscribe(destination=args[1], ack='auto') + + def unsubscribe(self, args): + if len(args) < 2: + print 'expecting: unsubscribe ' + else: + print 'unsubscribing from "%s"' % args[1] + self.c.unsubscribe(destination=args[1]) + + if len(sys.argv) > 5: + print 'USAGE: stomp.py [host] [port] [user] [passcode]' + sys.exit(1) + + if len(sys.argv) >= 2: + host = sys.argv[1] + else: + host = "localhost" + if len(sys.argv) >= 3: + port = int(sys.argv[2]) + else: + port = 61613 + + if len(sys.argv) >= 5: + user = sys.argv[3] + passcode = sys.argv[4] + else: + user = None + passcode = None + + st = StompTester(host, port, user, passcode) + try: + while True: + line = raw_input("\r> ") + if not line or line.lstrip().rstrip() == '': + continue + elif 'quit' in line or 'disconnect' in line: + break + split = line.split() + command = split[0] + if not command.startswith("on_") and hasattr(st, command): + getattr(st, command)(split) + else: + print 'unrecognized command' + finally: + st.disconnect(None) + + diff --git a/awips/test/testQpidTimeToLive.py b/awips/test/testQpidTimeToLive.py index 7176324..a8de041 100644 --- a/awips/test/testQpidTimeToLive.py +++ b/awips/test/testQpidTimeToLive.py @@ -57,7 +57,7 @@ class ListenThread(threading.Thread): self.qs.topicSubscribe(self.topicName, self.receivedMessage) def receivedMessage(self, msg): - print "Received message" + print("Received message") self.nMessagesReceived += 1 if self.waitSecond == 0: fmsg = open('/tmp/rawMessage', 'w') @@ -66,20 +66,20 @@ class ListenThread(threading.Thread): while self.waitSecond < TIME_TO_SLEEP and not self.stopped: if self.waitSecond % 60 == 0: - print time.strftime('%H:%M:%S'), "Sleeping and stuck in not so infinite while loop" + print(time.strftime('%H:%M:%S'), "Sleeping and stuck in not so infinite while loop") self.waitSecond += 1 time.sleep(1) - print time.strftime('%H:%M:%S'), "Received", self.nMessagesReceived, "messages" + print(time.strftime('%H:%M:%S'), "Received", self.nMessagesReceived, "messages") def stop(self): - print "Stopping" + print("Stopping") self.stopped = True self.qs.close() def main(): - print "Starting up at", time.strftime('%H:%M:%S') + print("Starting up at", time.strftime('%H:%M:%S')) topic = 'edex.alerts' host = 'localhost' diff --git a/awips/test/testQpidTimeToLive.py.bak b/awips/test/testQpidTimeToLive.py.bak new file mode 100644 index 0000000..7176324 --- /dev/null +++ b/awips/test/testQpidTimeToLive.py.bak @@ -0,0 +1,99 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# +# +# +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 03/09/11 njensen Initial Creation. +# 08/15/13 2169 bkowal Decompress data read from the queue +# +# +# + +import time, sys +import threading + +import dynamicserialize + +TIME_TO_SLEEP = 300 + +class ListenThread(threading.Thread): + + def __init__(self, hostname, portNumber, topicName): + self.hostname = hostname + self.portNumber = portNumber + self.topicName = topicName + self.nMessagesReceived = 0 + self.waitSecond = 0 + self.stopped = False + threading.Thread.__init__(self) + + def run(self): + from awips import QpidSubscriber + self.qs = QpidSubscriber.QpidSubscriber(self.hostname, self.portNumber, True) + self.qs.topicSubscribe(self.topicName, self.receivedMessage) + + def receivedMessage(self, msg): + print "Received message" + self.nMessagesReceived += 1 + if self.waitSecond == 0: + fmsg = open('/tmp/rawMessage', 'w') + fmsg.write(msg) + fmsg.close() + + while self.waitSecond < TIME_TO_SLEEP and not self.stopped: + if self.waitSecond % 60 == 0: + print time.strftime('%H:%M:%S'), "Sleeping and stuck in not so infinite while loop" + self.waitSecond += 1 + time.sleep(1) + + print time.strftime('%H:%M:%S'), "Received", self.nMessagesReceived, "messages" + + def stop(self): + print "Stopping" + self.stopped = True + self.qs.close() + + +def main(): + print "Starting up at", time.strftime('%H:%M:%S') + + topic = 'edex.alerts' + host = 'localhost' + port = 5672 + + thread = ListenThread(host, port, topic) + try: + thread.start() + while True: + time.sleep(3) + except KeyboardInterrupt: + pass + finally: + thread.stop() + +if __name__ == '__main__': + main() diff --git a/docs/source/conf.py b/docs/source/conf.py index 190e4ae..b6702b0 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -56,16 +56,16 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'python-awips' -copyright = u'2016, Unidata' -author = u'Unidata' +project = 'python-awips' +copyright = '2016, Unidata' +author = 'Unidata' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = u'0.9.3' +version = '0.9.3' # The full version, including alpha/beta/rc tags. # The language for content autogenerated by Sphinx. Refer to documentation @@ -231,8 +231,8 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'python-awips.tex', u'python-awips Documentation', - u'Unidata', 'manual'), + (master_doc, 'python-awips.tex', 'python-awips Documentation', + 'Unidata', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -261,7 +261,7 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'python-awips', u'python-awips Documentation', + (master_doc, 'python-awips', 'python-awips Documentation', [author], 1) ] @@ -275,7 +275,7 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'python-awips', u'python-awips Documentation', + (master_doc, 'python-awips', 'python-awips Documentation', author, 'python-awips', 'One line description of project.', 'Miscellaneous'), ] diff --git a/docs/source/conf.py.bak b/docs/source/conf.py.bak new file mode 100644 index 0000000..190e4ae --- /dev/null +++ b/docs/source/conf.py.bak @@ -0,0 +1,303 @@ +# -*- coding: utf-8 -*- +# +# python-awips documentation build configuration file, created by +# sphinx-quickstart on Tue Mar 15 15:59:23 2016. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.insert(0, os.path.abspath('.')) +sys.path.insert(0, os.path.abspath('../..')) + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.intersphinx', + 'sphinx.ext.viewcode' +# 'notebook_gen_sphinxext' +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'python-awips' +copyright = u'2016, Unidata' +author = u'Unidata' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = u'0.9.3' +# The full version, including alpha/beta/rc tags. + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = [] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +#html_theme = 'alabaster' +html_theme = 'sphinx_rtd_theme' +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (relative to this directory) to use as a favicon of +# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' +#html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +#html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +#html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'python-awipsdoc' + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', + +# Latex figure (float) alignment +#'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'python-awips.tex', u'python-awips Documentation', + u'Unidata', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'python-awips', u'python-awips Documentation', + [author], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'python-awips', u'python-awips Documentation', + author, 'python-awips', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False + +# Set up mapping for other projects' docs +intersphinx_mapping = { + 'matplotlib': ('http://matplotlib.org/', None), + 'metpy': ('http://docs.scipy.org/doc/metpy/', None), + 'numpy': ('http://docs.scipy.org/doc/numpy/', None), + 'scipy': ('http://docs.scipy.org/doc/scipy/reference/', None), + 'pint': ('http://pint.readthedocs.org/en/stable/', None), + 'python': ('http://docs.python.org', None) + } diff --git a/dynamicserialize/DynamicSerializationManager.py b/dynamicserialize/DynamicSerializationManager.py index 60d8512..dbfd0bf 100644 --- a/dynamicserialize/DynamicSerializationManager.py +++ b/dynamicserialize/DynamicSerializationManager.py @@ -36,7 +36,7 @@ # from thrift.transport import TTransport -import SelfDescribingBinaryProtocol, ThriftSerializationContext +from . import SelfDescribingBinaryProtocol, ThriftSerializationContext class DynamicSerializationManager: diff --git a/dynamicserialize/DynamicSerializationManager.py.bak b/dynamicserialize/DynamicSerializationManager.py.bak new file mode 100644 index 0000000..60d8512 --- /dev/null +++ b/dynamicserialize/DynamicSerializationManager.py.bak @@ -0,0 +1,69 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + + +# +# A port of the Java DynamicSerializeManager. Should be used to read/write +# DynamicSerialize binary data. +# +# +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 06/09/10 njensen Initial Creation. +# +# +# + +from thrift.transport import TTransport +import SelfDescribingBinaryProtocol, ThriftSerializationContext + +class DynamicSerializationManager: + + def __init__(self): + self.transport = None + + def _deserialize(self, ctx): + return ctx.deserializeMessage() + + def deserializeBytes(self, bytes): + ctx = self._buildSerializationContext(bytes) + ctx.readMessageStart() + obj = self._deserialize(ctx) + ctx.readMessageEnd() + return obj + + def _buildSerializationContext(self, bytes=None): + self.transport = TTransport.TMemoryBuffer(bytes) + protocol = SelfDescribingBinaryProtocol.SelfDescribingBinaryProtocol(self.transport) + return ThriftSerializationContext.ThriftSerializationContext(self, protocol) + + def serializeObject(self, obj): + ctx = self._buildSerializationContext() + ctx.writeMessageStart("dynamicSerialize") + self._serialize(ctx, obj) + ctx.writeMessageEnd() + return self.transport.getvalue() + + def _serialize(self, ctx, obj): + ctx.serializeMessage(obj) \ No newline at end of file diff --git a/dynamicserialize/ThriftSerializationContext.py b/dynamicserialize/ThriftSerializationContext.py index 0ed39d2..ee8ebfa 100644 --- a/dynamicserialize/ThriftSerializationContext.py +++ b/dynamicserialize/ThriftSerializationContext.py @@ -44,13 +44,14 @@ from thrift.Thrift import TType import inspect, sys, types import dynamicserialize from dynamicserialize import dstypes, adapters -import SelfDescribingBinaryProtocol +from . import SelfDescribingBinaryProtocol import numpy +import collections dsObjTypes = {} def buildObjMap(module): - if module.__dict__.has_key('__all__'): + if '__all__' in module.__dict__: for i in module.__all__: name = module.__name__ + '.' + i __import__(name) @@ -65,17 +66,17 @@ def buildObjMap(module): buildObjMap(dstypes) pythonToThriftMap = { - types.StringType: TType.STRING, - types.IntType: TType.I32, - types.LongType: TType.I64, - types.ListType: TType.LIST, - types.DictionaryType: TType.MAP, + bytes: TType.STRING, + int: TType.I32, + int: TType.I64, + list: TType.LIST, + dict: TType.MAP, type(set([])): TType.SET, - types.FloatType: SelfDescribingBinaryProtocol.FLOAT, + float: SelfDescribingBinaryProtocol.FLOAT, #types.FloatType: TType.DOUBLE, - types.BooleanType: TType.BOOL, + bool: TType.BOOL, types.InstanceType: TType.STRUCT, - types.NoneType: TType.VOID, + type(None): TType.VOID, numpy.float32: SelfDescribingBinaryProtocol.FLOAT, numpy.int32: TType.I32, numpy.ndarray: TType.LIST, @@ -155,7 +156,7 @@ class ThriftSerializationContext(object): if name.isdigit(): obj = self._deserializeType(int(name)) return obj - elif adapters.classAdapterRegistry.has_key(name): + elif name in adapters.classAdapterRegistry: return adapters.classAdapterRegistry[name].deserialize(self) elif name.find('$') > -1: # it's an inner class, we're going to hope it's an enum, treat it special @@ -176,7 +177,7 @@ class ThriftSerializationContext(object): return obj def _deserializeType(self, b): - if self.typeDeserializationMethod.has_key(b): + if b in self.typeDeserializationMethod: return self.typeDeserializationMethod[b]() else: raise dynamicserialize.SerializationException("Unsupported type value " + str(b)) @@ -196,7 +197,7 @@ class ThriftSerializationContext(object): try: setMethod = getattr(obj, lookingFor) - if callable(setMethod): + if isinstance(setMethod, collections.Callable): setMethod(result) else: raise dynamicserialize.SerializationException("Couldn't find setter method " + lookingFor) @@ -213,7 +214,7 @@ class ThriftSerializationContext(object): if size: if listType not in primitiveSupport: m = self.typeDeserializationMethod[listType] - result = [m() for n in xrange(size)] + result = [m() for n in range(size)] else: result = self.listDeserializationMethod[listType](size) self.protocol.readListEnd() @@ -222,7 +223,7 @@ class ThriftSerializationContext(object): def _deserializeMap(self): keyType, valueType, size = self.protocol.readMapBegin() result = {} - for n in xrange(size): + for n in range(size): # can't go off the type, due to java generics limitations dynamic serialize is # serializing keys and values as void key = self.typeDeserializationMethod[TType.STRUCT]() @@ -234,14 +235,14 @@ class ThriftSerializationContext(object): def _deserializeSet(self): setType, setSize = self.protocol.readSetBegin() result = set([]) - for n in xrange(setSize): + for n in range(setSize): result.add(self.typeDeserializationMethod[TType.STRUCT]()) self.protocol.readSetEnd() return result def _lookupType(self, obj): pyt = type(obj) - if pythonToThriftMap.has_key(pyt): + if pyt in pythonToThriftMap: return pythonToThriftMap[pyt] elif pyt.__module__.startswith('dynamicserialize.dstypes'): return pythonToThriftMap[types.InstanceType] @@ -253,7 +254,7 @@ class ThriftSerializationContext(object): if tt == TType.STRUCT: fqn = obj.__module__.replace('dynamicserialize.dstypes.', '') - if adapters.classAdapterRegistry.has_key(fqn): + if fqn in adapters.classAdapterRegistry: # get proper class name when writing class name to serialization stream # in case we have a special inner-class case m = sys.modules[adapters.classAdapterRegistry[fqn].__name__] @@ -293,7 +294,7 @@ class ThriftSerializationContext(object): self.protocol.writeFieldEnd() def _serializeType(self, fieldValue, fieldType): - if self.typeSerializationMethod.has_key(fieldType): + if fieldType in self.typeSerializationMethod: return self.typeSerializationMethod[fieldType](fieldValue) else: raise dynamicserialize.SerializationException("Unsupported type value " + str(fieldType)) @@ -335,7 +336,7 @@ class ThriftSerializationContext(object): def _serializeMap(self, obj): size = len(obj) self.protocol.writeMapBegin(TType.VOID, TType.VOID, size) - for k in obj.keys(): + for k in list(obj.keys()): self.typeSerializationMethod[TType.STRUCT](k) self.typeSerializationMethod[TType.STRUCT](obj[k]) self.protocol.writeMapEnd() diff --git a/dynamicserialize/ThriftSerializationContext.py.bak b/dynamicserialize/ThriftSerializationContext.py.bak new file mode 100644 index 0000000..0ed39d2 --- /dev/null +++ b/dynamicserialize/ThriftSerializationContext.py.bak @@ -0,0 +1,420 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + + +# +# A port of the Java ThriftSerializationContext, used for reading/writing +# DynamicSerialize objects to/from thrift. +# +# For serialization, it has no knowledge of the expected types in other +# languages, it is instead all based on inspecting the types of the objects +# passed to it. Therefore, ensure the types of python objects and primitives +# match what they should be in the destination language. +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 06/09/10 njensen Initial Creation. +# 06/12/13 #2099 dgilling Implement readObject() and +# writeObject(). +# Apr 24, 2015 4425 nabowle Add Double support +# +# + +from thrift.Thrift import TType +import inspect, sys, types +import dynamicserialize +from dynamicserialize import dstypes, adapters +import SelfDescribingBinaryProtocol +import numpy + +dsObjTypes = {} + +def buildObjMap(module): + if module.__dict__.has_key('__all__'): + for i in module.__all__: + name = module.__name__ + '.' + i + __import__(name) + buildObjMap(sys.modules[name]) + else: + clzName = module.__name__[module.__name__.rfind('.') + 1:] + clz = module.__dict__[clzName] + tname = module.__name__ + tname = tname.replace('dynamicserialize.dstypes.', '') + dsObjTypes[tname] = clz + +buildObjMap(dstypes) + +pythonToThriftMap = { + types.StringType: TType.STRING, + types.IntType: TType.I32, + types.LongType: TType.I64, + types.ListType: TType.LIST, + types.DictionaryType: TType.MAP, + type(set([])): TType.SET, + types.FloatType: SelfDescribingBinaryProtocol.FLOAT, + #types.FloatType: TType.DOUBLE, + types.BooleanType: TType.BOOL, + types.InstanceType: TType.STRUCT, + types.NoneType: TType.VOID, + numpy.float32: SelfDescribingBinaryProtocol.FLOAT, + numpy.int32: TType.I32, + numpy.ndarray: TType.LIST, + numpy.object_: TType.STRING, # making an assumption here + numpy.string_: TType.STRING, + numpy.float64: TType.DOUBLE, + numpy.int16: TType.I16, + numpy.int8: TType.BYTE, + numpy.int64: TType.I64 +} + +primitiveSupport = (TType.BYTE, TType.I16, TType.I32, TType.I64, SelfDescribingBinaryProtocol.FLOAT, TType.DOUBLE) + +class ThriftSerializationContext(object): + + def __init__(self, serializationManager, selfDescribingBinaryProtocol): + self.serializationManager = serializationManager + self.protocol = selfDescribingBinaryProtocol + self.typeDeserializationMethod = { + TType.STRING: self.protocol.readString, + TType.I16: self.protocol.readI16, + TType.I32: self.protocol.readI32, + TType.LIST: self._deserializeArray, + TType.MAP: self._deserializeMap, + TType.SET: self._deserializeSet, + SelfDescribingBinaryProtocol.FLOAT: self.protocol.readFloat, + TType.BYTE: self.protocol.readByte, + TType.I64: self.protocol.readI64, + TType.DOUBLE: self.protocol.readDouble, + TType.BOOL: self.protocol.readBool, + TType.STRUCT: self.deserializeMessage, + TType.VOID: lambda: None + } + self.typeSerializationMethod = { + TType.STRING: self.protocol.writeString, + TType.I16: self.protocol.writeI16, + TType.I32: self.protocol.writeI32, + TType.LIST: self._serializeArray, + TType.MAP: self._serializeMap, + TType.SET: self._serializeSet, + SelfDescribingBinaryProtocol.FLOAT: self.protocol.writeFloat, + TType.BYTE: self.protocol.writeByte, + TType.I64: self.protocol.writeI64, + TType.DOUBLE: self.protocol.writeDouble, + TType.BOOL: self.protocol.writeBool, + TType.STRUCT: self.serializeMessage, + TType.VOID: lambda x: None + } + self.listDeserializationMethod = { + TType.BYTE: self.protocol.readI8List, + TType.I16: self.protocol.readI16List, + TType.I32: self.protocol.readI32List, + TType.I64: self.protocol.readI64List, + SelfDescribingBinaryProtocol.FLOAT: self.protocol.readF32List, + TType.DOUBLE: self.protocol.readF64List + } + self.listSerializationMethod = { + TType.BYTE: self.protocol.writeI8List, + TType.I16: self.protocol.writeI16List, + TType.I32: self.protocol.writeI32List, + TType.I64: self.protocol.writeI64List, + SelfDescribingBinaryProtocol.FLOAT: self.protocol.writeF32List, + TType.DOUBLE: self.protocol.writeF64List + } + + + def readMessageStart(self): + msg = self.protocol.readMessageBegin() + return msg[0] + + def readMessageEnd(self): + self.protocol.readMessageEnd() + + def deserializeMessage(self): + name = self.protocol.readStructBegin() + name = name.replace('_', '.') + if name.isdigit(): + obj = self._deserializeType(int(name)) + return obj + elif adapters.classAdapterRegistry.has_key(name): + return adapters.classAdapterRegistry[name].deserialize(self) + elif name.find('$') > -1: + # it's an inner class, we're going to hope it's an enum, treat it special + fieldName, fieldType, fieldId = self.protocol.readFieldBegin() + if fieldName != '__enumValue__': + raise dynamiceserialize.SerializationException("Expected to find enum payload. Found: " + fieldName) + obj = self.protocol.readString() + self.protocol.readFieldEnd() + return obj + else: + clz = dsObjTypes[name] + obj = clz() + + while self._deserializeField(name, obj): + pass + + self.protocol.readStructEnd() + return obj + + def _deserializeType(self, b): + if self.typeDeserializationMethod.has_key(b): + return self.typeDeserializationMethod[b]() + else: + raise dynamicserialize.SerializationException("Unsupported type value " + str(b)) + + + def _deserializeField(self, structname, obj): + fieldName, fieldType, fieldId = self.protocol.readFieldBegin() + if fieldType == TType.STOP: + return False + elif fieldType != TType.VOID: +# if adapters.fieldAdapterRegistry.has_key(structname) and adapters.fieldAdapterRegistry[structname].has_key(fieldName): +# result = adapters.fieldAdapterRegistry[structname][fieldName].deserialize(self) +# else: + result = self._deserializeType(fieldType) + lookingFor = "set" + fieldName[0].upper() + fieldName[1:] + + try: + setMethod = getattr(obj, lookingFor) + + if callable(setMethod): + setMethod(result) + else: + raise dynamicserialize.SerializationException("Couldn't find setter method " + lookingFor) + except: + raise dynamicserialize.SerializationException("Couldn't find setter method " + lookingFor) + + self.protocol.readFieldEnd() + return True + + + def _deserializeArray(self): + listType, size = self.protocol.readListBegin() + result = [] + if size: + if listType not in primitiveSupport: + m = self.typeDeserializationMethod[listType] + result = [m() for n in xrange(size)] + else: + result = self.listDeserializationMethod[listType](size) + self.protocol.readListEnd() + return result + + def _deserializeMap(self): + keyType, valueType, size = self.protocol.readMapBegin() + result = {} + for n in xrange(size): + # can't go off the type, due to java generics limitations dynamic serialize is + # serializing keys and values as void + key = self.typeDeserializationMethod[TType.STRUCT]() + value = self.typeDeserializationMethod[TType.STRUCT]() + result[key] = value + self.protocol.readMapEnd() + return result + + def _deserializeSet(self): + setType, setSize = self.protocol.readSetBegin() + result = set([]) + for n in xrange(setSize): + result.add(self.typeDeserializationMethod[TType.STRUCT]()) + self.protocol.readSetEnd() + return result + + def _lookupType(self, obj): + pyt = type(obj) + if pythonToThriftMap.has_key(pyt): + return pythonToThriftMap[pyt] + elif pyt.__module__.startswith('dynamicserialize.dstypes'): + return pythonToThriftMap[types.InstanceType] + else: + raise dynamicserialize.SerializationException("Don't know how to serialize object of type: " + str(pyt)) + + def serializeMessage(self, obj): + tt = self._lookupType(obj) + + if tt == TType.STRUCT: + fqn = obj.__module__.replace('dynamicserialize.dstypes.', '') + if adapters.classAdapterRegistry.has_key(fqn): + # get proper class name when writing class name to serialization stream + # in case we have a special inner-class case + m = sys.modules[adapters.classAdapterRegistry[fqn].__name__] + if isinstance(m.ClassAdapter, list): + fqn = m.ClassAdapter[0] + self.protocol.writeStructBegin(fqn) + adapters.classAdapterRegistry[fqn].serialize(self, obj) + return + else: + self.protocol.writeStructBegin(fqn) + methods = inspect.getmembers(obj, inspect.ismethod) + fid = 1 + for m in methods: + methodName = m[0] + if methodName.startswith('get'): + fieldname = methodName[3].lower() + methodName[4:] + val = m[1]() + ft = self._lookupType(val) + if ft == TType.STRUCT: + fc = val.__module__.replace('dynamicserialize.dstypes.', '') + self._serializeField(fieldname, ft, fid, val) + else: + self._serializeField(fieldname, ft, fid, val) + fid += 1 + self.protocol.writeFieldStop() + + self.protocol.writeStructEnd() + else: + # basic types + self.protocol.writeStructBegin(str(tt)) + self._serializeType(obj, tt) + self.protocol.writeStructEnd() + + def _serializeField(self, fieldName, fieldType, fieldId, fieldValue): + self.protocol.writeFieldBegin(fieldName, fieldType, fieldId) + self._serializeType(fieldValue, fieldType) + self.protocol.writeFieldEnd() + + def _serializeType(self, fieldValue, fieldType): + if self.typeSerializationMethod.has_key(fieldType): + return self.typeSerializationMethod[fieldType](fieldValue) + else: + raise dynamicserialize.SerializationException("Unsupported type value " + str(fieldType)) + + def _serializeArray(self, obj): + size = len(obj) + if size: + if type(obj) is numpy.ndarray: + t = pythonToThriftMap[obj.dtype.type] + size = obj.size + else: + t = self._lookupType(obj[0]) + else: + t = TType.STRUCT + self.protocol.writeListBegin(t, size) + if t == TType.STRING: + if type(obj) is numpy.ndarray: + if len(obj.shape) == 1: + for x in obj: + s = str(x).strip() + self.typeSerializationMethod[t](s) + else: + for x in obj: + for y in x: + s = str(y).strip() + self.typeSerializationMethod[t](s) + else: + for x in obj: + s = str(x) + self.typeSerializationMethod[t](s) + elif t not in primitiveSupport: + for x in obj: + self.typeSerializationMethod[t](x) + else: + self.listSerializationMethod[t](obj) + self.protocol.writeListEnd() + + + def _serializeMap(self, obj): + size = len(obj) + self.protocol.writeMapBegin(TType.VOID, TType.VOID, size) + for k in obj.keys(): + self.typeSerializationMethod[TType.STRUCT](k) + self.typeSerializationMethod[TType.STRUCT](obj[k]) + self.protocol.writeMapEnd() + + def _serializeSet(self, obj): + size = len(obj) + self.protocol.writeSetBegin(TType.VOID, size) + for x in obj: + self.typeSerializationMethod[TType.STRUCT](x) + self.protocol.writeSetEnd() + + def writeMessageStart(self, name): + self.protocol.writeMessageBegin(name, TType.VOID, 0) + + def writeMessageEnd(self): + self.protocol.writeMessageEnd() + + def readBool(self): + return self.protocol.readBool() + + def writeBool(self, b): + self.protocol.writeBool(b) + + def readByte(self): + return self.protocol.readByte() + + def writeByte(self, b): + self.protocol.writeByte(b) + + def readDouble(self): + return self.protocol.readDouble() + + def writeDouble(self, d): + self.protocol.writeDouble(d) + + def readFloat(self): + return self.protocol.readFloat() + + def writeFloat(self, f): + self.protocol.writeFloat(f) + + def readI16(self): + return self.protocol.readI16() + + def writeI16(self, i): + self.protocol.writeI16(i) + + def readI32(self): + return self.protocol.readI32() + + def writeI32(self, i): + self.protocol.writeI32(i) + + def readI64(self): + return self.protocol.readI64() + + def writeI64(self, i): + self.protocol.writeI64(i) + + def readString(self): + return self.protocol.readString() + + def writeString(self, s): + self.protocol.writeString(s) + + def readBinary(self): + numBytes = self.protocol.readI32() + return self.protocol.readI8List(numBytes) + + def readFloatArray(self): + size = self.protocol.readI32() + return self.protocol.readF32List(size) + + def writeFloatArray(self, floats): + self.protocol.writeI32(len(floats)) + self.protocol.writeF32List(floats) + + def readObject(self): + return self.deserializeMessage() + + def writeObject(self, obj): + self.serializeMessage(obj) diff --git a/dynamicserialize/__init__.py b/dynamicserialize/__init__.py index c7a94fd..ac73ed7 100644 --- a/dynamicserialize/__init__.py +++ b/dynamicserialize/__init__.py @@ -35,8 +35,8 @@ __all__ = [ ] -import dstypes, adapters -import DynamicSerializationManager +from . import dstypes, adapters +from . import DynamicSerializationManager class SerializationException(Exception): diff --git a/dynamicserialize/__init__.py.bak b/dynamicserialize/__init__.py.bak new file mode 100644 index 0000000..c7a94fd --- /dev/null +++ b/dynamicserialize/__init__.py.bak @@ -0,0 +1,58 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + + +# +# TODO +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 08/20/10 njensen Initial Creation. +# +# +# + +__all__ = [ + ] + +import dstypes, adapters +import DynamicSerializationManager + +class SerializationException(Exception): + + def __init__(self, message=None): + self.message = message + + def __str__(self): + if self.message: + return self.message + else: + return "" + +def serialize(obj): + dsm = DynamicSerializationManager.DynamicSerializationManager() + return dsm.serializeObject(obj) + +def deserialize(bytes): + dsm = DynamicSerializationManager.DynamicSerializationManager() + return dsm.deserializeBytes(bytes) \ No newline at end of file diff --git a/dynamicserialize/adapters/EnumSetAdapter.py b/dynamicserialize/adapters/EnumSetAdapter.py index 9603401..c813f5b 100644 --- a/dynamicserialize/adapters/EnumSetAdapter.py +++ b/dynamicserialize/adapters/EnumSetAdapter.py @@ -52,6 +52,6 @@ def deserialize(context): setSize = context.readI32() enumClassName = context.readString() valList = [] - for i in xrange(setSize): + for i in range(setSize): valList.append(context.readString()) return EnumSet(enumClassName, valList) diff --git a/dynamicserialize/adapters/EnumSetAdapter.py.bak b/dynamicserialize/adapters/EnumSetAdapter.py.bak new file mode 100644 index 0000000..9603401 --- /dev/null +++ b/dynamicserialize/adapters/EnumSetAdapter.py.bak @@ -0,0 +1,57 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + + +# +# Adapter for java.util.EnumSet +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 07/28/11 dgilling Initial Creation. +# 12/02/13 2537 bsteffen Serialize empty enum sets. +# +# +# + + + +from dynamicserialize.dstypes.java.util import EnumSet + +ClassAdapter = ['java.util.EnumSet', 'java.util.RegularEnumSet'] + + +def serialize(context, set): + setSize = len(set) + context.writeI32(setSize) + context.writeString(set.getEnumClass()) + for val in set: + context.writeString(val) + + +def deserialize(context): + setSize = context.readI32() + enumClassName = context.readString() + valList = [] + for i in xrange(setSize): + valList.append(context.readString()) + return EnumSet(enumClassName, valList) diff --git a/dynamicserialize/adapters/LockTableAdapter.py b/dynamicserialize/adapters/LockTableAdapter.py index 254b275..d88b103 100644 --- a/dynamicserialize/adapters/LockTableAdapter.py +++ b/dynamicserialize/adapters/LockTableAdapter.py @@ -45,7 +45,7 @@ def serialize(context, lockTable): for lock in locks: wsIdString = lock.getWsId().toString() - if wsIds.has_key(wsIdString): + if wsIdString in wsIds: lockWsIdIndex.append(wsIds[wsIdString]) else: lockWsIdIndex.append(index) @@ -68,12 +68,12 @@ def deserialize(context): parmId = context.readObject() numWsIds = context.readI32() wsIds = [] - for x in xrange(numWsIds): + for x in range(numWsIds): wsIds.append(context.readObject()) numLocks = context.readI32() locks = [] - for x in xrange(numLocks): + for x in range(numLocks): startTime = context.readI64() endTime = context.readI64() wsId = wsIds[context.readI32()] diff --git a/dynamicserialize/adapters/LockTableAdapter.py.bak b/dynamicserialize/adapters/LockTableAdapter.py.bak new file mode 100644 index 0000000..254b275 --- /dev/null +++ b/dynamicserialize/adapters/LockTableAdapter.py.bak @@ -0,0 +1,88 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# +# Adapter for com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 04/22/13 rjpeter Initial Creation. +# 06/12/13 #2099 dgilling Use new Lock constructor. +# +# + +from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.lock import LockTable +from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.lock import Lock + +ClassAdapter = 'com.raytheon.uf.common.dataplugin.gfe.server.lock.LockTable' + +def serialize(context, lockTable): + index=0 + wsIds = {lockTable.getWsId().toString() : index} + index += 1 + locks = lockTable.getLocks() + lockWsIdIndex = [] + for lock in locks: + wsIdString = lock.getWsId().toString() + + if wsIds.has_key(wsIdString): + lockWsIdIndex.append(wsIds[wsIdString]) + else: + lockWsIdIndex.append(index) + wsIds[wsIdString] = index + index += 1 + + context.writeObject(lockTable.getParmId()) + + context.writeI32(index) + for wsId in sorted(wsIds, key=wsIds.get): + context.writeObject(wsId) + + context.writeI32(len(locks)) + for lock, wsIndex in zip(locks, lockWsIdIndex): + serializer.writeI64(lock.getStartTime()) + serializer.writeI64(lock.getEndTime()) + serializer.writeI32(wsIndex) + +def deserialize(context): + parmId = context.readObject() + numWsIds = context.readI32() + wsIds = [] + for x in xrange(numWsIds): + wsIds.append(context.readObject()) + + numLocks = context.readI32() + locks = [] + for x in xrange(numLocks): + startTime = context.readI64() + endTime = context.readI64() + wsId = wsIds[context.readI32()] + lock = Lock(parmId, wsId, startTime, endTime) + locks.append(lock) + + lockTable = LockTable() + lockTable.setParmId(parmId) + lockTable.setWsId(wsIds[0]) + lockTable.setLocks(locks) + + return lockTable \ No newline at end of file diff --git a/dynamicserialize/adapters/WsIdAdapter.py b/dynamicserialize/adapters/WsIdAdapter.py index 9cb0153..ceb34b7 100644 --- a/dynamicserialize/adapters/WsIdAdapter.py +++ b/dynamicserialize/adapters/WsIdAdapter.py @@ -52,7 +52,7 @@ def deserialize(context): wsId.setUserName(wsIdParts[1]) wsId.setProgName(wsIdParts[2]) wsId.setPid(wsIdParts[3]) - wsId.setThreadId(long(wsIdParts[4])) + wsId.setThreadId(int(wsIdParts[4])) return wsId diff --git a/dynamicserialize/adapters/WsIdAdapter.py.bak b/dynamicserialize/adapters/WsIdAdapter.py.bak new file mode 100644 index 0000000..9cb0153 --- /dev/null +++ b/dynamicserialize/adapters/WsIdAdapter.py.bak @@ -0,0 +1,58 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + + +# +# Adapter for com.raytheon.uf.common.message.WsId +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 09/16/10 dgilling Initial Creation. +# 04/25/12 545 randerso Repurposed the lockKey field as threadId +# +# +# + + + +from dynamicserialize.dstypes.com.raytheon.uf.common.message import WsId + +ClassAdapter = 'com.raytheon.uf.common.message.WsId' + + +def serialize(context, wsId): + context.writeString(wsId.toString()) + +def deserialize(context): + wsIdString = context.readString() + wsIdParts = wsIdString.split(":", 5) + + wsId = WsId() + wsId.setNetworkId(wsIdParts[0]) + wsId.setUserName(wsIdParts[1]) + wsId.setProgName(wsIdParts[2]) + wsId.setPid(wsIdParts[3]) + wsId.setThreadId(long(wsIdParts[4])) + + return wsId + diff --git a/dynamicserialize/adapters/__init__.py b/dynamicserialize/adapters/__init__.py index 26cbdcd..24db1bc 100644 --- a/dynamicserialize/adapters/__init__.py +++ b/dynamicserialize/adapters/__init__.py @@ -66,10 +66,10 @@ classAdapterRegistry = {} def getAdapterRegistry(): import sys for x in __all__: - exec 'import ' + x + exec('import ' + x) m = sys.modules['dynamicserialize.adapters.' + x] d = m.__dict__ - if d.has_key('ClassAdapter'): + if 'ClassAdapter' in d: if isinstance(m.ClassAdapter, list): for clz in m.ClassAdapter: classAdapterRegistry[clz] = m diff --git a/dynamicserialize/adapters/__init__.py.bak b/dynamicserialize/adapters/__init__.py.bak new file mode 100644 index 0000000..26cbdcd --- /dev/null +++ b/dynamicserialize/adapters/__init__.py.bak @@ -0,0 +1,85 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + + +# +# __init__.py for Dynamic Serialize adapters. +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 08/31/10 njensen Initial Creation. +# 03/20/13 #1774 randerso Added TimeConstraintsAdapter +# 04/22/13 #1949 rjpeter Added LockTableAdapter +# 02/06/14 #2672 bsteffen Added JTSEnvelopeAdapter +# 06/22/2015 #4573 randerso Added JobProgressAdapter +# +# + +__all__ = [ + 'PointAdapter', + 'StackTraceElementAdapter', + 'WsIdAdapter', + 'CalendarAdapter', + 'GregorianCalendarAdapter', + 'ActiveTableModeAdapter', + 'DateAdapter', + 'LocalizationLevelSerializationAdapter', + 'LocalizationTypeSerializationAdapter', + 'GeometryTypeAdapter', + 'CoordAdapter', + 'TimeRangeTypeAdapter', + 'ParmIDAdapter', + 'DatabaseIDAdapter', + 'TimestampAdapter', + 'EnumSetAdapter', + 'FloatBufferAdapter', + 'ByteBufferAdapter', + 'TimeConstraintsAdapter', + 'LockTableAdapter', + 'JTSEnvelopeAdapter', + 'JobProgressAdapter', + ] + +classAdapterRegistry = {} + + +def getAdapterRegistry(): + import sys + for x in __all__: + exec 'import ' + x + m = sys.modules['dynamicserialize.adapters.' + x] + d = m.__dict__ + if d.has_key('ClassAdapter'): + if isinstance(m.ClassAdapter, list): + for clz in m.ClassAdapter: + classAdapterRegistry[clz] = m + else: + clzName = m.ClassAdapter + classAdapterRegistry[clzName] = m + else: + raise LookupError('Adapter class ' + x + ' has no ClassAdapter field ' + \ + 'and cannot be registered.') + + +getAdapterRegistry() + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/ActiveTableRecord.py b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/ActiveTableRecord.py index 25c19fc..d201ccb 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/ActiveTableRecord.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/ActiveTableRecord.py @@ -26,12 +26,10 @@ # ## -import ActiveTableKey +from . import ActiveTableKey import abc -class ActiveTableRecord(object): - __metaclass__ = abc.ABCMeta - +class ActiveTableRecord(object, metaclass=abc.ABCMeta): @abc.abstractmethod def __init__(self): self.key = ActiveTableKey.ActiveTableKey() diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/ActiveTableRecord.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/ActiveTableRecord.py.bak new file mode 100644 index 0000000..25c19fc --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/ActiveTableRecord.py.bak @@ -0,0 +1,291 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 05/22/2015 4522 randerso Initial creation (hand generated) +# +## + +import ActiveTableKey +import abc + +class ActiveTableRecord(object): + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def __init__(self): + self.key = ActiveTableKey.ActiveTableKey() + self.wmoid = None + self.pil = None + self.xxxid = None + self.countyheader = None + self.vtecstr = None + self.productClass = None + self.act = None + self.startTime = None + self.endTime = None + self.issueTime = None + self.purgeTime = None + self.ufn = None + self.geometry = None + self.forecaster = None + self.motdir = None + self.motspd = None + self.loc = None + self.rawmessage = None + self.seg = None + self.phensig = None + self.region = None + self.overviewText = None + self.segText = None + self.locationID = None + self.floodSeverity = None + self.immediateCause = None + self.floodRecordStatus = None + self.floodBegin = None + self.floodCrest = None + self.floodEnd = None + self.identifier = None + + def getKey(self): + return self.key + + def setKey(self, key): + self.key = key + + def getWmoid(self): + return self.wmoid + + def setWmoid(self, wmoid): + self.wmoid = wmoid + + def getPil(self): + return self.pil + + def setPil(self, pil): + self.pil = pil + + def getXxxid(self): + return self.xxxid + + def setXxxid(self, xxxid): + self.xxxid = xxxid + + def getCountyheader(self): + return self.countyheader + + def setCountyheader(self, countyheader): + self.countyheader = countyheader + + def getUgcZone(self): + return self.key.getUgcZone() + + def setUgcZone(self, ugcZone): + self.key.setUgcZone(ugcZone) + + def getVtecstr(self): + return self.vtecstr + + def setVtecstr(self, vtecstr): + self.vtecstr = vtecstr + + def getProductClass(self): + return self.productClass + + def setProductClass(self, productClass): + self.productClass = productClass + + def getAct(self): + return self.act + + def setAct(self, act): + self.act = act + + def getOfficeid(self): + return self.key.getOfficeid() + + def setOfficeid(self, officeid): + self.key.setOfficeid(officeid) + + def getPhen(self): + return self.key.getPhen() + + def setPhen(self, phen): + self.key.setPhen(phen) + + def getSig(self): + return self.key.getSig() + + def setSig(self, sig): + self.key.setSig(sig) + + def getEtn(self): + return self.key.getEtn() + + def setEtn(self, etn): + self.key.setEtn(etn) + + def getStartTime(self): + return self.startTime + + def setStartTime(self, startTime): + self.startTime = startTime + + def getEndTime(self): + return self.endTime + + def setEndTime(self, endTime): + self.endTime = endTime + + def getIssueTime(self): + return self.issueTime + + def setIssueTime(self, issueTime): + self.issueTime = issueTime + + def getPurgeTime(self): + return self.purgeTime + + def setPurgeTime(self, purgeTime): + self.purgeTime = purgeTime + + def isUfn(self): + return self.ufn + + def setUfn(self, ufn): + self.ufn = ufn + + def getGeometry(self): + return self.geometry + + def setGeometry(self, geometry): + self.geometry = geometry + + def getForecaster(self): + return self.forecaster + + def setForecaster(self, forecaster): + self.forecaster = forecaster + + def getMotdir(self): + return self.motdir + + def setMotdir(self, motdir): + self.motdir = motdir + + def getMotspd(self): + return self.motspd + + def setMotspd(self, motspd): + self.motspd = motspd + + def getLoc(self): + return self.loc + + def setLoc(self, loc): + self.loc = loc + + def getRawmessage(self): + return self.rawmessage + + def setRawmessage(self, rawmessage): + self.rawmessage = rawmessage + + def getSeg(self): + return self.seg + + def setSeg(self, seg): + self.seg = seg + + def getPhensig(self): + return self.phensig + + def setPhensig(self, phensig): + self.phensig = phensig + + def getRegion(self): + return self.region + + def setRegion(self, region): + self.region = region + + def getOverviewText(self): + return self.overviewText + + def setOverviewText(self, overviewText): + self.overviewText = overviewText + + def getSegText(self): + return self.segText + + def setSegText(self, segText): + self.segText = segText + + def getLocationID(self): + return self.locationID + + def setLocationID(self, locationID): + self.locationID = locationID + + def getFloodSeverity(self): + return self.floodSeverity + + def setFloodSeverity(self, floodSeverity): + self.floodSeverity = floodSeverity + + def getImmediateCause(self): + return self.immediateCause + + def setImmediateCause(self, immediateCause): + self.immediateCause = immediateCause + + def getFloodRecordStatus(self): + return self.floodRecordStatus + + def setFloodRecordStatus(self, floodRecordStatus): + self.floodRecordStatus = floodRecordStatus + + def getFloodBegin(self): + return self.floodBegin + + def setFloodBegin(self, floodBegin): + self.floodBegin = floodBegin + + def getFloodCrest(self): + return self.floodCrest + + def setFloodCrest(self, floodCrest): + self.floodCrest = floodCrest + + def getFloodEnd(self): + return self.floodEnd + + def setFloodEnd(self, floodEnd): + self.floodEnd = floodEnd + + def getIdentifier(self): + return self.identifier + + def setIdentifier(self, identifier): + self.identifier = identifier + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/OperationalActiveTableRecord.py b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/OperationalActiveTableRecord.py index 86a959c..1c7dbbc 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/OperationalActiveTableRecord.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/OperationalActiveTableRecord.py @@ -26,7 +26,7 @@ # ## -import ActiveTableRecord +from . import ActiveTableRecord class OperationalActiveTableRecord(ActiveTableRecord.ActiveTableRecord): diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/OperationalActiveTableRecord.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/OperationalActiveTableRecord.py.bak new file mode 100644 index 0000000..86a959c --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/OperationalActiveTableRecord.py.bak @@ -0,0 +1,34 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 05/22/2015 4522 randerso Changed to inherit from ActiveTableRecord +# +## + +import ActiveTableRecord + +class OperationalActiveTableRecord(ActiveTableRecord.ActiveTableRecord): + + def __init__(self): + super(OperationalActiveTableRecord, self).__init__() diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/PracticeActiveTableRecord.py b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/PracticeActiveTableRecord.py index d60e78a..a9174f1 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/PracticeActiveTableRecord.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/PracticeActiveTableRecord.py @@ -26,7 +26,7 @@ # ## -import ActiveTableRecord +from . import ActiveTableRecord class PracticeActiveTableRecord(ActiveTableRecord.ActiveTableRecord): diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/PracticeActiveTableRecord.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/PracticeActiveTableRecord.py.bak new file mode 100644 index 0000000..d60e78a --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/PracticeActiveTableRecord.py.bak @@ -0,0 +1,34 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 05/22/2015 4522 randerso Changed to inherit from ActiveTableRecord +# +## + +import ActiveTableRecord + +class PracticeActiveTableRecord(ActiveTableRecord.ActiveTableRecord): + + def __init__(self): + super(PracticeActiveTableRecord, self).__init__() diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/__init__.py index 6dce1e6..a209f1f 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/__init__.py @@ -41,20 +41,20 @@ __all__ = [ 'response' ] -from ActiveTableKey import ActiveTableKey -from ActiveTableRecord import ActiveTableRecord -from ActiveTableMode import ActiveTableMode -from DumpActiveTableRequest import DumpActiveTableRequest -from DumpActiveTableResponse import DumpActiveTableResponse -from GetActiveTableDictRequest import GetActiveTableDictRequest -from GetActiveTableDictResponse import GetActiveTableDictResponse -from GetFourCharSitesRequest import GetFourCharSitesRequest -from GetFourCharSitesResponse import GetFourCharSitesResponse -from GetVtecAttributeRequest import GetVtecAttributeRequest -from GetVtecAttributeResponse import GetVtecAttributeResponse -from OperationalActiveTableRecord import OperationalActiveTableRecord -from PracticeActiveTableRecord import PracticeActiveTableRecord -from SendPracticeProductRequest import SendPracticeProductRequest -from VTECChange import VTECChange -from VTECTableChangeNotification import VTECTableChangeNotification +from .ActiveTableKey import ActiveTableKey +from .ActiveTableRecord import ActiveTableRecord +from .ActiveTableMode import ActiveTableMode +from .DumpActiveTableRequest import DumpActiveTableRequest +from .DumpActiveTableResponse import DumpActiveTableResponse +from .GetActiveTableDictRequest import GetActiveTableDictRequest +from .GetActiveTableDictResponse import GetActiveTableDictResponse +from .GetFourCharSitesRequest import GetFourCharSitesRequest +from .GetFourCharSitesResponse import GetFourCharSitesResponse +from .GetVtecAttributeRequest import GetVtecAttributeRequest +from .GetVtecAttributeResponse import GetVtecAttributeResponse +from .OperationalActiveTableRecord import OperationalActiveTableRecord +from .PracticeActiveTableRecord import PracticeActiveTableRecord +from .SendPracticeProductRequest import SendPracticeProductRequest +from .VTECChange import VTECChange +from .VTECTableChangeNotification import VTECTableChangeNotification diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/__init__.py.bak new file mode 100644 index 0000000..6dce1e6 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/__init__.py.bak @@ -0,0 +1,60 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'ActiveTableKey', + 'ActiveTableRecord', + 'ActiveTableMode', + 'DumpActiveTableRequest', + 'DumpActiveTableResponse', + 'GetActiveTableDictRequest', + 'GetActiveTableDictResponse', + 'GetFourCharSitesRequest', + 'GetFourCharSitesResponse', + 'GetVtecAttributeRequest', + 'GetVtecAttributeResponse', + 'OperationalActiveTableRecord', + 'PracticeActiveTableRecord', + 'SendPracticeProductRequest', + 'VTECChange', + 'VTECTableChangeNotification', + 'request', + 'response' + ] + +from ActiveTableKey import ActiveTableKey +from ActiveTableRecord import ActiveTableRecord +from ActiveTableMode import ActiveTableMode +from DumpActiveTableRequest import DumpActiveTableRequest +from DumpActiveTableResponse import DumpActiveTableResponse +from GetActiveTableDictRequest import GetActiveTableDictRequest +from GetActiveTableDictResponse import GetActiveTableDictResponse +from GetFourCharSitesRequest import GetFourCharSitesRequest +from GetFourCharSitesResponse import GetFourCharSitesResponse +from GetVtecAttributeRequest import GetVtecAttributeRequest +from GetVtecAttributeResponse import GetVtecAttributeResponse +from OperationalActiveTableRecord import OperationalActiveTableRecord +from PracticeActiveTableRecord import PracticeActiveTableRecord +from SendPracticeProductRequest import SendPracticeProductRequest +from VTECChange import VTECChange +from VTECTableChangeNotification import VTECTableChangeNotification + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/request/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/request/__init__.py index d025668..7636aeb 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/request/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/request/__init__.py @@ -27,8 +27,8 @@ __all__ = [ 'SendActiveTableRequest' ] -from ClearPracticeVTECTableRequest import ClearPracticeVTECTableRequest -from MergeActiveTableRequest import MergeActiveTableRequest -from RetrieveRemoteActiveTableRequest import RetrieveRemoteActiveTableRequest -from SendActiveTableRequest import SendActiveTableRequest +from .ClearPracticeVTECTableRequest import ClearPracticeVTECTableRequest +from .MergeActiveTableRequest import MergeActiveTableRequest +from .RetrieveRemoteActiveTableRequest import RetrieveRemoteActiveTableRequest +from .SendActiveTableRequest import SendActiveTableRequest diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/request/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/request/__init__.py.bak new file mode 100644 index 0000000..d025668 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/request/__init__.py.bak @@ -0,0 +1,34 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'ClearPracticeVTECTableRequest', + 'MergeActiveTableRequest', + 'RetrieveRemoteActiveTableRequest', + 'SendActiveTableRequest' + ] + +from ClearPracticeVTECTableRequest import ClearPracticeVTECTableRequest +from MergeActiveTableRequest import MergeActiveTableRequest +from RetrieveRemoteActiveTableRequest import RetrieveRemoteActiveTableRequest +from SendActiveTableRequest import SendActiveTableRequest + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/response/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/response/__init__.py index 85a8994..32ad861 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/response/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/response/__init__.py @@ -24,5 +24,5 @@ __all__ = [ 'ActiveTableSharingResponse' ] -from ActiveTableSharingResponse import ActiveTableSharingResponse +from .ActiveTableSharingResponse import ActiveTableSharingResponse diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/response/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/response/__init__.py.bak new file mode 100644 index 0000000..85a8994 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/response/__init__.py.bak @@ -0,0 +1,28 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'ActiveTableSharingResponse' + ] + +from ActiveTableSharingResponse import ActiveTableSharingResponse + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/alertviz/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/alertviz/__init__.py index 91d253d..45db355 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/alertviz/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/alertviz/__init__.py @@ -24,5 +24,5 @@ __all__ = [ 'AlertVizRequest' ] -from AlertVizRequest import AlertVizRequest +from .AlertVizRequest import AlertVizRequest diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/alertviz/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/alertviz/__init__.py.bak new file mode 100644 index 0000000..91d253d --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/alertviz/__init__.py.bak @@ -0,0 +1,28 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'AlertVizRequest' + ] + +from AlertVizRequest import AlertVizRequest + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/AbstractFailedResponse.py b/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/AbstractFailedResponse.py index 36d417f..e852ae9 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/AbstractFailedResponse.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/AbstractFailedResponse.py @@ -23,9 +23,7 @@ import abc -class AbstractFailedResponse(object): - __metaclass__ = abc.ABCMeta - +class AbstractFailedResponse(object, metaclass=abc.ABCMeta): @abc.abstractmethod def __init__(self): self.request = None diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/AbstractFailedResponse.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/AbstractFailedResponse.py.bak new file mode 100644 index 0000000..36d417f --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/AbstractFailedResponse.py.bak @@ -0,0 +1,38 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated against equivalent DynamicSerialize Java class + +import abc + + +class AbstractFailedResponse(object): + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def __init__(self): + self.request = None + + def getRequest(self): + return self.request + + def setRequest(self, request): + self.request = request + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/__init__.py index d974289..ee77bf9 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/__init__.py @@ -27,8 +27,8 @@ __all__ = [ 'UserNotAuthorized' ] -from AbstractFailedResponse import AbstractFailedResponse -from AuthServerErrorResponse import AuthServerErrorResponse -from SuccessfulExecution import SuccessfulExecution -from UserNotAuthorized import UserNotAuthorized +from .AbstractFailedResponse import AbstractFailedResponse +from .AuthServerErrorResponse import AuthServerErrorResponse +from .SuccessfulExecution import SuccessfulExecution +from .UserNotAuthorized import UserNotAuthorized diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/__init__.py.bak new file mode 100644 index 0000000..d974289 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/__init__.py.bak @@ -0,0 +1,34 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'AbstractFailedResponse', + 'AuthServerErrorResponse', + 'SuccessfulExecution', + 'UserNotAuthorized' + ] + +from AbstractFailedResponse import AbstractFailedResponse +from AuthServerErrorResponse import AuthServerErrorResponse +from SuccessfulExecution import SuccessfulExecution +from UserNotAuthorized import UserNotAuthorized + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/auth/user/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/auth/user/__init__.py index 81425bf..f570434 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/auth/user/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/auth/user/__init__.py @@ -24,4 +24,4 @@ __all__ = [ 'AuthenticationData' ] -from AuthenticationData import AuthenticationData +from .AuthenticationData import AuthenticationData diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/auth/user/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/auth/user/__init__.py.bak new file mode 100644 index 0000000..81425bf --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/auth/user/__init__.py.bak @@ -0,0 +1,27 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'AuthenticationData' + ] + +from AuthenticationData import AuthenticationData diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/DefaultDataRequest.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/DefaultDataRequest.py index 7fbf286..bf1a6d3 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/DefaultDataRequest.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/DefaultDataRequest.py @@ -56,10 +56,10 @@ class DefaultDataRequest(IDataRequest): del self.identifiers[key] def setParameters(self, *params): - self.parameters = map(str, params) + self.parameters = list(map(str, params)) def setLevels(self, *levels): - self.levels = map(self.__makeLevel, levels) + self.levels = list(map(self.__makeLevel, levels)) def __makeLevel(self, level): if type(level) is Level: @@ -73,7 +73,7 @@ class DefaultDataRequest(IDataRequest): self.envelope = Envelope(env.envelope) def setLocationNames(self, *locationNames): - self.locationNames = map(str, locationNames) + self.locationNames = list(map(str, locationNames)) def getDatatype(self): return self.datatype diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/DefaultDataRequest.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/DefaultDataRequest.py.bak new file mode 100644 index 0000000..7fbf286 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/DefaultDataRequest.py.bak @@ -0,0 +1,94 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated against equivalent DynamicSerialize Java class +# and then modified post-generation to sub-class IDataRequest. +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 05/28/13 2023 dgilling Initial Creation. +# +# + + +from awips.dataaccess import IDataRequest + +from dynamicserialize.dstypes.com.vividsolutions.jts.geom import Envelope +from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.level import Level + + +class DefaultDataRequest(IDataRequest): + + def __init__(self): + self.datatype = None + self.identifiers = {} + self.parameters = [] + self.levels = [] + self.locationNames = [] + self.envelope = None + + def setDatatype(self, datatype): + self.datatype = str(datatype) + + def addIdentifier(self, key, value): + self.identifiers[key] = value + + def removeIdentifier(self, key): + del self.identifiers[key] + + def setParameters(self, *params): + self.parameters = map(str, params) + + def setLevels(self, *levels): + self.levels = map(self.__makeLevel, levels) + + def __makeLevel(self, level): + if type(level) is Level: + return level + elif type(level) is str: + return Level(level) + else: + raise TypeError("Invalid object type specified for level.") + + def setEnvelope(self, env): + self.envelope = Envelope(env.envelope) + + def setLocationNames(self, *locationNames): + self.locationNames = map(str, locationNames) + + def getDatatype(self): + return self.datatype + + def getIdentifiers(self): + return self.identifiers + + def getParameters(self): + return self.parameters + + def getLevels(self): + return self.levels + + def getEnvelope(self): + return self.envelope + + def getLocationNames(self): + return self.locationNames diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/__init__.py index f9a76ac..5d57bfb 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/__init__.py @@ -24,5 +24,5 @@ __all__ = [ 'DefaultDataRequest' ] -from DefaultDataRequest import DefaultDataRequest +from .DefaultDataRequest import DefaultDataRequest diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/__init__.py.bak new file mode 100644 index 0000000..f9a76ac --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/impl/__init__.py.bak @@ -0,0 +1,28 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'DefaultDataRequest' + ] + +from DefaultDataRequest import DefaultDataRequest + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractDataAccessRequest.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractDataAccessRequest.py index 1d64796..a70c46f 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractDataAccessRequest.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractDataAccessRequest.py @@ -32,9 +32,7 @@ import abc -class AbstractDataAccessRequest(object): - __metaclass__ = abc.ABCMeta - +class AbstractDataAccessRequest(object, metaclass=abc.ABCMeta): def __init__(self): self.requestParameters = None diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractDataAccessRequest.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractDataAccessRequest.py.bak new file mode 100644 index 0000000..1d64796 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractDataAccessRequest.py.bak @@ -0,0 +1,46 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated against equivalent DynamicSerialize Java class +# and then modified post-generation to make it a abstract base class. +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 05/28/13 #2023 dgilling Initial Creation. +# +# + +import abc + + +class AbstractDataAccessRequest(object): + __metaclass__ = abc.ABCMeta + + def __init__(self): + self.requestParameters = None + + def getRequestParameters(self): + return self.requestParameters + + def setRequestParameters(self, requestParameters): + self.requestParameters = requestParameters + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractIdentifierRequest.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractIdentifierRequest.py index 0288580..337035c 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractIdentifierRequest.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractIdentifierRequest.py @@ -31,9 +31,7 @@ import abc -class AbstractIdentifierRequest(object): - __metaclass__ = abc.ABCMeta - +class AbstractIdentifierRequest(object, metaclass=abc.ABCMeta): def __init__(self): self.datatype = None diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractIdentifierRequest.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractIdentifierRequest.py.bak new file mode 100644 index 0000000..0288580 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractIdentifierRequest.py.bak @@ -0,0 +1,45 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated against equivalent DynamicSerialize Java class +# and then modified post-generation to make it a abstract base class. +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 07/23/14 #3185 njensen Initial Creation. +# +# + +import abc + +class AbstractIdentifierRequest(object): + __metaclass__ = abc.ABCMeta + + def __init__(self): + self.datatype = None + + def getDatatype(self): + return self.datatype + + def setDatatype(self, datatype): + self.datatype = datatype + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/__init__.py index 75a770d..f85be8b 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/__init__.py @@ -34,15 +34,15 @@ __all__ = [ 'GetOptionalIdentifiersRequest' ] -from AbstractDataAccessRequest import AbstractDataAccessRequest -from AbstractIdentifierRequest import AbstractIdentifierRequest -from GetAvailableLevelsRequest import GetAvailableLevelsRequest -from GetAvailableLocationNamesRequest import GetAvailableLocationNamesRequest -from GetAvailableParametersRequest import GetAvailableParametersRequest -from GetAvailableTimesRequest import GetAvailableTimesRequest -from GetGeometryDataRequest import GetGeometryDataRequest -from GetGridDataRequest import GetGridDataRequest -from GetRequiredIdentifiersRequest import GetRequiredIdentifiersRequest -from GetSupportedDatatypesRequest import GetSupportedDatatypesRequest -from GetOptionalIdentifiersRequest import GetOptionalIdentifiersRequest +from .AbstractDataAccessRequest import AbstractDataAccessRequest +from .AbstractIdentifierRequest import AbstractIdentifierRequest +from .GetAvailableLevelsRequest import GetAvailableLevelsRequest +from .GetAvailableLocationNamesRequest import GetAvailableLocationNamesRequest +from .GetAvailableParametersRequest import GetAvailableParametersRequest +from .GetAvailableTimesRequest import GetAvailableTimesRequest +from .GetGeometryDataRequest import GetGeometryDataRequest +from .GetGridDataRequest import GetGridDataRequest +from .GetRequiredIdentifiersRequest import GetRequiredIdentifiersRequest +from .GetSupportedDatatypesRequest import GetSupportedDatatypesRequest +from .GetOptionalIdentifiersRequest import GetOptionalIdentifiersRequest diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/__init__.py.bak new file mode 100644 index 0000000..75a770d --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/__init__.py.bak @@ -0,0 +1,48 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'AbstractDataAccessRequest', + 'AbstractIdentifierRequest', + 'GetAvailableLevelsRequest', + 'GetAvailableLocationNamesRequest', + 'GetAvailableParametersRequest', + 'GetAvailableTimesRequest', + 'GetGeometryDataRequest', + 'GetGridDataRequest', + 'GetRequiredIdentifiersRequest', + 'GetSupportedDatatypesRequest', + 'GetOptionalIdentifiersRequest' + ] + +from AbstractDataAccessRequest import AbstractDataAccessRequest +from AbstractIdentifierRequest import AbstractIdentifierRequest +from GetAvailableLevelsRequest import GetAvailableLevelsRequest +from GetAvailableLocationNamesRequest import GetAvailableLocationNamesRequest +from GetAvailableParametersRequest import GetAvailableParametersRequest +from GetAvailableTimesRequest import GetAvailableTimesRequest +from GetGeometryDataRequest import GetGeometryDataRequest +from GetGridDataRequest import GetGridDataRequest +from GetRequiredIdentifiersRequest import GetRequiredIdentifiersRequest +from GetSupportedDatatypesRequest import GetSupportedDatatypesRequest +from GetOptionalIdentifiersRequest import GetOptionalIdentifiersRequest + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/AbstractResponseData.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/AbstractResponseData.py index 801763a..7e9520a 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/AbstractResponseData.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/AbstractResponseData.py @@ -23,9 +23,7 @@ import abc -class AbstractResponseData(object): - __metaclass__ = abc.ABCMeta - +class AbstractResponseData(object, metaclass=abc.ABCMeta): @abc.abstractmethod def __init__(self): self.time = None diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/AbstractResponseData.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/AbstractResponseData.py.bak new file mode 100644 index 0000000..801763a --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/AbstractResponseData.py.bak @@ -0,0 +1,59 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated against equivalent DynamicSerialize Java class + +import abc + + +class AbstractResponseData(object): + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def __init__(self): + self.time = None + self.level = None + self.locationName = None + self.attributes = None + + def getTime(self): + return self.time + + def setTime(self, time): + self.time = time + + def getLevel(self): + return self.level + + def setLevel(self, level): + self.level = level + + def getLocationName(self): + return self.locationName + + def setLocationName(self, locationName): + self.locationName = locationName + + def getAttributes(self): + return self.attributes + + def setAttributes(self, attributes): + self.attributes = attributes + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/__init__.py index 9b88d47..491d3f3 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/__init__.py @@ -28,9 +28,9 @@ __all__ = [ 'GridResponseData' ] -from AbstractResponseData import AbstractResponseData -from GeometryResponseData import GeometryResponseData -from GetGeometryDataResponse import GetGeometryDataResponse -from GetGridDataResponse import GetGridDataResponse -from GridResponseData import GridResponseData +from .AbstractResponseData import AbstractResponseData +from .GeometryResponseData import GeometryResponseData +from .GetGeometryDataResponse import GetGeometryDataResponse +from .GetGridDataResponse import GetGridDataResponse +from .GridResponseData import GridResponseData diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/__init__.py.bak new file mode 100644 index 0000000..9b88d47 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/__init__.py.bak @@ -0,0 +1,36 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'AbstractResponseData', + 'GeometryResponseData', + 'GetGeometryDataResponse', + 'GetGridDataResponse', + 'GridResponseData' + ] + +from AbstractResponseData import AbstractResponseData +from GeometryResponseData import GeometryResponseData +from GetGeometryDataResponse import GetGeometryDataResponse +from GetGridDataResponse import GetGridDataResponse +from GridResponseData import GridResponseData + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/events/hazards/requests/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/events/hazards/requests/__init__.py index e9e81a9..1cf5210 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/events/hazards/requests/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/events/hazards/requests/__init__.py @@ -24,5 +24,5 @@ __all__ = [ 'RegionLookupRequest' ] -from RegionLookupRequest import RegionLookupRequest +from .RegionLookupRequest import RegionLookupRequest diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/events/hazards/requests/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/events/hazards/requests/__init__.py.bak new file mode 100644 index 0000000..e9e81a9 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/events/hazards/requests/__init__.py.bak @@ -0,0 +1,28 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'RegionLookupRequest' + ] + +from RegionLookupRequest import RegionLookupRequest + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/__init__.py index 3cce4f9..f8dcfce 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/__init__.py @@ -39,5 +39,5 @@ __all__ = [ 'weather' ] -from GridDataHistory import GridDataHistory +from .GridDataHistory import GridDataHistory diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/__init__.py.bak new file mode 100644 index 0000000..3cce4f9 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/__init__.py.bak @@ -0,0 +1,43 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 06/22/2015 4573 randerso Added svcbu package +# +## + +__all__ = [ + 'GridDataHistory', + 'config', + 'db', + 'discrete', + 'grid', + 'request', + 'server', + 'slice', + 'svcbu', + 'weather' + ] + +from GridDataHistory import GridDataHistory + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/config/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/config/__init__.py index 2b663f3..485645a 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/config/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/config/__init__.py @@ -24,5 +24,5 @@ __all__ = [ 'ProjectionData' ] -from ProjectionData import ProjectionData +from .ProjectionData import ProjectionData diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/config/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/config/__init__.py.bak new file mode 100644 index 0000000..2b663f3 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/config/__init__.py.bak @@ -0,0 +1,28 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'ProjectionData' + ] + +from ProjectionData import ProjectionData + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/__init__.py index 8ff9bb9..7de4112 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/__init__.py @@ -29,10 +29,10 @@ __all__ = [ 'TimeConstraints' ] -from DatabaseID import DatabaseID -from GFERecord import GFERecord -from GridLocation import GridLocation -from GridParmInfo import GridParmInfo -from ParmID import ParmID -from TimeConstraints import TimeConstraints +from .DatabaseID import DatabaseID +from .GFERecord import GFERecord +from .GridLocation import GridLocation +from .GridParmInfo import GridParmInfo +from .ParmID import ParmID +from .TimeConstraints import TimeConstraints diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/__init__.py.bak new file mode 100644 index 0000000..8ff9bb9 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/db/objects/__init__.py.bak @@ -0,0 +1,38 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'DatabaseID', + 'GFERecord', + 'GridLocation', + 'GridParmInfo', + 'ParmID', + 'TimeConstraints' + ] + +from DatabaseID import DatabaseID +from GFERecord import GFERecord +from GridLocation import GridLocation +from GridParmInfo import GridParmInfo +from ParmID import ParmID +from TimeConstraints import TimeConstraints + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/discrete/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/discrete/__init__.py index 7e837ea..1c34157 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/discrete/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/discrete/__init__.py @@ -24,5 +24,5 @@ __all__ = [ 'DiscreteKey' ] -from DiscreteKey import DiscreteKey +from .DiscreteKey import DiscreteKey diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/discrete/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/discrete/__init__.py.bak new file mode 100644 index 0000000..7e837ea --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/discrete/__init__.py.bak @@ -0,0 +1,28 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'DiscreteKey' + ] + +from DiscreteKey import DiscreteKey + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/grid/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/grid/__init__.py index fbe02f5..f59fd07 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/grid/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/grid/__init__.py @@ -25,6 +25,6 @@ __all__ = [ 'Grid2DFloat' ] -from Grid2DByte import Grid2DByte -from Grid2DFloat import Grid2DFloat +from .Grid2DByte import Grid2DByte +from .Grid2DFloat import Grid2DFloat diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/grid/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/grid/__init__.py.bak new file mode 100644 index 0000000..fbe02f5 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/grid/__init__.py.bak @@ -0,0 +1,30 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'Grid2DByte', + 'Grid2DFloat' + ] + +from Grid2DByte import Grid2DByte +from Grid2DFloat import Grid2DFloat + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfeRequest.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfeRequest.py index a6ab957..f5c8209 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfeRequest.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfeRequest.py @@ -23,9 +23,7 @@ import abc -class AbstractGfeRequest(object): - __metaclass__ = abc.ABCMeta - +class AbstractGfeRequest(object, metaclass=abc.ABCMeta): @abc.abstractmethod def __init__(self): self.siteID = None diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfeRequest.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfeRequest.py.bak new file mode 100644 index 0000000..a6ab957 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfeRequest.py.bak @@ -0,0 +1,44 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated against equivalent DynamicSerialize Java class + +import abc + + +class AbstractGfeRequest(object): + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def __init__(self): + self.siteID = None + self.workstationID = None + + def getSiteID(self): + return self.siteID + + def setSiteID(self, siteID): + self.siteID = siteID + + def getWorkstationID(self): + return self.workstationID + + def setWorkstationID(self, workstationID): + self.workstationID = workstationID diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/GetGridDataRequest.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/GetGridDataRequest.py index 43be6e0..41b666c 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/GetGridDataRequest.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/GetGridDataRequest.py @@ -25,9 +25,7 @@ import abc from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.request import GetGridRequest -class GetGridDataRequest(object): - __metaclass__ = abc.ABCMeta - +class GetGridDataRequest(object, metaclass=abc.ABCMeta): @abc.abstractmethod def __init__(self): self.requests = [] diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/GetGridDataRequest.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/GetGridDataRequest.py.bak new file mode 100644 index 0000000..43be6e0 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/GetGridDataRequest.py.bak @@ -0,0 +1,63 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated against equivalent DynamicSerialize Java class + +import abc + +from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.request import GetGridRequest + + +class GetGridDataRequest(object): + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def __init__(self): + self.requests = [] + self.workstationID = None + self.siteID = None + + def addRequest(self, gridDataReq): + if not isinstance(gridDataReq, GetGridRequest): + raise TypeError("Invalid request specified: " + str(type(gridDataReq)) + \ + ". Only GetGridRequests are supported.") + else: + self.requests.append(gridDataReq) + + def getRequests(self): + return self.requests + + def setRequests(self, requests): + del self.requests[:] + for req in requests: + self.addRequest(req) + + def getWorkstationID(self): + return self.workstationID + + def setWorkstationID(self, workstationID): + self.workstationID = workstationID + + def getSiteID(self): + return self.siteID + + def setSiteID(self, siteID): + self.siteID = siteID + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/__init__.py index 8cea5cd..eedcac5 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/__init__.py @@ -54,30 +54,30 @@ __all__ = [ 'RsyncGridsToCWFRequest', ] -from AbstractGfeRequest import AbstractGfeRequest -from CommitGridsRequest import CommitGridsRequest -from ConfigureTextProductsRequest import ConfigureTextProductsRequest -from ExecuteIfpNetCDFGridRequest import ExecuteIfpNetCDFGridRequest -from ExecuteIscMosaicRequest import ExecuteIscMosaicRequest -from ExportGridsRequest import ExportGridsRequest -from GetASCIIGridsRequest import GetASCIIGridsRequest -from GetGridDataRequest import GetGridDataRequest -from GetGridInventoryRequest import GetGridInventoryRequest -from GetLatestDbTimeRequest import GetLatestDbTimeRequest -from GetLatestModelDbIdRequest import GetLatestModelDbIdRequest -from GetLockTablesRequest import GetLockTablesRequest -from GetOfficialDbNameRequest import GetOfficialDbNameRequest -from GetParmListRequest import GetParmListRequest -from GetSelectTimeRangeRequest import GetSelectTimeRangeRequest -from GetSingletonDbIdsRequest import GetSingletonDbIdsRequest -from GetSiteTimeZoneInfoRequest import GetSiteTimeZoneInfoRequest -from GridLocRequest import GridLocRequest -from IscDataRecRequest import IscDataRecRequest -from LockChangeRequest import LockChangeRequest -from ProcessReceivedConfRequest import ProcessReceivedConfRequest -from ProcessReceivedDigitalDataRequest import ProcessReceivedDigitalDataRequest -from PurgeGfeGridsRequest import PurgeGfeGridsRequest -from SaveASCIIGridsRequest import SaveASCIIGridsRequest -from SmartInitRequest import SmartInitRequest -from RsyncGridsToCWFRequest import RsyncGridsToCWFRequest +from .AbstractGfeRequest import AbstractGfeRequest +from .CommitGridsRequest import CommitGridsRequest +from .ConfigureTextProductsRequest import ConfigureTextProductsRequest +from .ExecuteIfpNetCDFGridRequest import ExecuteIfpNetCDFGridRequest +from .ExecuteIscMosaicRequest import ExecuteIscMosaicRequest +from .ExportGridsRequest import ExportGridsRequest +from .GetASCIIGridsRequest import GetASCIIGridsRequest +from .GetGridDataRequest import GetGridDataRequest +from .GetGridInventoryRequest import GetGridInventoryRequest +from .GetLatestDbTimeRequest import GetLatestDbTimeRequest +from .GetLatestModelDbIdRequest import GetLatestModelDbIdRequest +from .GetLockTablesRequest import GetLockTablesRequest +from .GetOfficialDbNameRequest import GetOfficialDbNameRequest +from .GetParmListRequest import GetParmListRequest +from .GetSelectTimeRangeRequest import GetSelectTimeRangeRequest +from .GetSingletonDbIdsRequest import GetSingletonDbIdsRequest +from .GetSiteTimeZoneInfoRequest import GetSiteTimeZoneInfoRequest +from .GridLocRequest import GridLocRequest +from .IscDataRecRequest import IscDataRecRequest +from .LockChangeRequest import LockChangeRequest +from .ProcessReceivedConfRequest import ProcessReceivedConfRequest +from .ProcessReceivedDigitalDataRequest import ProcessReceivedDigitalDataRequest +from .PurgeGfeGridsRequest import PurgeGfeGridsRequest +from .SaveASCIIGridsRequest import SaveASCIIGridsRequest +from .SmartInitRequest import SmartInitRequest +from .RsyncGridsToCWFRequest import RsyncGridsToCWFRequest diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/__init__.py.bak new file mode 100644 index 0000000..8cea5cd --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/__init__.py.bak @@ -0,0 +1,83 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# Jul 15, 2015 #4013 randerso Added RsyncGridsToCWFRequest +# + +__all__ = [ + 'AbstractGfeRequest', + 'CommitGridsRequest', + 'ConfigureTextProductsRequest', + 'ExecuteIfpNetCDFGridRequest', + 'ExecuteIscMosaicRequest', + 'ExportGridsRequest', + 'GetASCIIGridsRequest', + 'GetGridDataRequest', + 'GetGridInventoryRequest', + 'GetLatestDbTimeRequest', + 'GetLatestModelDbIdRequest', + 'GetLockTablesRequest', + 'GetOfficialDbNameRequest', + 'GetParmListRequest', + 'GetSelectTimeRangeRequest', + 'GetSingletonDbIdsRequest', + 'GetSiteTimeZoneInfoRequest', + 'GridLocRequest', + 'IscDataRecRequest', + 'LockChangeRequest', + 'ProcessReceivedConfRequest', + 'ProcessReceivedDigitalDataRequest', + 'PurgeGfeGridsRequest', + 'SaveASCIIGridsRequest', + 'SmartInitRequest', + 'RsyncGridsToCWFRequest', + ] + +from AbstractGfeRequest import AbstractGfeRequest +from CommitGridsRequest import CommitGridsRequest +from ConfigureTextProductsRequest import ConfigureTextProductsRequest +from ExecuteIfpNetCDFGridRequest import ExecuteIfpNetCDFGridRequest +from ExecuteIscMosaicRequest import ExecuteIscMosaicRequest +from ExportGridsRequest import ExportGridsRequest +from GetASCIIGridsRequest import GetASCIIGridsRequest +from GetGridDataRequest import GetGridDataRequest +from GetGridInventoryRequest import GetGridInventoryRequest +from GetLatestDbTimeRequest import GetLatestDbTimeRequest +from GetLatestModelDbIdRequest import GetLatestModelDbIdRequest +from GetLockTablesRequest import GetLockTablesRequest +from GetOfficialDbNameRequest import GetOfficialDbNameRequest +from GetParmListRequest import GetParmListRequest +from GetSelectTimeRangeRequest import GetSelectTimeRangeRequest +from GetSingletonDbIdsRequest import GetSingletonDbIdsRequest +from GetSiteTimeZoneInfoRequest import GetSiteTimeZoneInfoRequest +from GridLocRequest import GridLocRequest +from IscDataRecRequest import IscDataRecRequest +from LockChangeRequest import LockChangeRequest +from ProcessReceivedConfRequest import ProcessReceivedConfRequest +from ProcessReceivedDigitalDataRequest import ProcessReceivedDigitalDataRequest +from PurgeGfeGridsRequest import PurgeGfeGridsRequest +from SaveASCIIGridsRequest import SaveASCIIGridsRequest +from SmartInitRequest import SmartInitRequest +from RsyncGridsToCWFRequest import RsyncGridsToCWFRequest + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/lock/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/lock/__init__.py index aa2715f..ea63b44 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/lock/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/lock/__init__.py @@ -25,6 +25,6 @@ __all__ = [ 'LockTable' ] -from Lock import Lock -from LockTable import LockTable +from .Lock import Lock +from .LockTable import LockTable diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/lock/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/lock/__init__.py.bak new file mode 100644 index 0000000..aa2715f --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/lock/__init__.py.bak @@ -0,0 +1,30 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'Lock', + 'LockTable' + ] + +from Lock import Lock +from LockTable import LockTable + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/ServerResponse.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/ServerResponse.py index 36635f9..a476ddb 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/ServerResponse.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/ServerResponse.py @@ -61,5 +61,5 @@ class ServerResponse(object): def __str__(self): return self.message() - def __nonzero__(self): + def __bool__(self): return self.isOkay() \ No newline at end of file diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/ServerResponse.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/ServerResponse.py.bak new file mode 100644 index 0000000..36635f9 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/ServerResponse.py.bak @@ -0,0 +1,65 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated against equivalent DynamicSerialize Java class + +class ServerResponse(object): + + def __init__(self): + self.messages = None + self.payload = None + self.notifications = None + + def getMessages(self): + return self.messages + + def setMessages(self, messages): + self.messages = messages + + def getPayload(self): + return self.payload + + def setPayload(self, payload): + self.payload = payload + + def getNotifications(self): + return self.notifications + + def setNotifications(self, notifications): + self.notifications = notifications + + def isOkay(self): + return (self.messages is None or len(self.messages) == 0) + + def message(self): + if (self.isOkay()): + return "" + else: + compMessage = "" + for serverMsg in self.messages: + compMessage += serverMsg.getMessage() + "\n" + + return compMessage + + def __str__(self): + return self.message() + + def __nonzero__(self): + return self.isOkay() \ No newline at end of file diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/__init__.py index 868bbc0..0f8839d 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/__init__.py @@ -25,6 +25,6 @@ __all__ = [ 'ServerResponse' ] -from ServerMsg import ServerMsg -from ServerResponse import ServerResponse +from .ServerMsg import ServerMsg +from .ServerResponse import ServerResponse diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/__init__.py.bak new file mode 100644 index 0000000..868bbc0 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/message/__init__.py.bak @@ -0,0 +1,30 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'ServerMsg', + 'ServerResponse' + ] + +from ServerMsg import ServerMsg +from ServerResponse import ServerResponse + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/CombinationsFileChangedNotification.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/CombinationsFileChangedNotification.py index 6c55f30..8b69723 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/CombinationsFileChangedNotification.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/CombinationsFileChangedNotification.py @@ -26,7 +26,7 @@ # ## -import GfeNotification +from . import GfeNotification class CombinationsFileChangedNotification(GfeNotification.GfeNotification): diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/CombinationsFileChangedNotification.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/CombinationsFileChangedNotification.py.bak new file mode 100644 index 0000000..6c55f30 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/CombinationsFileChangedNotification.py.bak @@ -0,0 +1,53 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 06/22/2015 4573 randerso Initial creation (hand generated) +# +## + +import GfeNotification + +class CombinationsFileChangedNotification(GfeNotification.GfeNotification): + + def __init__(self): + super(CombinationsFileChangedNotification, self).__init__() + self.combinationsFileName = None + self.whoChanged = None + + def __str__(self): + msg = "fileName: " + str(self.combinationsFileName) + msg += '\n' + "whoChanged: " + str(self.whoChanged) + return msg + + def getCombinationsFileName(self): + return self.combinationsFileName + + def setCombinationsFileName(self, combinationsFileName): + self.combinationsFileName = combinationsFileName + + def getWhoChanged(self): + return self.whoChanged + + def setWhoChanged(self, whoChanged): + self.whoChanged = whoChanged diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/DBInvChangeNotification.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/DBInvChangeNotification.py index 090fd97..c687e38 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/DBInvChangeNotification.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/DBInvChangeNotification.py @@ -28,7 +28,7 @@ # ## -import GfeNotification +from . import GfeNotification class DBInvChangeNotification(GfeNotification.GfeNotification): diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/DBInvChangeNotification.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/DBInvChangeNotification.py.bak new file mode 100644 index 0000000..090fd97 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/DBInvChangeNotification.py.bak @@ -0,0 +1,56 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# ??/??/???? ???? njensen Modified to add __repr__ +# 06/22/2015 4573 randerso Change to extend GfeNotification +# removed inventory methods +# +## + +import GfeNotification + +class DBInvChangeNotification(GfeNotification.GfeNotification): + + def __init__(self): + super(DBInvChangeNotification, self).__init__() + self.additions = None + self.deletions = None + + def getAdditions(self): + return self.additions + + def setAdditions(self, additions): + self.additions = additions + + def getDeletions(self): + return self.deletions + + def setDeletions(self, deletions): + self.deletions = deletions + + def __str__(self): + msg = 'Additions' + str(self.additions) + '\n' + msg += 'Deletions' + str(self.deletions) + return msg + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GfeNotification.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GfeNotification.py index 4da53d1..dd2fca7 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GfeNotification.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GfeNotification.py @@ -26,9 +26,7 @@ ## import abc -class GfeNotification(object): - __metaclass__ = abc.ABCMeta - +class GfeNotification(object, metaclass=abc.ABCMeta): @abc.abstractmethod def __init__(self): self.siteID = None diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GfeNotification.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GfeNotification.py.bak new file mode 100644 index 0000000..4da53d1 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GfeNotification.py.bak @@ -0,0 +1,48 @@ +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 10/07/2014 3684 randerso Manually updated to add sourceID +# +## +import abc + +class GfeNotification(object): + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def __init__(self): + self.siteID = None + self.sourceID = None + + def getSiteID(self): + return self.siteID + + def setSiteID(self, siteID): + self.siteID = siteID + + + def getSourceID(self): + return self.sourceID + + def setSourceID(self, sourceID): + self.sourceID = sourceID diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridHistoryUpdateNotification.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridHistoryUpdateNotification.py index f989fde..cf8c116 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridHistoryUpdateNotification.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridHistoryUpdateNotification.py @@ -26,7 +26,7 @@ # ## -import GfeNotification +from . import GfeNotification class GridHistoryUpdateNotification(GfeNotification.GfeNotification): diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridHistoryUpdateNotification.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridHistoryUpdateNotification.py.bak new file mode 100644 index 0000000..f989fde --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridHistoryUpdateNotification.py.bak @@ -0,0 +1,61 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 06/22/2015 4573 randerso Initial creation (hand generated) +# +## + +import GfeNotification + +class GridHistoryUpdateNotification(GfeNotification.GfeNotification): + + def __init__(self): + super(GridHistoryUpdateNotification, self).__init__() + self.parmId = None + self.workstationID = None + self.histories = None + + def getParmId(self): + return self.parmId + + def setParmId(self, parmId): + self.parmId = parmId + + def getWorkstationID(self): + return self.workstationID + + def setWorkstationID(self, workstationID): + self.workstationID = workstationID + + def getHistories(self): + return self.histories + + def setHistories(self, histories): + self.histories = histories + + def __str__(self): + msg = "ParmID: " + str(self.parmId) + msg += '\n' + "Histories: " + str(self.histories) + return msg + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridUpdateNotification.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridUpdateNotification.py index 2bc1f16..9be3e40 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridUpdateNotification.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridUpdateNotification.py @@ -27,7 +27,7 @@ # ## -import GfeNotification +from . import GfeNotification class GridUpdateNotification(GfeNotification.GfeNotification): diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridUpdateNotification.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridUpdateNotification.py.bak new file mode 100644 index 0000000..2bc1f16 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridUpdateNotification.py.bak @@ -0,0 +1,70 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# ??/??/???? ???? njensen Modified to add __repr__ +# 06/22/2015 4573 randerso Change to extend GfeNotification +# +## + +import GfeNotification + +class GridUpdateNotification(GfeNotification.GfeNotification): + + def __init__(self): + super(GridUpdateNotification, self).__init__() + self.parmId = None + self.replacementTimeRange = None + self.workstationID = None + self.histories = None + + def getParmId(self): + return self.parmId + + def setParmId(self, parmId): + self.parmId = parmId + + def getReplacementTimeRange(self): + return self.replacementTimeRange + + def setReplacementTimeRange(self, replacementTimeRange): + self.replacementTimeRange = replacementTimeRange + + def getWorkstationID(self): + return self.workstationID + + def setWorkstationID(self, workstationID): + self.workstationID = workstationID + + def getHistories(self): + return self.histories + + def setHistories(self, histories): + self.histories = histories + + def __str__(self): + msg = "ParmID: " + str(self.parmId) + msg += '\n' + "Replacement TimeRange: " + str(self.replacementTimeRange) + msg += '\n' + "Histories: " + str(self.histories) + return msg + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/LockNotification.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/LockNotification.py index a86a507..454225b 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/LockNotification.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/LockNotification.py @@ -27,7 +27,7 @@ # ## -import GfeNotification +from . import GfeNotification class LockNotification(GfeNotification.GfeNotification): diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/LockNotification.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/LockNotification.py.bak new file mode 100644 index 0000000..a86a507 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/LockNotification.py.bak @@ -0,0 +1,46 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# ??/??/???? ???? njensen Modified to add __repr__ +# 06/22/2015 4573 randerso Change to extend GfeNotification +# +## + +import GfeNotification + +class LockNotification(GfeNotification.GfeNotification): + + def __init__(self): + super(LockNotification, self).__init__() + self.lockTable = None + + def getLockTable(self): + return self.lockTable + + def setLockTable(self, lockTable): + self.lockTable = lockTable + + def __str__(self): + return str(self.lockTable) + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/ServiceBackupJobStatusNotification.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/ServiceBackupJobStatusNotification.py index 0081481..20d15b3 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/ServiceBackupJobStatusNotification.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/ServiceBackupJobStatusNotification.py @@ -26,7 +26,7 @@ # ## -import GfeNotification +from . import GfeNotification class ServiceBackupJobStatusNotification(GfeNotification.GfeNotification): diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/ServiceBackupJobStatusNotification.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/ServiceBackupJobStatusNotification.py.bak new file mode 100644 index 0000000..0081481 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/ServiceBackupJobStatusNotification.py.bak @@ -0,0 +1,53 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 06/22/2015 4573 randerso Initial creation (hand generated) +# +## + +import GfeNotification + +class ServiceBackupJobStatusNotification(GfeNotification.GfeNotification): + + def __init__(self): + super(ServiceBackupJobStatusNotification, self).__init__() + self.name = None + self.state = "UNKNOWN" + + def __str__(self): + msg = "name: " + str(self.name) + msg += '\n' + "state: " + str(self.state) + return msg + + def getName(self): + return self.name + + def setName(self, name): + self.name = name + + def getState(self): + return self.state + + def setState(self, state): + self.state = state diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/UserMessageNotification.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/UserMessageNotification.py index 06ba5cd..52043af 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/UserMessageNotification.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/UserMessageNotification.py @@ -26,7 +26,7 @@ # ## -import GfeNotification +from . import GfeNotification class UserMessageNotification(GfeNotification.GfeNotification): diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/UserMessageNotification.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/UserMessageNotification.py.bak new file mode 100644 index 0000000..06ba5cd --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/UserMessageNotification.py.bak @@ -0,0 +1,62 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 06/22/2015 4573 randerso Change to extend GfeNotification +# +## + +import GfeNotification + +class UserMessageNotification(GfeNotification.GfeNotification): + + def __init__(self): + super(UserMessageNotification, self).__init__() + self.category = None + self.priority = None + self.message = None + + def getCategory(self): + return self.category + + def setCategory(self, category): + self.category = category + + def getPriority(self): + return self.priority + + def setPriority(self, priority): + self.priority = priority + + def getMessage(self): + return self.message + + def setMessage(self, message): + self.message = message + + def __str__(self): + msg = 'Message: ' + str(self.message) + '\n' + msg += 'Priority: ' + str(self.priority) + '\n' + msg += 'Category: ' + str(self.category) + '\n' + return msg + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/__init__.py index f58c70b..9cac95d 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/__init__.py @@ -31,12 +31,12 @@ __all__ = [ 'UserMessageNotification' ] -from CombinationsFileChangedNotification import CombinationsFileChangedNotification -from DBInvChangeNotification import DBInvChangeNotification -from GfeNotification import GfeNotification -from GridHistoryUpdateNotification import GridHistoryUpdateNotification -from GridUpdateNotification import GridUpdateNotification -from LockNotification import LockNotification -from ServiceBackupJobStatusNotification import ServiceBackupJobStatusNotification -from UserMessageNotification import UserMessageNotification +from .CombinationsFileChangedNotification import CombinationsFileChangedNotification +from .DBInvChangeNotification import DBInvChangeNotification +from .GfeNotification import GfeNotification +from .GridHistoryUpdateNotification import GridHistoryUpdateNotification +from .GridUpdateNotification import GridUpdateNotification +from .LockNotification import LockNotification +from .ServiceBackupJobStatusNotification import ServiceBackupJobStatusNotification +from .UserMessageNotification import UserMessageNotification diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/__init__.py.bak new file mode 100644 index 0000000..f58c70b --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/__init__.py.bak @@ -0,0 +1,42 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'CombinationsFileChangedNotification', + 'DBInvChangeNotification', + 'GfeNotification', + 'GridHistoryUpdateNotification', + 'GridUpdateNotification', + 'LockNotification', + 'ServiceBackupJobStatusNotification', + 'UserMessageNotification' + ] + +from CombinationsFileChangedNotification import CombinationsFileChangedNotification +from DBInvChangeNotification import DBInvChangeNotification +from GfeNotification import GfeNotification +from GridHistoryUpdateNotification import GridHistoryUpdateNotification +from GridUpdateNotification import GridUpdateNotification +from LockNotification import LockNotification +from ServiceBackupJobStatusNotification import ServiceBackupJobStatusNotification +from UserMessageNotification import UserMessageNotification + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/request/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/request/__init__.py index aca4b9d..d710e66 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/request/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/request/__init__.py @@ -27,8 +27,8 @@ __all__ = [ 'LockTableRequest' ] -from CommitGridRequest import CommitGridRequest -from GetGridRequest import GetGridRequest -from LockRequest import LockRequest -from LockTableRequest import LockTableRequest +from .CommitGridRequest import CommitGridRequest +from .GetGridRequest import GetGridRequest +from .LockRequest import LockRequest +from .LockTableRequest import LockTableRequest diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/request/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/request/__init__.py.bak new file mode 100644 index 0000000..aca4b9d --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/request/__init__.py.bak @@ -0,0 +1,34 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'CommitGridRequest', + 'GetGridRequest', + 'LockRequest', + 'LockTableRequest' + ] + +from CommitGridRequest import CommitGridRequest +from GetGridRequest import GetGridRequest +from LockRequest import LockRequest +from LockTableRequest import LockTableRequest + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/AbstractGridSlice.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/AbstractGridSlice.py index d1bb11b..7faae2b 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/AbstractGridSlice.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/AbstractGridSlice.py @@ -21,9 +21,7 @@ import abc -class AbstractGridSlice(object): - __metaclass__ = abc.ABCMeta - +class AbstractGridSlice(object, metaclass=abc.ABCMeta): @abc.abstractmethod def __init__(self): self.validTime = None diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/AbstractGridSlice.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/AbstractGridSlice.py.bak new file mode 100644 index 0000000..d1bb11b --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/AbstractGridSlice.py.bak @@ -0,0 +1,53 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +import abc + + +class AbstractGridSlice(object): + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def __init__(self): + self.validTime = None + self.gridParmInfo = None + self.gridDataHistory = None + + @abc.abstractmethod + def getNumPyGrid(self): + raise NotImplementedError + + def getValidTime(self): + return self.validTime + + def setValidTime(self, validTime): + self.validTime = validTime + + def getGridParmInfo(self): + return self.gridParmInfo + + def setGridParmInfo(self, gridParmInfo): + self.gridParmInfo = gridParmInfo + + def getGridDataHistory(self): + return self.gridDataHistory + + def setGridDataHistory(self, gridDataHistory): + self.gridDataHistory = gridDataHistory \ No newline at end of file diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/__init__.py index c2140d8..f3430ba 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/__init__.py @@ -28,9 +28,9 @@ __all__ = [ 'WeatherGridSlice' ] -from AbstractGridSlice import AbstractGridSlice -from DiscreteGridSlice import DiscreteGridSlice -from ScalarGridSlice import ScalarGridSlice -from VectorGridSlice import VectorGridSlice -from WeatherGridSlice import WeatherGridSlice +from .AbstractGridSlice import AbstractGridSlice +from .DiscreteGridSlice import DiscreteGridSlice +from .ScalarGridSlice import ScalarGridSlice +from .VectorGridSlice import VectorGridSlice +from .WeatherGridSlice import WeatherGridSlice diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/__init__.py.bak new file mode 100644 index 0000000..c2140d8 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/__init__.py.bak @@ -0,0 +1,36 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'AbstractGridSlice', + 'DiscreteGridSlice', + 'ScalarGridSlice', + 'VectorGridSlice', + 'WeatherGridSlice' + ] + +from AbstractGridSlice import AbstractGridSlice +from DiscreteGridSlice import DiscreteGridSlice +from ScalarGridSlice import ScalarGridSlice +from VectorGridSlice import VectorGridSlice +from WeatherGridSlice import WeatherGridSlice + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/svcbu/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/svcbu/__init__.py index 5413785..f2af1fc 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/svcbu/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/svcbu/__init__.py @@ -30,4 +30,4 @@ __all__ = [ 'JobProgress', ] -from JobProgress import JobProgress +from .JobProgress import JobProgress diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/svcbu/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/svcbu/__init__.py.bak new file mode 100644 index 0000000..5413785 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/svcbu/__init__.py.bak @@ -0,0 +1,33 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 06/22/2015 4573 randerso Initial creation (hand generated) +# +## + +__all__ = [ + 'JobProgress', + ] + +from JobProgress import JobProgress diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/weather/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/weather/__init__.py index b241dd9..9efb235 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/weather/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/weather/__init__.py @@ -25,6 +25,6 @@ __all__ = [ 'WeatherSubKey' ] -from WeatherKey import WeatherKey -from WeatherSubKey import WeatherSubKey +from .WeatherKey import WeatherKey +from .WeatherSubKey import WeatherSubKey diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/weather/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/weather/__init__.py.bak new file mode 100644 index 0000000..b241dd9 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/weather/__init__.py.bak @@ -0,0 +1,30 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'WeatherKey', + 'WeatherSubKey' + ] + +from WeatherKey import WeatherKey +from WeatherSubKey import WeatherSubKey + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grid/request/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grid/request/__init__.py index dcbe795..dcb199f 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grid/request/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grid/request/__init__.py @@ -24,5 +24,5 @@ __all__ = [ 'DeleteAllGridDataRequest' ] -from DeleteAllGridDataRequest import DeleteAllGridDataRequest +from .DeleteAllGridDataRequest import DeleteAllGridDataRequest diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grid/request/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grid/request/__init__.py.bak new file mode 100644 index 0000000..dcbe795 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/grid/request/__init__.py.bak @@ -0,0 +1,28 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'DeleteAllGridDataRequest' + ] + +from DeleteAllGridDataRequest import DeleteAllGridDataRequest + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py index e5b56c0..14b658f 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py @@ -45,7 +45,7 @@ INVALID_VALUE = numpy.float64(-999999) class Level(object): def __init__(self, levelString=None): - self.id = 0L + self.id = 0 self.identifier = None self.masterLevel = None self.levelonevalue = INVALID_VALUE diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py.bak new file mode 100644 index 0000000..e5b56c0 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py.bak @@ -0,0 +1,205 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated against equivalent DynamicSerialize Java class +# and then modified post-generation to add additional features to better +# match Java implementation. +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 05/29/13 2023 dgilling Initial Creation. +# 02/12/14 2672 bsteffen Allow String constructor to parse floats. +# 06/29/15 4480 dgilling Implement __hash__, __eq__, +# __str__ and rich comparison operators. +# + + +import numpy +import re + +from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.level import MasterLevel + + +LEVEL_NAMING_REGEX = re.compile("^(\d*(?:\.\d*)?)(?:_(\d*(?:\.\d*)?))?([a-zA-Z]+)$") +INVALID_VALUE = numpy.float64(-999999) + +class Level(object): + + def __init__(self, levelString=None): + self.id = 0L + self.identifier = None + self.masterLevel = None + self.levelonevalue = INVALID_VALUE + self.leveltwovalue = INVALID_VALUE + + if levelString is not None: + matcher = LEVEL_NAMING_REGEX.match(str(levelString)) + if matcher is not None: + self.levelonevalue = numpy.float64(matcher.group(1)) + self.masterLevel = MasterLevel.MasterLevel(matcher.group(3)) + levelTwo = matcher.group(2) + if levelTwo: + self.leveltwovalue = numpy.float64(levelTwo) + + def __hash__(self): + # XOR-ing the 3 items in a tuple ensures that order of the + # values matters + hashCode = hash(self.masterLevel) ^ hash(self.levelonevalue) ^ hash(self.leveltwovalue) + hashCode ^= hash((self.masterLevel, self.levelonevalue, self.leveltwovalue)) + return hashCode + + def __eq__(self, other): + if type(self) != type(other): + return False + else: + return (self.masterLevel, self.levelonevalue, self.leveltwovalue) == \ + (other.masterLevel, other.levelonevalue, other.leveltwovalue) + + def __ne__(self, other): + return not self.__eq__(other) + + def __lt__(self, other): + if type(self) != type(other): + return NotImplemented + elif self.masterLevel.getName() != other.masterLevel.getName(): + return NotImplemented + + myLevel1 = self.levelonevalue + myLevel2 = self.leveltwovalue + otherLevel1 = other.levelonevalue + otherLevel2 = other.leveltwovalue + if myLevel1 == INVALID_VALUE and myLevel2 != INVALID_VALUE: + myLevel1 = myLevel2 + myLevel2 = INVALID_VALUE + if otherLevel1 == INVALID_VALUE and otherLevel2 != INVALID_VALUE: + otherLevel1 = otherLevel2 + otherLevel2 = INVALID_VALUE + + # We default to descending order to make sorting levels from the DAF easier + compareType = self.masterLevel.getType() if self.masterLevel.getType() else "DEC" + if myLevel1 != INVALID_VALUE and otherLevel1 != INVALID_VALUE: + level1Cmp = self.__compareLevelValues(compareType, myLevel1, otherLevel1) + if level1Cmp == -1: + if myLevel2 != INVALID_VALUE and otherLevel2 != INVALID_VALUE: + level2Cmp = self.__compareLevelValues(compareType, myLevel2, otherLevel2) + return level2Cmp == -1 + elif myLevel2 != INVALID_VALUE: + level2Cmp = self.__compareLevelValues(compareType, myLevel2, otherLevel1) + return level2Cmp == -1 + else: + return True + return False + + def __le__(self, other): + if type(self) != type(other): + return NotImplemented + elif self.masterLevel.getName() != other.masterLevel.getName(): + return NotImplemented + + return self.__lt__(other) or self.__eq__(other) + + def __gt__(self, other): + if type(self) != type(other): + return NotImplemented + elif self.masterLevel.getName() != other.masterLevel.getName(): + return NotImplemented + + myLevel1 = self.levelonevalue + myLevel2 = self.leveltwovalue + otherLevel1 = other.levelonevalue + otherLevel2 = other.leveltwovalue + if myLevel1 == INVALID_VALUE and myLevel2 != INVALID_VALUE: + myLevel1 = myLevel2 + myLevel2 = INVALID_VALUE + if otherLevel1 == INVALID_VALUE and otherLevel2 != INVALID_VALUE: + otherLevel1 = otherLevel2 + otherLevel2 = INVALID_VALUE + + # We default to descending order to make sorting levels from the DAF easier + compareType = self.masterLevel.getType() if self.masterLevel.getType() else "DEC" + if myLevel1 != INVALID_VALUE and otherLevel1 != INVALID_VALUE: + level1Cmp = self.__compareLevelValues(compareType, myLevel1, otherLevel1) + if level1Cmp == 1: + if myLevel2 != INVALID_VALUE and otherLevel2 != INVALID_VALUE: + level2Cmp = self.__compareLevelValues(compareType, myLevel2, otherLevel2) + return level2Cmp == 1 + elif otherLevel2 != INVALID_VALUE: + level2Cmp = self.__compareLevelValues(compareType, myLevel1, otherLevel2) + return level2Cmp == 1 + else: + return True + return False + + def __ge__(self, other): + if type(self) != type(other): + return NotImplemented + elif self.masterLevel.getName() != other.masterLevel.getName(): + return NotImplemented + + return self.__gt__(other) or self.__eq__(other) + + def __compareLevelValues(self, compareType, val1, val2): + returnVal = 0 + if val1 < val2: + returnVal = -1 if compareType == 'INC' else 1 + elif val2 < val1: + returnVal = 1 if compareType == 'INC' else -1 + return returnVal + + def __str__(self): + retVal = "" + if INVALID_VALUE != self.levelonevalue: + retVal += str(self.levelonevalue) + if INVALID_VALUE != self.leveltwovalue: + retVal += "_" + str(self.leveltwovalue) + retVal += str(self.masterLevel.getName()) + return retVal + + def getId(self): + return self.id + + def setId(self, id): + self.id = id + + def getMasterLevel(self): + return self.masterLevel + + def setMasterLevel(self, masterLevel): + self.masterLevel = masterLevel + + def getLevelonevalue(self): + return self.levelonevalue + + def setLevelonevalue(self, levelonevalue): + self.levelonevalue = numpy.float64(levelonevalue) + + def getLeveltwovalue(self): + return self.leveltwovalue + + def setLeveltwovalue(self, leveltwovalue): + self.leveltwovalue = numpy.float64(leveltwovalue) + + def getIdentifier(self): + return self.identifier + + def setIdentifier(self, identifier): + self.identifier = identifier diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/__init__.py index 9e5a9fb..97b4729 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/__init__.py @@ -25,6 +25,6 @@ __all__ = [ 'MasterLevel' ] -from Level import Level -from MasterLevel import MasterLevel +from .Level import Level +from .MasterLevel import MasterLevel diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/__init__.py.bak new file mode 100644 index 0000000..9e5a9fb --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/__init__.py.bak @@ -0,0 +1,30 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'Level', + 'MasterLevel' + ] + +from Level import Level +from MasterLevel import MasterLevel + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/message/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/message/__init__.py index 95d6060..cf5a62b 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/message/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/message/__init__.py @@ -24,5 +24,5 @@ __all__ = [ 'DataURINotificationMessage' ] -from DataURINotificationMessage import DataURINotificationMessage +from .DataURINotificationMessage import DataURINotificationMessage diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/message/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/message/__init__.py.bak new file mode 100644 index 0000000..95d6060 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/message/__init__.py.bak @@ -0,0 +1,28 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'DataURINotificationMessage' + ] + +from DataURINotificationMessage import DataURINotificationMessage + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/request/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/request/__init__.py index e8c9e13..0231869 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/request/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/request/__init__.py @@ -24,5 +24,5 @@ __all__ = [ 'GetRadarDataRecordRequest' ] -from GetRadarDataRecordRequest import GetRadarDataRecordRequest +from .GetRadarDataRecordRequest import GetRadarDataRecordRequest diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/request/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/request/__init__.py.bak new file mode 100644 index 0000000..e8c9e13 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/request/__init__.py.bak @@ -0,0 +1,28 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'GetRadarDataRecordRequest' + ] + +from GetRadarDataRecordRequest import GetRadarDataRecordRequest + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/response/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/response/__init__.py index 914b29b..54c07d1 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/response/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/response/__init__.py @@ -25,6 +25,6 @@ __all__ = [ 'RadarDataRecord' ] -from GetRadarDataRecordResponse import GetRadarDataRecordResponse -from RadarDataRecord import RadarDataRecord +from .GetRadarDataRecordResponse import GetRadarDataRecordResponse +from .RadarDataRecord import RadarDataRecord diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/response/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/response/__init__.py.bak new file mode 100644 index 0000000..914b29b --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/radar/response/__init__.py.bak @@ -0,0 +1,30 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'GetRadarDataRecordResponse', + 'RadarDataRecord' + ] + +from GetRadarDataRecordResponse import GetRadarDataRecordResponse +from RadarDataRecord import RadarDataRecord + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/text/dbsrv/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/text/dbsrv/__init__.py index c9568bf..2f94fc0 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/text/dbsrv/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/text/dbsrv/__init__.py @@ -24,5 +24,5 @@ __all__ = [ 'TextDBRequest' ] -from TextDBRequest import TextDBRequest +from .TextDBRequest import TextDBRequest diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/text/dbsrv/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/text/dbsrv/__init__.py.bak new file mode 100644 index 0000000..c9568bf --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/text/dbsrv/__init__.py.bak @@ -0,0 +1,28 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'TextDBRequest' + ] + +from TextDBRequest import TextDBRequest + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/text/request/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/text/request/__init__.py index 93b51c5..7bf5ac4 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/text/request/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/text/request/__init__.py @@ -24,5 +24,5 @@ __all__ = [ 'SubscriptionRequest' ] -from SubscriptionRequest import SubscriptionRequest +from .SubscriptionRequest import SubscriptionRequest diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/text/request/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/text/request/__init__.py.bak new file mode 100644 index 0000000..93b51c5 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/text/request/__init__.py.bak @@ -0,0 +1,28 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'SubscriptionRequest' + ] + +from SubscriptionRequest import SubscriptionRequest + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/datastorage/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/datastorage/__init__.py index 5d2f79c..78a3093 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/datastorage/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/datastorage/__init__.py @@ -40,6 +40,6 @@ __all__ = [ 'StorageStatus', ] -from Request import Request -from StorageProperties import StorageProperties -from StorageStatus import StorageStatus +from .Request import Request +from .StorageProperties import StorageProperties +from .StorageStatus import StorageStatus diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/datastorage/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/datastorage/__init__.py.bak new file mode 100644 index 0000000..5d2f79c --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/datastorage/__init__.py.bak @@ -0,0 +1,45 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + + +# +# Package definition for com.raytheon.uf.common.datastorage +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 08/31/10 njensen Initial Creation. +# +# +# + + +__all__ = [ + 'records', + 'Request', + 'StorageProperties', + 'StorageStatus', + ] + +from Request import Request +from StorageProperties import StorageProperties +from StorageStatus import StorageStatus diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/datastorage/records/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/datastorage/records/__init__.py index 9fa7b23..1798841 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/datastorage/records/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/datastorage/records/__init__.py @@ -43,11 +43,11 @@ __all__ = [ 'StringDataRecord' ] -from ByteDataRecord import ByteDataRecord -from DoubleDataRecord import DoubleDataRecord -from FloatDataRecord import FloatDataRecord -from IntegerDataRecord import IntegerDataRecord -from LongDataRecord import LongDataRecord -from ShortDataRecord import ShortDataRecord -from StringDataRecord import StringDataRecord +from .ByteDataRecord import ByteDataRecord +from .DoubleDataRecord import DoubleDataRecord +from .FloatDataRecord import FloatDataRecord +from .IntegerDataRecord import IntegerDataRecord +from .LongDataRecord import LongDataRecord +from .ShortDataRecord import ShortDataRecord +from .StringDataRecord import StringDataRecord diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/datastorage/records/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/datastorage/records/__init__.py.bak new file mode 100644 index 0000000..9fa7b23 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/datastorage/records/__init__.py.bak @@ -0,0 +1,53 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# +# Package definition for com.raytheon.uf.common.datastorage.records +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 08/31/10 njensen Initial Creation. +# Apr 24, 2015 4425 nabowle Add DoubleDataRecord +# +# +# + + +__all__ = [ + 'ByteDataRecord', + 'DoubleDataRecord', + 'FloatDataRecord', + 'IntegerDataRecord', + 'LongDataRecord', + 'ShortDataRecord', + 'StringDataRecord' + ] + +from ByteDataRecord import ByteDataRecord +from DoubleDataRecord import DoubleDataRecord +from FloatDataRecord import FloatDataRecord +from IntegerDataRecord import IntegerDataRecord +from LongDataRecord import LongDataRecord +from ShortDataRecord import ShortDataRecord +from StringDataRecord import StringDataRecord + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/LocalizationLevel.py b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/LocalizationLevel.py index f8cd2af..7731873 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/LocalizationLevel.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/LocalizationLevel.py @@ -43,7 +43,7 @@ knownLevels = {"BASE": {"text" : "BASE", class LocalizationLevel(object): def __init__(self, level, order=750, systemLevel=False): - if knownLevels.has_key(level.upper()): + if level.upper() in knownLevels: self.text = level.upper() self.order = knownLevels[self.text]["order"] self.systemLevel = knownLevels[self.text]["systemLevel"] diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/LocalizationLevel.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/LocalizationLevel.py.bak new file mode 100644 index 0000000..f8cd2af --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/LocalizationLevel.py.bak @@ -0,0 +1,75 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +knownLevels = {"BASE": {"text" : "BASE", + "order" : 0, + "systemLevel" : True, + }, + "CONFIGURED": {"text" : "CONFIGURED", + "order" : 250, + "systemLevel" : True, + }, + "SITE": {"text" : "SITE", + "order" : 500, + "systemLevel" : False, + }, + "USER": {"text" : "USER", + "order" : 1000, + "systemLevel" : False, + }, + "UNKNOWN": {"text" : "UNKNOWN", + "order" : -1, + } + } + + +class LocalizationLevel(object): + + def __init__(self, level, order=750, systemLevel=False): + if knownLevels.has_key(level.upper()): + self.text = level.upper() + self.order = knownLevels[self.text]["order"] + self.systemLevel = knownLevels[self.text]["systemLevel"] + else: + self.text = level.upper() + self.order = int(order) + self.systemLevel = systemLevel + + def getText(self): + return self.text + + def setText(self, text): + self.text = text + + def getOrder(self): + return self.order + + def setOrder(self, order): + self.order = int(order) + + def isSystemLevel(self): + return self.systemLevel + + def __str__(self): + return self.__repr__() + + def __repr__(self): + return str(self.text) + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/__init__.py index d2f66b4..3a13605 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/__init__.py @@ -28,7 +28,7 @@ __all__ = [ 'stream' ] -from LocalizationContext import LocalizationContext -from LocalizationLevel import LocalizationLevel -from LocalizationType import LocalizationType +from .LocalizationContext import LocalizationContext +from .LocalizationLevel import LocalizationLevel +from .LocalizationType import LocalizationType diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/__init__.py.bak new file mode 100644 index 0000000..d2f66b4 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/__init__.py.bak @@ -0,0 +1,34 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'LocalizationContext', + 'LocalizationLevel', + 'LocalizationType', + 'msgs', + 'stream' + ] + +from LocalizationContext import LocalizationContext +from LocalizationLevel import LocalizationLevel +from LocalizationType import LocalizationType + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/msgs/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/msgs/__init__.py index 16698ec..e52d13a 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/msgs/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/msgs/__init__.py @@ -31,12 +31,12 @@ __all__ = [ 'UtilityResponseMessage' ] -from DeleteUtilityCommand import DeleteUtilityCommand -from DeleteUtilityResponse import DeleteUtilityResponse -from ListResponseEntry import ListResponseEntry -from ListUtilityCommand import ListUtilityCommand -from ListUtilityResponse import ListUtilityResponse -from PrivilegedUtilityRequestMessage import PrivilegedUtilityRequestMessage -from UtilityRequestMessage import UtilityRequestMessage -from UtilityResponseMessage import UtilityResponseMessage +from .DeleteUtilityCommand import DeleteUtilityCommand +from .DeleteUtilityResponse import DeleteUtilityResponse +from .ListResponseEntry import ListResponseEntry +from .ListUtilityCommand import ListUtilityCommand +from .ListUtilityResponse import ListUtilityResponse +from .PrivilegedUtilityRequestMessage import PrivilegedUtilityRequestMessage +from .UtilityRequestMessage import UtilityRequestMessage +from .UtilityResponseMessage import UtilityResponseMessage diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/msgs/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/msgs/__init__.py.bak new file mode 100644 index 0000000..16698ec --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/msgs/__init__.py.bak @@ -0,0 +1,42 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'DeleteUtilityCommand', + 'DeleteUtilityResponse', + 'ListResponseEntry', + 'ListUtilityCommand', + 'ListUtilityResponse', + 'PrivilegedUtilityRequestMessage', + 'UtilityRequestMessage', + 'UtilityResponseMessage' + ] + +from DeleteUtilityCommand import DeleteUtilityCommand +from DeleteUtilityResponse import DeleteUtilityResponse +from ListResponseEntry import ListResponseEntry +from ListUtilityCommand import ListUtilityCommand +from ListUtilityResponse import ListUtilityResponse +from PrivilegedUtilityRequestMessage import PrivilegedUtilityRequestMessage +from UtilityRequestMessage import UtilityRequestMessage +from UtilityResponseMessage import UtilityResponseMessage + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/AbstractLocalizationStreamRequest.py b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/AbstractLocalizationStreamRequest.py index 2d5fd3d..58d2fb9 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/AbstractLocalizationStreamRequest.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/AbstractLocalizationStreamRequest.py @@ -24,9 +24,7 @@ import abc import os from dynamicserialize.dstypes.com.raytheon.uf.common.plugin.nwsauth.user import User -class AbstractLocalizationStreamRequest(object): - __metaclass__ = abc.ABCMeta - +class AbstractLocalizationStreamRequest(object, metaclass=abc.ABCMeta): @abc.abstractmethod def __init__(self): self.context = None diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/AbstractLocalizationStreamRequest.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/AbstractLocalizationStreamRequest.py.bak new file mode 100644 index 0000000..2d5fd3d --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/AbstractLocalizationStreamRequest.py.bak @@ -0,0 +1,62 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated against equivalent DynamicSerialize Java class + +import abc +import os +from dynamicserialize.dstypes.com.raytheon.uf.common.plugin.nwsauth.user import User + +class AbstractLocalizationStreamRequest(object): + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def __init__(self): + self.context = None + self.fileName = None + self.myContextName = None + self.user = User() + + def getContext(self): + return self.context + + def setContext(self, context): + self.context = context + + def getFileName(self): + return self.fileName + + def setFileName(self, fileName): + if fileName[0] == os.sep: + fileName = fileName[1:] + self.fileName = fileName + + def getMyContextName(self): + return self.myContextName + + def setMyContextName(self, contextName): + self.myContextName = str(contextName) + + def getUser(self): + return self.user + + def setUser(self, user): + self.user = user + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/__init__.py index adf43bb..6034e57 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/__init__.py @@ -26,7 +26,7 @@ __all__ = [ 'LocalizationStreamPutRequest' ] -from AbstractLocalizationStreamRequest import AbstractLocalizationStreamRequest -from LocalizationStreamGetRequest import LocalizationStreamGetRequest -from LocalizationStreamPutRequest import LocalizationStreamPutRequest +from .AbstractLocalizationStreamRequest import AbstractLocalizationStreamRequest +from .LocalizationStreamGetRequest import LocalizationStreamGetRequest +from .LocalizationStreamPutRequest import LocalizationStreamPutRequest diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/__init__.py.bak new file mode 100644 index 0000000..adf43bb --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/__init__.py.bak @@ -0,0 +1,32 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'AbstractLocalizationStreamRequest', + 'LocalizationStreamGetRequest', + 'LocalizationStreamPutRequest' + ] + +from AbstractLocalizationStreamRequest import AbstractLocalizationStreamRequest +from LocalizationStreamGetRequest import LocalizationStreamGetRequest +from LocalizationStreamPutRequest import LocalizationStreamPutRequest + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/management/request/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/management/request/__init__.py index fe82ea9..7cb4f82 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/management/request/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/management/request/__init__.py @@ -26,6 +26,6 @@ __all__ = [ 'diagnostic' ] -from ChangeContextRequest import ChangeContextRequest -from PassThroughRequest import PassThroughRequest +from .ChangeContextRequest import ChangeContextRequest +from .PassThroughRequest import PassThroughRequest diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/management/request/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/management/request/__init__.py.bak new file mode 100644 index 0000000..fe82ea9 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/management/request/__init__.py.bak @@ -0,0 +1,31 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'ChangeContextRequest', + 'PassThroughRequest', + 'diagnostic' + ] + +from ChangeContextRequest import ChangeContextRequest +from PassThroughRequest import PassThroughRequest + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/management/request/diagnostic/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/management/request/diagnostic/__init__.py index 8a60ea5..2b41204 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/management/request/diagnostic/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/management/request/diagnostic/__init__.py @@ -26,7 +26,7 @@ __all__ = [ 'StatusRequest' ] -from GetClusterMembersRequest import GetClusterMembersRequest -from GetContextsRequest import GetContextsRequest -from StatusRequest import StatusRequest +from .GetClusterMembersRequest import GetClusterMembersRequest +from .GetContextsRequest import GetContextsRequest +from .StatusRequest import StatusRequest diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/management/request/diagnostic/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/management/request/diagnostic/__init__.py.bak new file mode 100644 index 0000000..8a60ea5 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/management/request/diagnostic/__init__.py.bak @@ -0,0 +1,32 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'GetClusterMembersRequest', + 'GetContextsRequest', + 'StatusRequest' + ] + +from GetClusterMembersRequest import GetClusterMembersRequest +from GetContextsRequest import GetContextsRequest +from StatusRequest import StatusRequest + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/management/response/diagnostic/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/management/response/diagnostic/__init__.py index b32f23f..8e2140d 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/management/response/diagnostic/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/management/response/diagnostic/__init__.py @@ -26,7 +26,7 @@ __all__ = [ 'StatusResponse' ] -from ClusterMembersResponse import ClusterMembersResponse -from ContextsResponse import ContextsResponse -from StatusResponse import StatusResponse +from .ClusterMembersResponse import ClusterMembersResponse +from .ContextsResponse import ContextsResponse +from .StatusResponse import StatusResponse diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/management/response/diagnostic/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/management/response/diagnostic/__init__.py.bak new file mode 100644 index 0000000..b32f23f --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/management/response/diagnostic/__init__.py.bak @@ -0,0 +1,32 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'ClusterMembersResponse', + 'ContextsResponse', + 'StatusResponse' + ] + +from ClusterMembersResponse import ClusterMembersResponse +from ContextsResponse import ContextsResponse +from StatusResponse import StatusResponse + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/message/Header.py b/dynamicserialize/dstypes/com/raytheon/uf/common/message/Header.py index 04f3163..43b5de6 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/message/Header.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/message/Header.py @@ -20,7 +20,7 @@ # File auto-generated against equivalent DynamicSerialize Java class -from Property import Property +from .Property import Property class Header(object): @@ -31,7 +31,7 @@ class Header(object): self.properties = properties if multimap is not None: - for k, l in multimap.iteritems(): + for k, l in multimap.items(): for v in l: self.properties.append(Property(k, v)) diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/message/Header.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/message/Header.py.bak new file mode 100644 index 0000000..04f3163 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/message/Header.py.bak @@ -0,0 +1,43 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated against equivalent DynamicSerialize Java class + +from Property import Property + +class Header(object): + + def __init__(self, properties=None, multimap=None): + if properties is None: + self.properties = [] + else: + self.properties = properties + + if multimap is not None: + for k, l in multimap.iteritems(): + for v in l: + self.properties.append(Property(k, v)) + + def getProperties(self): + return self.properties + + def setProperties(self, properties): + self.properties = properties + diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/message/WsId.py b/dynamicserialize/dstypes/com/raytheon/uf/common/message/WsId.py index 15930ea..33627ed 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/message/WsId.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/message/WsId.py @@ -31,7 +31,7 @@ import struct import socket import os import pwd -import thread +import _thread class WsId(object): @@ -50,7 +50,7 @@ class WsId(object): self.pid = os.getpid() - self.threadId = long(thread.get_ident()) + self.threadId = int(_thread.get_ident()) def getNetworkId(self): return self.networkId diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/message/WsId.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/message/WsId.py.bak new file mode 100644 index 0000000..15930ea --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/message/WsId.py.bak @@ -0,0 +1,96 @@ +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. + +# File auto-generated against equivalent DynamicSerialize Java class +# Modified by njensen to add __repr__ +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 04/25/12 545 randerso Repurposed the lockKey field as threadId +# 06/12/13 2099 dgilling Implemented toPrettyString(). +# + +import struct +import socket +import os +import pwd +import thread + +class WsId(object): + + def __init__(self, networkId=None, userName=None, progName=None): + self.networkId = networkId + if networkId is None: + self.networkId = str(struct.unpack('" + + def __hash__(self): + hashCode = hash(self.refTime) ^ hash(self.fcstTime) + if self.validPeriod is not None and self.validPeriod.isValid(): + hashCode ^= hash(self.validPeriod.getStart()) + hashCode ^= hash(self.validPeriod.getEnd()) + hashCode ^= hash(self.levelValue) + return hashCode + + def __eq__(self, other): + if type(self) != type(other): + return False + + if other.getRefTime() is None: + return self.fcstTime == other.fcstTime + + dataTime1 = (self.refTime, self.fcstTime, self.validPeriod, self.levelValue) + dataTime2 = (other.refTime, other.fcstTime, other.validPeriod, other.levelValue) + return dataTime1 == dataTime2 + + def __ne__(self, other): + return not self.__eq__(other) + + def __lt__(self, other): + if type(self) != type(other): + return NotImplemented + + myValidTime = self.getRefTime().getTime() + self.getFcstTime() + otherValidTime = other.getRefTime().getTime() + other.getFcstTime() + if myValidTime < otherValidTime: + return True + + if self.fcstTime < other.fcstTime: + return True + + if self.levelValue < other.levelValue: + return True + + myValidPeriod = self.validPeriod + otherValidPeriod = other.validPeriod + if myValidPeriod != otherValidPeriod: + if myValidPeriod.duration() < otherValidPeriod.duration(): + return True + return myValidPeriod.getStartInMillis() < otherValidPeriod.getStartInMillis() + return False + + def __le__(self, other): + if type(self) != type(other): + return NotImplemented + + return self.__lt__(other) or self.__eq__(other) + + def __gt__(self, other): + if type(self) != type(other): + return NotImplemented + + myValidTime = self.getRefTime().getTime() + self.getFcstTime() + otherValidTime = other.getRefTime().getTime() + other.getFcstTime() + if myValidTime > otherValidTime: + return True + + if self.fcstTime > other.fcstTime: + return True + + if self.levelValue > other.levelValue: + return True + + myValidPeriod = self.validPeriod + otherValidPeriod = other.validPeriod + if myValidPeriod != otherValidPeriod: + if myValidPeriod.duration() > otherValidPeriod.duration(): + return True + return myValidPeriod.getStartInMillis() > otherValidPeriod.getStartInMillis() + return False + + def __ge__(self, other): + if type(self) != type(other): + return NotImplemented + + return self.__gt__(other) or self.__eq__(other) \ No newline at end of file diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/time/TimeRange.py b/dynamicserialize/dstypes/com/raytheon/uf/common/time/TimeRange.py index 329bb74..34b2c52 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/time/TimeRange.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/time/TimeRange.py @@ -80,10 +80,10 @@ class TimeRange(object): return datetime.datetime(*timeArg[:6]) elif isinstance(timeArg, float): # seconds as float, should be avoided due to floating point errors - totalSecs = long(timeArg) + totalSecs = int(timeArg) micros = int((timeArg - totalSecs) * MICROS_IN_SECOND) return self.__convertSecsAndMicros(totalSecs, micros) - elif isinstance(timeArg, (int, long)): + elif isinstance(timeArg, int): # seconds as integer totalSecs = timeArg return self.__convertSecsAndMicros(totalSecs, 0) @@ -114,7 +114,7 @@ class TimeRange(object): return self._getInMillis(self.end) def _getInMillis(self, time): - rval = long(calendar.timegm(time.utctimetuple()) * 1000) + rval = int(calendar.timegm(time.utctimetuple()) * 1000) rval += time.microsecond // 1000 return rval @@ -123,7 +123,7 @@ class TimeRange(object): def duration(self): delta = self.end - self.start - return long(delta.total_seconds()) + return int(delta.total_seconds()) def contains(self, timeArg): if isinstance(timeArg, TimeRange): diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/time/TimeRange.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/time/TimeRange.py.bak new file mode 100644 index 0000000..329bb74 --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/time/TimeRange.py.bak @@ -0,0 +1,161 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated against equivalent DynamicSerialize Java class. Then modified to add functionality +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# ??/??/?? xxxxxxxx Initial Creation. +# 01/22/14 2667 bclement fixed millisecond support +# 02/28/14 2667 bclement constructor can take extra micros for start and end +# 06/24/15 4480 dgilling fix __eq__. +# +# +# + +import calendar +import datetime +import time + +MAX_TIME = 2147483647 +MICROS_IN_SECOND = 1000000 + +class TimeRange(object): + def __init__(self, start=None, end=None, startExtraMicros=None, endExtraMicros=None): + self.start = self.__convertToDateTimeWithExtra(start, startExtraMicros) + self.end = self.__convertToDateTimeWithExtra(end, endExtraMicros) + + def __str__(self): + return self.__repr__() + + def __repr__(self): + return "(" + self.start.strftime("%b %d %y %H:%M:%S %Z") + ", " + self.end.strftime("%b %d %y %H:%M:%S %Z") + ")" + + def __eq__(self, other): + if type(self) != type(other): + return False + + if self.isValid() and other.isValid(): + return self.getStart() == other.getStart() and self.getEnd() == other.getEnd() + elif not self.isValid() and not other.isValid(): + return True + else: + return False + + def __ne__(self, other): + return (not self.__eq__(other)) + + def __convertToDateTimeWithExtra(self, timeArg, extraMicros): + rval = self.__convertToDateTime(timeArg) + if rval is not None and extraMicros is not None: + rval = rval + datetime.timedelta(microseconds=extraMicros) + return rval + + def __convertToDateTime(self, timeArg): + if timeArg is None: + return None + if isinstance(timeArg, datetime.datetime): + return timeArg + elif isinstance(timeArg, time.struct_time): + return datetime.datetime(*timeArg[:6]) + elif isinstance(timeArg, float): + # seconds as float, should be avoided due to floating point errors + totalSecs = long(timeArg) + micros = int((timeArg - totalSecs) * MICROS_IN_SECOND) + return self.__convertSecsAndMicros(totalSecs, micros) + elif isinstance(timeArg, (int, long)): + # seconds as integer + totalSecs = timeArg + return self.__convertSecsAndMicros(totalSecs, 0) + else: + return None + + def __convertSecsAndMicros(self, seconds, micros): + if seconds < MAX_TIME: + rval = datetime.datetime.utcfromtimestamp(seconds) + else: + extraTime = datetime.timedelta(seconds=(seconds - MAX_TIME)) + rval = datetime.datetime.utcfromtimestamp(MAX_TIME) + extraTime + return rval.replace(microsecond=micros) + + def getStart(self): + return self.start.utctimetuple() + + def getStartInMillis(self): + return self._getInMillis(self.start) + + def setStart(self, start, extraMicros=None): + self.start = self.__convertToDateTimeWithExtra(start, extraMicros) + + def getEnd(self): + return self.end.utctimetuple() + + def getEndInMillis(self): + return self._getInMillis(self.end) + + def _getInMillis(self, time): + rval = long(calendar.timegm(time.utctimetuple()) * 1000) + rval += time.microsecond // 1000 + return rval + + def setEnd(self, end, extraMicros=None): + self.end = self.__convertToDateTimeWithExtra(end, extraMicros) + + def duration(self): + delta = self.end - self.start + return long(delta.total_seconds()) + + def contains(self, timeArg): + if isinstance(timeArg, TimeRange): + if self.duration() == 0: + return self.__eq__(timeArg) + elif timeArg.duration() == 0: + return self.contains(timeArg.start) + return (timeArg.start >= self.start and timeArg.end <= self.end) + else: + convTime = self.__convertToDateTime(timeArg) + if type(convTime) is not datetime.datetime: + raise TypeError("Invalid type for argument time specified to TimeRange.contains().") + if self.duration() != 0: + return (convTime >= self.start and convTime < self.end) + return convTime == self.start + + def isValid(self): + return bool(self.start != self.end) + + def overlaps(self, timeRange): + return (timeRange.contains(self.start) or self.contains(timeRange.start)) + + def combineWith(self, timeRange): + if self.isValid() and timeRange.isValid(): + newStart = min(self.start, timeRange.start) + newEnd = max(self.end, timeRange.end) + return TimeRange(newStart, newEnd) + elif self.isValid(): + return self + + return timeRange + + @staticmethod + def allTimes(): + return TimeRange(0, MAX_TIME) diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/time/__init__.py b/dynamicserialize/dstypes/com/raytheon/uf/common/time/__init__.py index a31aacc..5f570f5 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/time/__init__.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/time/__init__.py @@ -25,6 +25,6 @@ __all__ = [ 'TimeRange' ] -from DataTime import DataTime -from TimeRange import TimeRange +from .DataTime import DataTime +from .TimeRange import TimeRange diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/time/__init__.py.bak b/dynamicserialize/dstypes/com/raytheon/uf/common/time/__init__.py.bak new file mode 100644 index 0000000..a31aacc --- /dev/null +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/time/__init__.py.bak @@ -0,0 +1,30 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'DataTime', + 'TimeRange' + ] + +from DataTime import DataTime +from TimeRange import TimeRange + diff --git a/dynamicserialize/dstypes/com/vividsolutions/jts/geom/__init__.py b/dynamicserialize/dstypes/com/vividsolutions/jts/geom/__init__.py index 95449c8..18d2f36 100644 --- a/dynamicserialize/dstypes/com/vividsolutions/jts/geom/__init__.py +++ b/dynamicserialize/dstypes/com/vividsolutions/jts/geom/__init__.py @@ -26,7 +26,7 @@ __all__ = [ 'Geometry' ] -from Coordinate import Coordinate -from Envelope import Envelope -from Geometry import Geometry +from .Coordinate import Coordinate +from .Envelope import Envelope +from .Geometry import Geometry diff --git a/dynamicserialize/dstypes/com/vividsolutions/jts/geom/__init__.py.bak b/dynamicserialize/dstypes/com/vividsolutions/jts/geom/__init__.py.bak new file mode 100644 index 0000000..95449c8 --- /dev/null +++ b/dynamicserialize/dstypes/com/vividsolutions/jts/geom/__init__.py.bak @@ -0,0 +1,32 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'Coordinate', + 'Envelope', + 'Geometry' + ] + +from Coordinate import Coordinate +from Envelope import Envelope +from Geometry import Geometry + diff --git a/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/gempak/request/__init__.py b/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/gempak/request/__init__.py index 615510b..7f426a7 100644 --- a/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/gempak/request/__init__.py +++ b/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/gempak/request/__init__.py @@ -12,11 +12,11 @@ __all__ = [ 'GetGridNavRequest' ] -from GetTimesRequest import GetTimesRequest -from GetStationsRequest import GetStationsRequest -from GetTimesResponse import GetTimesResponse -from Station import Station -from StationDataRequest import StationDataRequest -from GetGridDataRequest import GetGridDataRequest -from GetGridInfoRequest import GetGridInfoRequest -from GetGridNavRequest import GetGridNavRequest +from .GetTimesRequest import GetTimesRequest +from .GetStationsRequest import GetStationsRequest +from .GetTimesResponse import GetTimesResponse +from .Station import Station +from .StationDataRequest import StationDataRequest +from .GetGridDataRequest import GetGridDataRequest +from .GetGridInfoRequest import GetGridInfoRequest +from .GetGridNavRequest import GetGridNavRequest diff --git a/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/gempak/request/__init__.py.bak b/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/gempak/request/__init__.py.bak new file mode 100644 index 0000000..615510b --- /dev/null +++ b/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/gempak/request/__init__.py.bak @@ -0,0 +1,22 @@ + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'GetTimesRequest', + 'GetStationsRequest', + 'GetTimesResponse', + 'Station', + 'StationDataRequest', + 'GetGridDataRequest', + 'GetGridInfoRequest', + 'GetGridNavRequest' + ] + +from GetTimesRequest import GetTimesRequest +from GetStationsRequest import GetStationsRequest +from GetTimesResponse import GetTimesResponse +from Station import Station +from StationDataRequest import StationDataRequest +from GetGridDataRequest import GetGridDataRequest +from GetGridInfoRequest import GetGridInfoRequest +from GetGridNavRequest import GetGridNavRequest diff --git a/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/gpd/query/__init__.py b/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/gpd/query/__init__.py index bfec6fc..6a24ef2 100644 --- a/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/gpd/query/__init__.py +++ b/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/gpd/query/__init__.py @@ -5,4 +5,4 @@ __all__ = [ 'GenericPointDataReqMsg' ] -from GenericPointDataReqMsg import GenericPointDataReqMsg +from .GenericPointDataReqMsg import GenericPointDataReqMsg diff --git a/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/gpd/query/__init__.py.bak b/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/gpd/query/__init__.py.bak new file mode 100644 index 0000000..bfec6fc --- /dev/null +++ b/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/gpd/query/__init__.py.bak @@ -0,0 +1,8 @@ + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'GenericPointDataReqMsg' + ] + +from GenericPointDataReqMsg import GenericPointDataReqMsg diff --git a/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/pgen/__init__.py b/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/pgen/__init__.py index 479ce8a..1bdf45b 100644 --- a/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/pgen/__init__.py +++ b/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/pgen/__init__.py @@ -8,7 +8,7 @@ __all__ = [ 'request' ] -from ActivityInfo import ActivityInfo -from DerivedProduct import DerivedProduct -from ResponseMessageValidate import ResponseMessageValidate +from .ActivityInfo import ActivityInfo +from .DerivedProduct import DerivedProduct +from .ResponseMessageValidate import ResponseMessageValidate diff --git a/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/pgen/__init__.py.bak b/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/pgen/__init__.py.bak new file mode 100644 index 0000000..479ce8a --- /dev/null +++ b/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/pgen/__init__.py.bak @@ -0,0 +1,14 @@ + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'ActivityInfo', + 'DerivedProduct', + 'ResponseMessageValidate', + 'request' + ] + +from ActivityInfo import ActivityInfo +from DerivedProduct import DerivedProduct +from ResponseMessageValidate import ResponseMessageValidate + diff --git a/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/pgen/request/__init__.py b/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/pgen/request/__init__.py index c5c872b..68ac523 100644 --- a/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/pgen/request/__init__.py +++ b/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/pgen/request/__init__.py @@ -7,7 +7,7 @@ __all__ = [ 'StoreDerivedProductRequest' ] -from RetrieveAllProductsRequest import RetrieveAllProductsRequest -from StoreActivityRequest import StoreActivityRequest -from StoreDerivedProductRequest import StoreDerivedProductRequest +from .RetrieveAllProductsRequest import RetrieveAllProductsRequest +from .StoreActivityRequest import StoreActivityRequest +from .StoreDerivedProductRequest import StoreDerivedProductRequest diff --git a/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/pgen/request/__init__.py.bak b/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/pgen/request/__init__.py.bak new file mode 100644 index 0000000..c5c872b --- /dev/null +++ b/dynamicserialize/dstypes/gov/noaa/nws/ncep/common/dataplugin/pgen/request/__init__.py.bak @@ -0,0 +1,13 @@ + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'RetrieveAllProductsRequest', + 'StoreActivityRequest', + 'StoreDerivedProductRequest' + ] + +from RetrieveAllProductsRequest import RetrieveAllProductsRequest +from StoreActivityRequest import StoreActivityRequest +from StoreDerivedProductRequest import StoreDerivedProductRequest + diff --git a/dynamicserialize/dstypes/java/awt/__init__.py b/dynamicserialize/dstypes/java/awt/__init__.py index 1a2a8b5..7fd9f01 100644 --- a/dynamicserialize/dstypes/java/awt/__init__.py +++ b/dynamicserialize/dstypes/java/awt/__init__.py @@ -37,4 +37,4 @@ __all__ = [ 'Point', ] -from Point import Point +from .Point import Point diff --git a/dynamicserialize/dstypes/java/awt/__init__.py.bak b/dynamicserialize/dstypes/java/awt/__init__.py.bak new file mode 100644 index 0000000..1a2a8b5 --- /dev/null +++ b/dynamicserialize/dstypes/java/awt/__init__.py.bak @@ -0,0 +1,40 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + + +# +# Package definition for java.awt +# +# +# SOFTWARE HISTORY +# +# Date Ticket# Engineer Description +# ------------ ---------- ----------- -------------------------- +# 08/31/10 njensen Initial Creation. +# +# +# + + +__all__ = [ + 'Point', + ] + +from Point import Point diff --git a/dynamicserialize/dstypes/java/lang/__init__.py b/dynamicserialize/dstypes/java/lang/__init__.py index ffa213f..47f0e2e 100644 --- a/dynamicserialize/dstypes/java/lang/__init__.py +++ b/dynamicserialize/dstypes/java/lang/__init__.py @@ -24,5 +24,5 @@ __all__ = [ 'StackTraceElement' ] -from StackTraceElement import StackTraceElement +from .StackTraceElement import StackTraceElement diff --git a/dynamicserialize/dstypes/java/lang/__init__.py.bak b/dynamicserialize/dstypes/java/lang/__init__.py.bak new file mode 100644 index 0000000..ffa213f --- /dev/null +++ b/dynamicserialize/dstypes/java/lang/__init__.py.bak @@ -0,0 +1,28 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'StackTraceElement' + ] + +from StackTraceElement import StackTraceElement + diff --git a/dynamicserialize/dstypes/java/sql/__init__.py b/dynamicserialize/dstypes/java/sql/__init__.py index 2c312f6..bec9fe8 100644 --- a/dynamicserialize/dstypes/java/sql/__init__.py +++ b/dynamicserialize/dstypes/java/sql/__init__.py @@ -24,4 +24,4 @@ __all__ = [ 'Timestamp' ] -from Timestamp import Timestamp +from .Timestamp import Timestamp diff --git a/dynamicserialize/dstypes/java/sql/__init__.py.bak b/dynamicserialize/dstypes/java/sql/__init__.py.bak new file mode 100644 index 0000000..2c312f6 --- /dev/null +++ b/dynamicserialize/dstypes/java/sql/__init__.py.bak @@ -0,0 +1,27 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'Timestamp' + ] + +from Timestamp import Timestamp diff --git a/dynamicserialize/dstypes/java/util/__init__.py b/dynamicserialize/dstypes/java/util/__init__.py index 2126103..9068645 100644 --- a/dynamicserialize/dstypes/java/util/__init__.py +++ b/dynamicserialize/dstypes/java/util/__init__.py @@ -27,8 +27,8 @@ __all__ = [ 'GregorianCalendar' ] -from Calendar import Calendar -from Date import Date -from EnumSet import EnumSet -from GregorianCalendar import GregorianCalendar +from .Calendar import Calendar +from .Date import Date +from .EnumSet import EnumSet +from .GregorianCalendar import GregorianCalendar diff --git a/dynamicserialize/dstypes/java/util/__init__.py.bak b/dynamicserialize/dstypes/java/util/__init__.py.bak new file mode 100644 index 0000000..2126103 --- /dev/null +++ b/dynamicserialize/dstypes/java/util/__init__.py.bak @@ -0,0 +1,34 @@ +## +# This software was developed and / or modified by Raytheon Company, +# pursuant to Contract DG133W-05-CQ-1067 with the US Government. +# +# U.S. EXPORT CONTROLLED TECHNICAL DATA +# This software product contains export-restricted data whose +# export/transfer/disclosure is restricted by U.S. law. Dissemination +# to non-U.S. persons whether in the United States or abroad requires +# an export license or other authorization. +# +# Contractor Name: Raytheon Company +# Contractor Address: 6825 Pine Street, Suite 340 +# Mail Stop B8 +# Omaha, NE 68106 +# 402.291.0100 +# +# See the AWIPS II Master Rights File ("Master Rights File.pdf") for +# further licensing information. +## + +# File auto-generated by PythonFileGenerator + +__all__ = [ + 'Calendar', + 'Date', + 'EnumSet', + 'GregorianCalendar' + ] + +from Calendar import Calendar +from Date import Date +from EnumSet import EnumSet +from GregorianCalendar import GregorianCalendar + diff --git a/thrift/TSCons.py b/thrift/TSCons.py index da8d283..d3176ed 100644 --- a/thrift/TSCons.py +++ b/thrift/TSCons.py @@ -31,5 +31,5 @@ def scons_env(env, add=''): def gen_cpp(env, dir, file): scons_env(env) suffixes = ['_types.h', '_types.cpp'] - targets = map(lambda s: 'gen-cpp/' + file + s, suffixes) + targets = ['gen-cpp/' + file + s for s in suffixes] return env.ThriftCpp(targets, dir + file + '.thrift') diff --git a/thrift/TSCons.py.bak b/thrift/TSCons.py.bak new file mode 100644 index 0000000..da8d283 --- /dev/null +++ b/thrift/TSCons.py.bak @@ -0,0 +1,35 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +from os import path +from SCons.Builder import Builder + + +def scons_env(env, add=''): + opath = path.dirname(path.abspath('$TARGET')) + lstr = 'thrift --gen cpp -o ' + opath + ' ' + add + ' $SOURCE' + cppbuild = Builder(action=lstr) + env.Append(BUILDERS={'ThriftCpp': cppbuild}) + + +def gen_cpp(env, dir, file): + scons_env(env) + suffixes = ['_types.h', '_types.cpp'] + targets = map(lambda s: 'gen-cpp/' + file + s, suffixes) + return env.ThriftCpp(targets, dir + file + '.thrift') diff --git a/thrift/TSerialization.py b/thrift/TSerialization.py index 8a58d89..fbbe768 100644 --- a/thrift/TSerialization.py +++ b/thrift/TSerialization.py @@ -17,8 +17,8 @@ # under the License. # -from protocol import TBinaryProtocol -from transport import TTransport +from .protocol import TBinaryProtocol +from .transport import TTransport def serialize(thrift_object, diff --git a/thrift/TSerialization.py.bak b/thrift/TSerialization.py.bak new file mode 100644 index 0000000..8a58d89 --- /dev/null +++ b/thrift/TSerialization.py.bak @@ -0,0 +1,38 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +from protocol import TBinaryProtocol +from transport import TTransport + + +def serialize(thrift_object, + protocol_factory=TBinaryProtocol.TBinaryProtocolFactory()): + transport = TTransport.TMemoryBuffer() + protocol = protocol_factory.getProtocol(transport) + thrift_object.write(protocol) + return transport.getvalue() + + +def deserialize(base, + buf, + protocol_factory=TBinaryProtocol.TBinaryProtocolFactory()): + transport = TTransport.TMemoryBuffer(buf) + protocol = protocol_factory.getProtocol(transport) + base.read(protocol) + return base diff --git a/thrift/protocol/TBase.py b/thrift/protocol/TBase.py index 6cbd5f3..6cd6c28 100644 --- a/thrift/protocol/TBase.py +++ b/thrift/protocol/TBase.py @@ -74,8 +74,8 @@ class TExceptionBase(Exception): # This can't inherit from TBase because of that limitation. __slots__ = [] - __repr__ = TBase.__repr__.im_func - __eq__ = TBase.__eq__.im_func - __ne__ = TBase.__ne__.im_func - read = TBase.read.im_func - write = TBase.write.im_func + __repr__ = TBase.__repr__.__func__ + __eq__ = TBase.__eq__.__func__ + __ne__ = TBase.__ne__.__func__ + read = TBase.read.__func__ + write = TBase.write.__func__ diff --git a/thrift/protocol/TBase.py.bak b/thrift/protocol/TBase.py.bak new file mode 100644 index 0000000..6cbd5f3 --- /dev/null +++ b/thrift/protocol/TBase.py.bak @@ -0,0 +1,81 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +from thrift.Thrift import * +from thrift.protocol import TBinaryProtocol +from thrift.transport import TTransport + +try: + from thrift.protocol import fastbinary +except: + fastbinary = None + + +class TBase(object): + __slots__ = [] + + def __repr__(self): + L = ['%s=%r' % (key, getattr(self, key)) + for key in self.__slots__] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + if not isinstance(other, self.__class__): + return False + for attr in self.__slots__: + my_val = getattr(self, attr) + other_val = getattr(other, attr) + if my_val != other_val: + return False + return True + + def __ne__(self, other): + return not (self == other) + + def read(self, iprot): + if (iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and + isinstance(iprot.trans, TTransport.CReadableTransport) and + self.thrift_spec is not None and + fastbinary is not None): + fastbinary.decode_binary(self, + iprot.trans, + (self.__class__, self.thrift_spec)) + return + iprot.readStruct(self, self.thrift_spec) + + def write(self, oprot): + if (oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and + self.thrift_spec is not None and + fastbinary is not None): + oprot.trans.write( + fastbinary.encode_binary(self, (self.__class__, self.thrift_spec))) + return + oprot.writeStruct(self, self.thrift_spec) + + +class TExceptionBase(Exception): + # old style class so python2.4 can raise exceptions derived from this + # This can't inherit from TBase because of that limitation. + __slots__ = [] + + __repr__ = TBase.__repr__.im_func + __eq__ = TBase.__eq__.im_func + __ne__ = TBase.__ne__.im_func + read = TBase.read.im_func + write = TBase.write.im_func diff --git a/thrift/protocol/TBinaryProtocol.py b/thrift/protocol/TBinaryProtocol.py index 6fdd08c..2af4a2d 100644 --- a/thrift/protocol/TBinaryProtocol.py +++ b/thrift/protocol/TBinaryProtocol.py @@ -17,7 +17,7 @@ # under the License. # -from TProtocol import * +from .TProtocol import * from struct import pack, unpack diff --git a/thrift/protocol/TBinaryProtocol.py.bak b/thrift/protocol/TBinaryProtocol.py.bak new file mode 100644 index 0000000..6fdd08c --- /dev/null +++ b/thrift/protocol/TBinaryProtocol.py.bak @@ -0,0 +1,260 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +from TProtocol import * +from struct import pack, unpack + + +class TBinaryProtocol(TProtocolBase): + """Binary implementation of the Thrift protocol driver.""" + + # NastyHaxx. Python 2.4+ on 32-bit machines forces hex constants to be + # positive, converting this into a long. If we hardcode the int value + # instead it'll stay in 32 bit-land. + + # VERSION_MASK = 0xffff0000 + VERSION_MASK = -65536 + + # VERSION_1 = 0x80010000 + VERSION_1 = -2147418112 + + TYPE_MASK = 0x000000ff + + def __init__(self, trans, strictRead=False, strictWrite=True): + TProtocolBase.__init__(self, trans) + self.strictRead = strictRead + self.strictWrite = strictWrite + + def writeMessageBegin(self, name, type, seqid): + if self.strictWrite: + self.writeI32(TBinaryProtocol.VERSION_1 | type) + self.writeString(name) + self.writeI32(seqid) + else: + self.writeString(name) + self.writeByte(type) + self.writeI32(seqid) + + def writeMessageEnd(self): + pass + + def writeStructBegin(self, name): + pass + + def writeStructEnd(self): + pass + + def writeFieldBegin(self, name, type, id): + self.writeByte(type) + self.writeI16(id) + + def writeFieldEnd(self): + pass + + def writeFieldStop(self): + self.writeByte(TType.STOP) + + def writeMapBegin(self, ktype, vtype, size): + self.writeByte(ktype) + self.writeByte(vtype) + self.writeI32(size) + + def writeMapEnd(self): + pass + + def writeListBegin(self, etype, size): + self.writeByte(etype) + self.writeI32(size) + + def writeListEnd(self): + pass + + def writeSetBegin(self, etype, size): + self.writeByte(etype) + self.writeI32(size) + + def writeSetEnd(self): + pass + + def writeBool(self, bool): + if bool: + self.writeByte(1) + else: + self.writeByte(0) + + def writeByte(self, byte): + buff = pack("!b", byte) + self.trans.write(buff) + + def writeI16(self, i16): + buff = pack("!h", i16) + self.trans.write(buff) + + def writeI32(self, i32): + buff = pack("!i", i32) + self.trans.write(buff) + + def writeI64(self, i64): + buff = pack("!q", i64) + self.trans.write(buff) + + def writeDouble(self, dub): + buff = pack("!d", dub) + self.trans.write(buff) + + def writeString(self, str): + self.writeI32(len(str)) + self.trans.write(str) + + def readMessageBegin(self): + sz = self.readI32() + if sz < 0: + version = sz & TBinaryProtocol.VERSION_MASK + if version != TBinaryProtocol.VERSION_1: + raise TProtocolException( + type=TProtocolException.BAD_VERSION, + message='Bad version in readMessageBegin: %d' % (sz)) + type = sz & TBinaryProtocol.TYPE_MASK + name = self.readString() + seqid = self.readI32() + else: + if self.strictRead: + raise TProtocolException(type=TProtocolException.BAD_VERSION, + message='No protocol version header') + name = self.trans.readAll(sz) + type = self.readByte() + seqid = self.readI32() + return (name, type, seqid) + + def readMessageEnd(self): + pass + + def readStructBegin(self): + pass + + def readStructEnd(self): + pass + + def readFieldBegin(self): + type = self.readByte() + if type == TType.STOP: + return (None, type, 0) + id = self.readI16() + return (None, type, id) + + def readFieldEnd(self): + pass + + def readMapBegin(self): + ktype = self.readByte() + vtype = self.readByte() + size = self.readI32() + return (ktype, vtype, size) + + def readMapEnd(self): + pass + + def readListBegin(self): + etype = self.readByte() + size = self.readI32() + return (etype, size) + + def readListEnd(self): + pass + + def readSetBegin(self): + etype = self.readByte() + size = self.readI32() + return (etype, size) + + def readSetEnd(self): + pass + + def readBool(self): + byte = self.readByte() + if byte == 0: + return False + return True + + def readByte(self): + buff = self.trans.readAll(1) + val, = unpack('!b', buff) + return val + + def readI16(self): + buff = self.trans.readAll(2) + val, = unpack('!h', buff) + return val + + def readI32(self): + buff = self.trans.readAll(4) + val, = unpack('!i', buff) + return val + + def readI64(self): + buff = self.trans.readAll(8) + val, = unpack('!q', buff) + return val + + def readDouble(self): + buff = self.trans.readAll(8) + val, = unpack('!d', buff) + return val + + def readString(self): + len = self.readI32() + str = self.trans.readAll(len) + return str + + +class TBinaryProtocolFactory: + def __init__(self, strictRead=False, strictWrite=True): + self.strictRead = strictRead + self.strictWrite = strictWrite + + def getProtocol(self, trans): + prot = TBinaryProtocol(trans, self.strictRead, self.strictWrite) + return prot + + +class TBinaryProtocolAccelerated(TBinaryProtocol): + """C-Accelerated version of TBinaryProtocol. + + This class does not override any of TBinaryProtocol's methods, + but the generated code recognizes it directly and will call into + our C module to do the encoding, bypassing this object entirely. + We inherit from TBinaryProtocol so that the normal TBinaryProtocol + encoding can happen if the fastbinary module doesn't work for some + reason. (TODO(dreiss): Make this happen sanely in more cases.) + + In order to take advantage of the C module, just use + TBinaryProtocolAccelerated instead of TBinaryProtocol. + + NOTE: This code was contributed by an external developer. + The internal Thrift team has reviewed and tested it, + but we cannot guarantee that it is production-ready. + Please feel free to report bugs and/or success stories + to the public mailing list. + """ + pass + + +class TBinaryProtocolAcceleratedFactory: + def getProtocol(self, trans): + return TBinaryProtocolAccelerated(trans) diff --git a/thrift/protocol/TCompactProtocol.py b/thrift/protocol/TCompactProtocol.py index cdec607..a3385e1 100644 --- a/thrift/protocol/TCompactProtocol.py +++ b/thrift/protocol/TCompactProtocol.py @@ -17,7 +17,7 @@ # under the License. # -from TProtocol import * +from .TProtocol import * from struct import pack, unpack __all__ = ['TCompactProtocol', 'TCompactProtocolFactory'] @@ -106,7 +106,7 @@ CTYPES = {TType.STOP: CompactType.STOP, } TTYPES = {} -for k, v in CTYPES.items(): +for k, v in list(CTYPES.items()): TTYPES[v] = k TTYPES[CompactType.FALSE] = TType.BOOL del k diff --git a/thrift/protocol/TCompactProtocol.py.bak b/thrift/protocol/TCompactProtocol.py.bak new file mode 100644 index 0000000..cdec607 --- /dev/null +++ b/thrift/protocol/TCompactProtocol.py.bak @@ -0,0 +1,403 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +from TProtocol import * +from struct import pack, unpack + +__all__ = ['TCompactProtocol', 'TCompactProtocolFactory'] + +CLEAR = 0 +FIELD_WRITE = 1 +VALUE_WRITE = 2 +CONTAINER_WRITE = 3 +BOOL_WRITE = 4 +FIELD_READ = 5 +CONTAINER_READ = 6 +VALUE_READ = 7 +BOOL_READ = 8 + + +def make_helper(v_from, container): + def helper(func): + def nested(self, *args, **kwargs): + assert self.state in (v_from, container), (self.state, v_from, container) + return func(self, *args, **kwargs) + return nested + return helper +writer = make_helper(VALUE_WRITE, CONTAINER_WRITE) +reader = make_helper(VALUE_READ, CONTAINER_READ) + + +def makeZigZag(n, bits): + return (n << 1) ^ (n >> (bits - 1)) + + +def fromZigZag(n): + return (n >> 1) ^ -(n & 1) + + +def writeVarint(trans, n): + out = [] + while True: + if n & ~0x7f == 0: + out.append(n) + break + else: + out.append((n & 0xff) | 0x80) + n = n >> 7 + trans.write(''.join(map(chr, out))) + + +def readVarint(trans): + result = 0 + shift = 0 + while True: + x = trans.readAll(1) + byte = ord(x) + result |= (byte & 0x7f) << shift + if byte >> 7 == 0: + return result + shift += 7 + + +class CompactType: + STOP = 0x00 + TRUE = 0x01 + FALSE = 0x02 + BYTE = 0x03 + I16 = 0x04 + I32 = 0x05 + I64 = 0x06 + DOUBLE = 0x07 + BINARY = 0x08 + LIST = 0x09 + SET = 0x0A + MAP = 0x0B + STRUCT = 0x0C + +CTYPES = {TType.STOP: CompactType.STOP, + TType.BOOL: CompactType.TRUE, # used for collection + TType.BYTE: CompactType.BYTE, + TType.I16: CompactType.I16, + TType.I32: CompactType.I32, + TType.I64: CompactType.I64, + TType.DOUBLE: CompactType.DOUBLE, + TType.STRING: CompactType.BINARY, + TType.STRUCT: CompactType.STRUCT, + TType.LIST: CompactType.LIST, + TType.SET: CompactType.SET, + TType.MAP: CompactType.MAP + } + +TTYPES = {} +for k, v in CTYPES.items(): + TTYPES[v] = k +TTYPES[CompactType.FALSE] = TType.BOOL +del k +del v + + +class TCompactProtocol(TProtocolBase): + """Compact implementation of the Thrift protocol driver.""" + + PROTOCOL_ID = 0x82 + VERSION = 1 + VERSION_MASK = 0x1f + TYPE_MASK = 0xe0 + TYPE_SHIFT_AMOUNT = 5 + + def __init__(self, trans): + TProtocolBase.__init__(self, trans) + self.state = CLEAR + self.__last_fid = 0 + self.__bool_fid = None + self.__bool_value = None + self.__structs = [] + self.__containers = [] + + def __writeVarint(self, n): + writeVarint(self.trans, n) + + def writeMessageBegin(self, name, type, seqid): + assert self.state == CLEAR + self.__writeUByte(self.PROTOCOL_ID) + self.__writeUByte(self.VERSION | (type << self.TYPE_SHIFT_AMOUNT)) + self.__writeVarint(seqid) + self.__writeString(name) + self.state = VALUE_WRITE + + def writeMessageEnd(self): + assert self.state == VALUE_WRITE + self.state = CLEAR + + def writeStructBegin(self, name): + assert self.state in (CLEAR, CONTAINER_WRITE, VALUE_WRITE), self.state + self.__structs.append((self.state, self.__last_fid)) + self.state = FIELD_WRITE + self.__last_fid = 0 + + def writeStructEnd(self): + assert self.state == FIELD_WRITE + self.state, self.__last_fid = self.__structs.pop() + + def writeFieldStop(self): + self.__writeByte(0) + + def __writeFieldHeader(self, type, fid): + delta = fid - self.__last_fid + if 0 < delta <= 15: + self.__writeUByte(delta << 4 | type) + else: + self.__writeByte(type) + self.__writeI16(fid) + self.__last_fid = fid + + def writeFieldBegin(self, name, type, fid): + assert self.state == FIELD_WRITE, self.state + if type == TType.BOOL: + self.state = BOOL_WRITE + self.__bool_fid = fid + else: + self.state = VALUE_WRITE + self.__writeFieldHeader(CTYPES[type], fid) + + def writeFieldEnd(self): + assert self.state in (VALUE_WRITE, BOOL_WRITE), self.state + self.state = FIELD_WRITE + + def __writeUByte(self, byte): + self.trans.write(pack('!B', byte)) + + def __writeByte(self, byte): + self.trans.write(pack('!b', byte)) + + def __writeI16(self, i16): + self.__writeVarint(makeZigZag(i16, 16)) + + def __writeSize(self, i32): + self.__writeVarint(i32) + + def writeCollectionBegin(self, etype, size): + assert self.state in (VALUE_WRITE, CONTAINER_WRITE), self.state + if size <= 14: + self.__writeUByte(size << 4 | CTYPES[etype]) + else: + self.__writeUByte(0xf0 | CTYPES[etype]) + self.__writeSize(size) + self.__containers.append(self.state) + self.state = CONTAINER_WRITE + writeSetBegin = writeCollectionBegin + writeListBegin = writeCollectionBegin + + def writeMapBegin(self, ktype, vtype, size): + assert self.state in (VALUE_WRITE, CONTAINER_WRITE), self.state + if size == 0: + self.__writeByte(0) + else: + self.__writeSize(size) + self.__writeUByte(CTYPES[ktype] << 4 | CTYPES[vtype]) + self.__containers.append(self.state) + self.state = CONTAINER_WRITE + + def writeCollectionEnd(self): + assert self.state == CONTAINER_WRITE, self.state + self.state = self.__containers.pop() + writeMapEnd = writeCollectionEnd + writeSetEnd = writeCollectionEnd + writeListEnd = writeCollectionEnd + + def writeBool(self, bool): + if self.state == BOOL_WRITE: + if bool: + ctype = CompactType.TRUE + else: + ctype = CompactType.FALSE + self.__writeFieldHeader(ctype, self.__bool_fid) + elif self.state == CONTAINER_WRITE: + if bool: + self.__writeByte(CompactType.TRUE) + else: + self.__writeByte(CompactType.FALSE) + else: + raise AssertionError("Invalid state in compact protocol") + + writeByte = writer(__writeByte) + writeI16 = writer(__writeI16) + + @writer + def writeI32(self, i32): + self.__writeVarint(makeZigZag(i32, 32)) + + @writer + def writeI64(self, i64): + self.__writeVarint(makeZigZag(i64, 64)) + + @writer + def writeDouble(self, dub): + self.trans.write(pack('!d', dub)) + + def __writeString(self, s): + self.__writeSize(len(s)) + self.trans.write(s) + writeString = writer(__writeString) + + def readFieldBegin(self): + assert self.state == FIELD_READ, self.state + type = self.__readUByte() + if type & 0x0f == TType.STOP: + return (None, 0, 0) + delta = type >> 4 + if delta == 0: + fid = self.__readI16() + else: + fid = self.__last_fid + delta + self.__last_fid = fid + type = type & 0x0f + if type == CompactType.TRUE: + self.state = BOOL_READ + self.__bool_value = True + elif type == CompactType.FALSE: + self.state = BOOL_READ + self.__bool_value = False + else: + self.state = VALUE_READ + return (None, self.__getTType(type), fid) + + def readFieldEnd(self): + assert self.state in (VALUE_READ, BOOL_READ), self.state + self.state = FIELD_READ + + def __readUByte(self): + result, = unpack('!B', self.trans.readAll(1)) + return result + + def __readByte(self): + result, = unpack('!b', self.trans.readAll(1)) + return result + + def __readVarint(self): + return readVarint(self.trans) + + def __readZigZag(self): + return fromZigZag(self.__readVarint()) + + def __readSize(self): + result = self.__readVarint() + if result < 0: + raise TException("Length < 0") + return result + + def readMessageBegin(self): + assert self.state == CLEAR + proto_id = self.__readUByte() + if proto_id != self.PROTOCOL_ID: + raise TProtocolException(TProtocolException.BAD_VERSION, + 'Bad protocol id in the message: %d' % proto_id) + ver_type = self.__readUByte() + type = (ver_type & self.TYPE_MASK) >> self.TYPE_SHIFT_AMOUNT + version = ver_type & self.VERSION_MASK + if version != self.VERSION: + raise TProtocolException(TProtocolException.BAD_VERSION, + 'Bad version: %d (expect %d)' % (version, self.VERSION)) + seqid = self.__readVarint() + name = self.__readString() + return (name, type, seqid) + + def readMessageEnd(self): + assert self.state == CLEAR + assert len(self.__structs) == 0 + + def readStructBegin(self): + assert self.state in (CLEAR, CONTAINER_READ, VALUE_READ), self.state + self.__structs.append((self.state, self.__last_fid)) + self.state = FIELD_READ + self.__last_fid = 0 + + def readStructEnd(self): + assert self.state == FIELD_READ + self.state, self.__last_fid = self.__structs.pop() + + def readCollectionBegin(self): + assert self.state in (VALUE_READ, CONTAINER_READ), self.state + size_type = self.__readUByte() + size = size_type >> 4 + type = self.__getTType(size_type) + if size == 15: + size = self.__readSize() + self.__containers.append(self.state) + self.state = CONTAINER_READ + return type, size + readSetBegin = readCollectionBegin + readListBegin = readCollectionBegin + + def readMapBegin(self): + assert self.state in (VALUE_READ, CONTAINER_READ), self.state + size = self.__readSize() + types = 0 + if size > 0: + types = self.__readUByte() + vtype = self.__getTType(types) + ktype = self.__getTType(types >> 4) + self.__containers.append(self.state) + self.state = CONTAINER_READ + return (ktype, vtype, size) + + def readCollectionEnd(self): + assert self.state == CONTAINER_READ, self.state + self.state = self.__containers.pop() + readSetEnd = readCollectionEnd + readListEnd = readCollectionEnd + readMapEnd = readCollectionEnd + + def readBool(self): + if self.state == BOOL_READ: + return self.__bool_value == CompactType.TRUE + elif self.state == CONTAINER_READ: + return self.__readByte() == CompactType.TRUE + else: + raise AssertionError("Invalid state in compact protocol: %d" % + self.state) + + readByte = reader(__readByte) + __readI16 = __readZigZag + readI16 = reader(__readZigZag) + readI32 = reader(__readZigZag) + readI64 = reader(__readZigZag) + + @reader + def readDouble(self): + buff = self.trans.readAll(8) + val, = unpack('!d', buff) + return val + + def __readString(self): + len = self.__readSize() + return self.trans.readAll(len) + readString = reader(__readString) + + def __getTType(self, byte): + return TTYPES[byte & 0x0f] + + +class TCompactProtocolFactory: + def __init__(self): + pass + + def getProtocol(self, trans): + return TCompactProtocol(trans) diff --git a/thrift/protocol/TProtocol.py b/thrift/protocol/TProtocol.py index 5177229..56d323a 100644 --- a/thrift/protocol/TProtocol.py +++ b/thrift/protocol/TProtocol.py @@ -244,13 +244,13 @@ class TProtocolBase: (list_type, list_len) = self.readListBegin() if tspec is None: # list values are simple types - for idx in xrange(list_len): + for idx in range(list_len): results.append(reader()) else: # this is like an inlined readFieldByTType container_reader = self._TTYPE_HANDLERS[list_type][0] val_reader = getattr(self, container_reader) - for idx in xrange(list_len): + for idx in range(list_len): val = val_reader(tspec) results.append(val) self.readListEnd() @@ -264,12 +264,12 @@ class TProtocolBase: (set_type, set_len) = self.readSetBegin() if tspec is None: # set members are simple types - for idx in xrange(set_len): + for idx in range(set_len): results.add(reader()) else: container_reader = self._TTYPE_HANDLERS[set_type][0] val_reader = getattr(self, container_reader) - for idx in xrange(set_len): + for idx in range(set_len): results.add(val_reader(tspec)) self.readSetEnd() return results @@ -290,7 +290,7 @@ class TProtocolBase: key_reader = getattr(self, self._TTYPE_HANDLERS[key_ttype][0]) val_reader = getattr(self, self._TTYPE_HANDLERS[val_ttype][0]) # list values are simple types - for idx in xrange(map_len): + for idx in range(map_len): if key_spec is None: k_val = key_reader() else: @@ -361,7 +361,7 @@ class TProtocolBase: k_writer = getattr(self, ktype_name) v_writer = getattr(self, vtype_name) self.writeMapBegin(k_type, v_type, len(val)) - for m_key, m_val in val.iteritems(): + for m_key, m_val in val.items(): if not k_is_container: k_writer(m_key) else: diff --git a/thrift/protocol/TProtocol.py.bak b/thrift/protocol/TProtocol.py.bak new file mode 100644 index 0000000..5177229 --- /dev/null +++ b/thrift/protocol/TProtocol.py.bak @@ -0,0 +1,406 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +from thrift.Thrift import * + + +class TProtocolException(TException): + """Custom Protocol Exception class""" + + UNKNOWN = 0 + INVALID_DATA = 1 + NEGATIVE_SIZE = 2 + SIZE_LIMIT = 3 + BAD_VERSION = 4 + + def __init__(self, type=UNKNOWN, message=None): + TException.__init__(self, message) + self.type = type + + +class TProtocolBase: + """Base class for Thrift protocol driver.""" + + def __init__(self, trans): + self.trans = trans + + def writeMessageBegin(self, name, type, seqid): + pass + + def writeMessageEnd(self): + pass + + def writeStructBegin(self, name): + pass + + def writeStructEnd(self): + pass + + def writeFieldBegin(self, name, type, id): + pass + + def writeFieldEnd(self): + pass + + def writeFieldStop(self): + pass + + def writeMapBegin(self, ktype, vtype, size): + pass + + def writeMapEnd(self): + pass + + def writeListBegin(self, etype, size): + pass + + def writeListEnd(self): + pass + + def writeSetBegin(self, etype, size): + pass + + def writeSetEnd(self): + pass + + def writeBool(self, bool): + pass + + def writeByte(self, byte): + pass + + def writeI16(self, i16): + pass + + def writeI32(self, i32): + pass + + def writeI64(self, i64): + pass + + def writeDouble(self, dub): + pass + + def writeString(self, str): + pass + + def readMessageBegin(self): + pass + + def readMessageEnd(self): + pass + + def readStructBegin(self): + pass + + def readStructEnd(self): + pass + + def readFieldBegin(self): + pass + + def readFieldEnd(self): + pass + + def readMapBegin(self): + pass + + def readMapEnd(self): + pass + + def readListBegin(self): + pass + + def readListEnd(self): + pass + + def readSetBegin(self): + pass + + def readSetEnd(self): + pass + + def readBool(self): + pass + + def readByte(self): + pass + + def readI16(self): + pass + + def readI32(self): + pass + + def readI64(self): + pass + + def readDouble(self): + pass + + def readString(self): + pass + + def skip(self, type): + if type == TType.STOP: + return + elif type == TType.BOOL: + self.readBool() + elif type == TType.BYTE: + self.readByte() + elif type == TType.I16: + self.readI16() + elif type == TType.I32: + self.readI32() + elif type == TType.I64: + self.readI64() + elif type == TType.DOUBLE: + self.readDouble() + elif type == TType.STRING: + self.readString() + elif type == TType.STRUCT: + name = self.readStructBegin() + while True: + (name, type, id) = self.readFieldBegin() + if type == TType.STOP: + break + self.skip(type) + self.readFieldEnd() + self.readStructEnd() + elif type == TType.MAP: + (ktype, vtype, size) = self.readMapBegin() + for i in range(size): + self.skip(ktype) + self.skip(vtype) + self.readMapEnd() + elif type == TType.SET: + (etype, size) = self.readSetBegin() + for i in range(size): + self.skip(etype) + self.readSetEnd() + elif type == TType.LIST: + (etype, size) = self.readListBegin() + for i in range(size): + self.skip(etype) + self.readListEnd() + + # tuple of: ( 'reader method' name, is_container bool, 'writer_method' name ) + _TTYPE_HANDLERS = ( + (None, None, False), # 0 TType.STOP + (None, None, False), # 1 TType.VOID # TODO: handle void? + ('readBool', 'writeBool', False), # 2 TType.BOOL + ('readByte', 'writeByte', False), # 3 TType.BYTE and I08 + ('readDouble', 'writeDouble', False), # 4 TType.DOUBLE + (None, None, False), # 5 undefined + ('readI16', 'writeI16', False), # 6 TType.I16 + (None, None, False), # 7 undefined + ('readI32', 'writeI32', False), # 8 TType.I32 + (None, None, False), # 9 undefined + ('readI64', 'writeI64', False), # 10 TType.I64 + ('readString', 'writeString', False), # 11 TType.STRING and UTF7 + ('readContainerStruct', 'writeContainerStruct', True), # 12 *.STRUCT + ('readContainerMap', 'writeContainerMap', True), # 13 TType.MAP + ('readContainerSet', 'writeContainerSet', True), # 14 TType.SET + ('readContainerList', 'writeContainerList', True), # 15 TType.LIST + (None, None, False), # 16 TType.UTF8 # TODO: handle utf8 types? + (None, None, False) # 17 TType.UTF16 # TODO: handle utf16 types? + ) + + def readFieldByTType(self, ttype, spec): + try: + (r_handler, w_handler, is_container) = self._TTYPE_HANDLERS[ttype] + except IndexError: + raise TProtocolException(type=TProtocolException.INVALID_DATA, + message='Invalid field type %d' % (ttype)) + if r_handler is None: + raise TProtocolException(type=TProtocolException.INVALID_DATA, + message='Invalid field type %d' % (ttype)) + reader = getattr(self, r_handler) + if not is_container: + return reader() + return reader(spec) + + def readContainerList(self, spec): + results = [] + ttype, tspec = spec[0], spec[1] + r_handler = self._TTYPE_HANDLERS[ttype][0] + reader = getattr(self, r_handler) + (list_type, list_len) = self.readListBegin() + if tspec is None: + # list values are simple types + for idx in xrange(list_len): + results.append(reader()) + else: + # this is like an inlined readFieldByTType + container_reader = self._TTYPE_HANDLERS[list_type][0] + val_reader = getattr(self, container_reader) + for idx in xrange(list_len): + val = val_reader(tspec) + results.append(val) + self.readListEnd() + return results + + def readContainerSet(self, spec): + results = set() + ttype, tspec = spec[0], spec[1] + r_handler = self._TTYPE_HANDLERS[ttype][0] + reader = getattr(self, r_handler) + (set_type, set_len) = self.readSetBegin() + if tspec is None: + # set members are simple types + for idx in xrange(set_len): + results.add(reader()) + else: + container_reader = self._TTYPE_HANDLERS[set_type][0] + val_reader = getattr(self, container_reader) + for idx in xrange(set_len): + results.add(val_reader(tspec)) + self.readSetEnd() + return results + + def readContainerStruct(self, spec): + (obj_class, obj_spec) = spec + obj = obj_class() + obj.read(self) + return obj + + def readContainerMap(self, spec): + results = dict() + key_ttype, key_spec = spec[0], spec[1] + val_ttype, val_spec = spec[2], spec[3] + (map_ktype, map_vtype, map_len) = self.readMapBegin() + # TODO: compare types we just decoded with thrift_spec and + # abort/skip if types disagree + key_reader = getattr(self, self._TTYPE_HANDLERS[key_ttype][0]) + val_reader = getattr(self, self._TTYPE_HANDLERS[val_ttype][0]) + # list values are simple types + for idx in xrange(map_len): + if key_spec is None: + k_val = key_reader() + else: + k_val = self.readFieldByTType(key_ttype, key_spec) + if val_spec is None: + v_val = val_reader() + else: + v_val = self.readFieldByTType(val_ttype, val_spec) + # this raises a TypeError with unhashable keys types + # i.e. this fails: d=dict(); d[[0,1]] = 2 + results[k_val] = v_val + self.readMapEnd() + return results + + def readStruct(self, obj, thrift_spec): + self.readStructBegin() + while True: + (fname, ftype, fid) = self.readFieldBegin() + if ftype == TType.STOP: + break + try: + field = thrift_spec[fid] + except IndexError: + self.skip(ftype) + else: + if field is not None and ftype == field[1]: + fname = field[2] + fspec = field[3] + val = self.readFieldByTType(ftype, fspec) + setattr(obj, fname, val) + else: + self.skip(ftype) + self.readFieldEnd() + self.readStructEnd() + + def writeContainerStruct(self, val, spec): + val.write(self) + + def writeContainerList(self, val, spec): + self.writeListBegin(spec[0], len(val)) + r_handler, w_handler, is_container = self._TTYPE_HANDLERS[spec[0]] + e_writer = getattr(self, w_handler) + if not is_container: + for elem in val: + e_writer(elem) + else: + for elem in val: + e_writer(elem, spec[1]) + self.writeListEnd() + + def writeContainerSet(self, val, spec): + self.writeSetBegin(spec[0], len(val)) + r_handler, w_handler, is_container = self._TTYPE_HANDLERS[spec[0]] + e_writer = getattr(self, w_handler) + if not is_container: + for elem in val: + e_writer(elem) + else: + for elem in val: + e_writer(elem, spec[1]) + self.writeSetEnd() + + def writeContainerMap(self, val, spec): + k_type = spec[0] + v_type = spec[2] + ignore, ktype_name, k_is_container = self._TTYPE_HANDLERS[k_type] + ignore, vtype_name, v_is_container = self._TTYPE_HANDLERS[v_type] + k_writer = getattr(self, ktype_name) + v_writer = getattr(self, vtype_name) + self.writeMapBegin(k_type, v_type, len(val)) + for m_key, m_val in val.iteritems(): + if not k_is_container: + k_writer(m_key) + else: + k_writer(m_key, spec[1]) + if not v_is_container: + v_writer(m_val) + else: + v_writer(m_val, spec[3]) + self.writeMapEnd() + + def writeStruct(self, obj, thrift_spec): + self.writeStructBegin(obj.__class__.__name__) + for field in thrift_spec: + if field is None: + continue + fname = field[2] + val = getattr(obj, fname) + if val is None: + # skip writing out unset fields + continue + fid = field[0] + ftype = field[1] + fspec = field[3] + # get the writer method for this value + self.writeFieldBegin(fname, ftype, fid) + self.writeFieldByTType(ftype, val, fspec) + self.writeFieldEnd() + self.writeFieldStop() + self.writeStructEnd() + + def writeFieldByTType(self, ttype, val, spec): + r_handler, w_handler, is_container = self._TTYPE_HANDLERS[ttype] + writer = getattr(self, w_handler) + if is_container: + writer(val, spec) + else: + writer(val) + + +class TProtocolFactory: + def getProtocol(self, trans): + pass diff --git a/thrift/server/THttpServer.py b/thrift/server/THttpServer.py index 6f92173..f6d1ff5 100644 --- a/thrift/server/THttpServer.py +++ b/thrift/server/THttpServer.py @@ -17,7 +17,7 @@ # under the License. # -import BaseHTTPServer +import http.server from thrift.server import TServer from thrift.transport import TTransport @@ -47,7 +47,7 @@ class THttpServer(TServer.TServer): server_address, inputProtocolFactory, outputProtocolFactory=None, - server_class=BaseHTTPServer.HTTPServer): + server_class=http.server.HTTPServer): """Set up protocol factories and HTTP server. See BaseHTTPServer for server_address. @@ -61,7 +61,7 @@ class THttpServer(TServer.TServer): thttpserver = self - class RequestHander(BaseHTTPServer.BaseHTTPRequestHandler): + class RequestHander(http.server.BaseHTTPRequestHandler): def do_POST(self): # Don't care about the request path. itrans = TTransport.TFileObjectTransport(self.rfile) diff --git a/thrift/server/THttpServer.py.bak b/thrift/server/THttpServer.py.bak new file mode 100644 index 0000000..6f92173 --- /dev/null +++ b/thrift/server/THttpServer.py.bak @@ -0,0 +1,87 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +import BaseHTTPServer + +from thrift.server import TServer +from thrift.transport import TTransport + + +class ResponseException(Exception): + """Allows handlers to override the HTTP response + + Normally, THttpServer always sends a 200 response. If a handler wants + to override this behavior (e.g., to simulate a misconfigured or + overloaded web server during testing), it can raise a ResponseException. + The function passed to the constructor will be called with the + RequestHandler as its only argument. + """ + def __init__(self, handler): + self.handler = handler + + +class THttpServer(TServer.TServer): + """A simple HTTP-based Thrift server + + This class is not very performant, but it is useful (for example) for + acting as a mock version of an Apache-based PHP Thrift endpoint. + """ + def __init__(self, + processor, + server_address, + inputProtocolFactory, + outputProtocolFactory=None, + server_class=BaseHTTPServer.HTTPServer): + """Set up protocol factories and HTTP server. + + See BaseHTTPServer for server_address. + See TServer for protocol factories. + """ + if outputProtocolFactory is None: + outputProtocolFactory = inputProtocolFactory + + TServer.TServer.__init__(self, processor, None, None, None, + inputProtocolFactory, outputProtocolFactory) + + thttpserver = self + + class RequestHander(BaseHTTPServer.BaseHTTPRequestHandler): + def do_POST(self): + # Don't care about the request path. + itrans = TTransport.TFileObjectTransport(self.rfile) + otrans = TTransport.TFileObjectTransport(self.wfile) + itrans = TTransport.TBufferedTransport( + itrans, int(self.headers['Content-Length'])) + otrans = TTransport.TMemoryBuffer() + iprot = thttpserver.inputProtocolFactory.getProtocol(itrans) + oprot = thttpserver.outputProtocolFactory.getProtocol(otrans) + try: + thttpserver.processor.process(iprot, oprot) + except ResponseException as exn: + exn.handler(self) + else: + self.send_response(200) + self.send_header("content-type", "application/x-thrift") + self.end_headers() + self.wfile.write(otrans.getvalue()) + + self.httpd = server_class(server_address, RequestHander) + + def serve(self): + self.httpd.serve_forever() diff --git a/thrift/server/TNonblockingServer.py b/thrift/server/TNonblockingServer.py index fa478d0..764c9ae 100644 --- a/thrift/server/TNonblockingServer.py +++ b/thrift/server/TNonblockingServer.py @@ -26,7 +26,7 @@ maximum connections """ import threading import socket -import Queue +import queue import select import struct import logging @@ -234,7 +234,7 @@ class TNonblockingServer: self.out_protocol = outputProtocolFactory or self.in_protocol self.threads = int(threads) self.clients = {} - self.tasks = Queue.Queue() + self.tasks = queue.Queue() self._read, self._write = socket.socketpair() self.prepared = False self._stop = False @@ -250,7 +250,7 @@ class TNonblockingServer: if self.prepared: return self.socket.listen() - for _ in xrange(self.threads): + for _ in range(self.threads): thread = Worker(self.tasks) thread.setDaemon(True) thread.start() @@ -288,7 +288,7 @@ class TNonblockingServer: """Does select on open connections.""" readable = [self.socket.handle.fileno(), self._read.fileno()] writable = [] - for i, connection in self.clients.items(): + for i, connection in list(self.clients.items()): if connection.is_readable(): readable.append(connection.fileno()) if connection.is_writeable(): @@ -330,7 +330,7 @@ class TNonblockingServer: def close(self): """Closes the server.""" - for _ in xrange(self.threads): + for _ in range(self.threads): self.tasks.put([None, None, None, None, None]) self.socket.close() self.prepared = False diff --git a/thrift/server/TNonblockingServer.py.bak b/thrift/server/TNonblockingServer.py.bak new file mode 100644 index 0000000..fa478d0 --- /dev/null +++ b/thrift/server/TNonblockingServer.py.bak @@ -0,0 +1,346 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +"""Implementation of non-blocking server. + +The main idea of the server is to receive and send requests +only from the main thread. + +The thread poool should be sized for concurrent tasks, not +maximum connections +""" +import threading +import socket +import Queue +import select +import struct +import logging + +from thrift.transport import TTransport +from thrift.protocol.TBinaryProtocol import TBinaryProtocolFactory + +__all__ = ['TNonblockingServer'] + + +class Worker(threading.Thread): + """Worker is a small helper to process incoming connection.""" + + def __init__(self, queue): + threading.Thread.__init__(self) + self.queue = queue + + def run(self): + """Process queries from task queue, stop if processor is None.""" + while True: + try: + processor, iprot, oprot, otrans, callback = self.queue.get() + if processor is None: + break + processor.process(iprot, oprot) + callback(True, otrans.getvalue()) + except Exception: + logging.exception("Exception while processing request") + callback(False, '') + +WAIT_LEN = 0 +WAIT_MESSAGE = 1 +WAIT_PROCESS = 2 +SEND_ANSWER = 3 +CLOSED = 4 + + +def locked(func): + """Decorator which locks self.lock.""" + def nested(self, *args, **kwargs): + self.lock.acquire() + try: + return func(self, *args, **kwargs) + finally: + self.lock.release() + return nested + + +def socket_exception(func): + """Decorator close object on socket.error.""" + def read(self, *args, **kwargs): + try: + return func(self, *args, **kwargs) + except socket.error: + self.close() + return read + + +class Connection: + """Basic class is represented connection. + + It can be in state: + WAIT_LEN --- connection is reading request len. + WAIT_MESSAGE --- connection is reading request. + WAIT_PROCESS --- connection has just read whole request and + waits for call ready routine. + SEND_ANSWER --- connection is sending answer string (including length + of answer). + CLOSED --- socket was closed and connection should be deleted. + """ + def __init__(self, new_socket, wake_up): + self.socket = new_socket + self.socket.setblocking(False) + self.status = WAIT_LEN + self.len = 0 + self.message = '' + self.lock = threading.Lock() + self.wake_up = wake_up + + def _read_len(self): + """Reads length of request. + + It's a safer alternative to self.socket.recv(4) + """ + read = self.socket.recv(4 - len(self.message)) + if len(read) == 0: + # if we read 0 bytes and self.message is empty, then + # the client closed the connection + if len(self.message) != 0: + logging.error("can't read frame size from socket") + self.close() + return + self.message += read + if len(self.message) == 4: + self.len, = struct.unpack('!i', self.message) + if self.len < 0: + logging.error("negative frame size, it seems client " + "doesn't use FramedTransport") + self.close() + elif self.len == 0: + logging.error("empty frame, it's really strange") + self.close() + else: + self.message = '' + self.status = WAIT_MESSAGE + + @socket_exception + def read(self): + """Reads data from stream and switch state.""" + assert self.status in (WAIT_LEN, WAIT_MESSAGE) + if self.status == WAIT_LEN: + self._read_len() + # go back to the main loop here for simplicity instead of + # falling through, even though there is a good chance that + # the message is already available + elif self.status == WAIT_MESSAGE: + read = self.socket.recv(self.len - len(self.message)) + if len(read) == 0: + logging.error("can't read frame from socket (get %d of " + "%d bytes)" % (len(self.message), self.len)) + self.close() + return + self.message += read + if len(self.message) == self.len: + self.status = WAIT_PROCESS + + @socket_exception + def write(self): + """Writes data from socket and switch state.""" + assert self.status == SEND_ANSWER + sent = self.socket.send(self.message) + if sent == len(self.message): + self.status = WAIT_LEN + self.message = '' + self.len = 0 + else: + self.message = self.message[sent:] + + @locked + def ready(self, all_ok, message): + """Callback function for switching state and waking up main thread. + + This function is the only function witch can be called asynchronous. + + The ready can switch Connection to three states: + WAIT_LEN if request was oneway. + SEND_ANSWER if request was processed in normal way. + CLOSED if request throws unexpected exception. + + The one wakes up main thread. + """ + assert self.status == WAIT_PROCESS + if not all_ok: + self.close() + self.wake_up() + return + self.len = '' + if len(message) == 0: + # it was a oneway request, do not write answer + self.message = '' + self.status = WAIT_LEN + else: + self.message = struct.pack('!i', len(message)) + message + self.status = SEND_ANSWER + self.wake_up() + + @locked + def is_writeable(self): + """Return True if connection should be added to write list of select""" + return self.status == SEND_ANSWER + + # it's not necessary, but... + @locked + def is_readable(self): + """Return True if connection should be added to read list of select""" + return self.status in (WAIT_LEN, WAIT_MESSAGE) + + @locked + def is_closed(self): + """Returns True if connection is closed.""" + return self.status == CLOSED + + def fileno(self): + """Returns the file descriptor of the associated socket.""" + return self.socket.fileno() + + def close(self): + """Closes connection""" + self.status = CLOSED + self.socket.close() + + +class TNonblockingServer: + """Non-blocking server.""" + + def __init__(self, + processor, + lsocket, + inputProtocolFactory=None, + outputProtocolFactory=None, + threads=10): + self.processor = processor + self.socket = lsocket + self.in_protocol = inputProtocolFactory or TBinaryProtocolFactory() + self.out_protocol = outputProtocolFactory or self.in_protocol + self.threads = int(threads) + self.clients = {} + self.tasks = Queue.Queue() + self._read, self._write = socket.socketpair() + self.prepared = False + self._stop = False + + def setNumThreads(self, num): + """Set the number of worker threads that should be created.""" + # implement ThreadPool interface + assert not self.prepared, "Can't change number of threads after start" + self.threads = num + + def prepare(self): + """Prepares server for serve requests.""" + if self.prepared: + return + self.socket.listen() + for _ in xrange(self.threads): + thread = Worker(self.tasks) + thread.setDaemon(True) + thread.start() + self.prepared = True + + def wake_up(self): + """Wake up main thread. + + The server usualy waits in select call in we should terminate one. + The simplest way is using socketpair. + + Select always wait to read from the first socket of socketpair. + + In this case, we can just write anything to the second socket from + socketpair. + """ + self._write.send('1') + + def stop(self): + """Stop the server. + + This method causes the serve() method to return. stop() may be invoked + from within your handler, or from another thread. + + After stop() is called, serve() will return but the server will still + be listening on the socket. serve() may then be called again to resume + processing requests. Alternatively, close() may be called after + serve() returns to close the server socket and shutdown all worker + threads. + """ + self._stop = True + self.wake_up() + + def _select(self): + """Does select on open connections.""" + readable = [self.socket.handle.fileno(), self._read.fileno()] + writable = [] + for i, connection in self.clients.items(): + if connection.is_readable(): + readable.append(connection.fileno()) + if connection.is_writeable(): + writable.append(connection.fileno()) + if connection.is_closed(): + del self.clients[i] + return select.select(readable, writable, readable) + + def handle(self): + """Handle requests. + + WARNING! You must call prepare() BEFORE calling handle() + """ + assert self.prepared, "You have to call prepare before handle" + rset, wset, xset = self._select() + for readable in rset: + if readable == self._read.fileno(): + # don't care i just need to clean readable flag + self._read.recv(1024) + elif readable == self.socket.handle.fileno(): + client = self.socket.accept().handle + self.clients[client.fileno()] = Connection(client, + self.wake_up) + else: + connection = self.clients[readable] + connection.read() + if connection.status == WAIT_PROCESS: + itransport = TTransport.TMemoryBuffer(connection.message) + otransport = TTransport.TMemoryBuffer() + iprot = self.in_protocol.getProtocol(itransport) + oprot = self.out_protocol.getProtocol(otransport) + self.tasks.put([self.processor, iprot, oprot, + otransport, connection.ready]) + for writeable in wset: + self.clients[writeable].write() + for oob in xset: + self.clients[oob].close() + del self.clients[oob] + + def close(self): + """Closes the server.""" + for _ in xrange(self.threads): + self.tasks.put([None, None, None, None, None]) + self.socket.close() + self.prepared = False + + def serve(self): + """Serve requests. + + Serve requests forever, or until stop() is called. + """ + self._stop = False + self.prepare() + while not self._stop: + self.handle() diff --git a/thrift/server/TProcessPoolServer.py b/thrift/server/TProcessPoolServer.py index 86c4312..3714ead 100644 --- a/thrift/server/TProcessPoolServer.py +++ b/thrift/server/TProcessPoolServer.py @@ -21,8 +21,9 @@ import logging from multiprocessing import Process, Value, Condition, reduction -from TServer import TServer +from .TServer import TServer from thrift.transport.TTransport import TTransportException +import collections class TProcessPoolServer(TServer): @@ -40,7 +41,7 @@ class TProcessPoolServer(TServer): self.postForkCallback = None def setPostForkCallback(self, callback): - if not callable(callback): + if not isinstance(callback, collections.Callable): raise TypeError("This is not a callback!") self.postForkCallback = callback @@ -72,7 +73,7 @@ class TProcessPoolServer(TServer): try: while True: self.processor.process(iprot, oprot) - except TTransportException, tx: + except TTransportException as tx: pass except Exception as x: logging.exception(x) @@ -95,7 +96,7 @@ class TProcessPoolServer(TServer): w.daemon = True w.start() self.workers.append(w) - except Exception, x: + except Exception as x: logging.exception(x) # wait until the condition is set by stop() diff --git a/thrift/server/TProcessPoolServer.py.bak b/thrift/server/TProcessPoolServer.py.bak new file mode 100644 index 0000000..86c4312 --- /dev/null +++ b/thrift/server/TProcessPoolServer.py.bak @@ -0,0 +1,118 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + + +import logging +from multiprocessing import Process, Value, Condition, reduction + +from TServer import TServer +from thrift.transport.TTransport import TTransportException + + +class TProcessPoolServer(TServer): + """Server with a fixed size pool of worker subprocesses to service requests + + Note that if you need shared state between the handlers - it's up to you! + Written by Dvir Volk, doat.com + """ + def __init__(self, *args): + TServer.__init__(self, *args) + self.numWorkers = 10 + self.workers = [] + self.isRunning = Value('b', False) + self.stopCondition = Condition() + self.postForkCallback = None + + def setPostForkCallback(self, callback): + if not callable(callback): + raise TypeError("This is not a callback!") + self.postForkCallback = callback + + def setNumWorkers(self, num): + """Set the number of worker threads that should be created""" + self.numWorkers = num + + def workerProcess(self): + """Loop getting clients from the shared queue and process them""" + if self.postForkCallback: + self.postForkCallback() + + while self.isRunning.value: + try: + client = self.serverTransport.accept() + self.serveClient(client) + except (KeyboardInterrupt, SystemExit): + return 0 + except Exception as x: + logging.exception(x) + + def serveClient(self, client): + """Process input/output from a client for as long as possible""" + itrans = self.inputTransportFactory.getTransport(client) + otrans = self.outputTransportFactory.getTransport(client) + iprot = self.inputProtocolFactory.getProtocol(itrans) + oprot = self.outputProtocolFactory.getProtocol(otrans) + + try: + while True: + self.processor.process(iprot, oprot) + except TTransportException, tx: + pass + except Exception as x: + logging.exception(x) + + itrans.close() + otrans.close() + + def serve(self): + """Start workers and put into queue""" + # this is a shared state that can tell the workers to exit when False + self.isRunning.value = True + + # first bind and listen to the port + self.serverTransport.listen() + + # fork the children + for i in range(self.numWorkers): + try: + w = Process(target=self.workerProcess) + w.daemon = True + w.start() + self.workers.append(w) + except Exception, x: + logging.exception(x) + + # wait until the condition is set by stop() + while True: + self.stopCondition.acquire() + try: + self.stopCondition.wait() + break + except (SystemExit, KeyboardInterrupt): + break + except Exception as x: + logging.exception(x) + + self.isRunning.value = False + + def stop(self): + self.isRunning.value = False + self.stopCondition.acquire() + self.stopCondition.notify() + self.stopCondition.release() diff --git a/thrift/server/TServer.py b/thrift/server/TServer.py index 97097cc..9e340f4 100644 --- a/thrift/server/TServer.py +++ b/thrift/server/TServer.py @@ -17,7 +17,7 @@ # under the License. # -import Queue +import queue import logging import os import sys @@ -82,7 +82,7 @@ class TSimpleServer(TServer): try: while True: self.processor.process(iprot, oprot) - except TTransport.TTransportException, tx: + except TTransport.TTransportException as tx: pass except Exception as x: logging.exception(x) @@ -119,7 +119,7 @@ class TThreadedServer(TServer): try: while True: self.processor.process(iprot, oprot) - except TTransport.TTransportException, tx: + except TTransport.TTransportException as tx: pass except Exception as x: logging.exception(x) @@ -133,7 +133,7 @@ class TThreadPoolServer(TServer): def __init__(self, *args, **kwargs): TServer.__init__(self, *args) - self.clients = Queue.Queue() + self.clients = queue.Queue() self.threads = 10 self.daemon = kwargs.get("daemon", False) @@ -147,7 +147,7 @@ class TThreadPoolServer(TServer): try: client = self.clients.get() self.serveClient(client) - except Exception, x: + except Exception as x: logging.exception(x) def serveClient(self, client): @@ -159,7 +159,7 @@ class TThreadPoolServer(TServer): try: while True: self.processor.process(iprot, oprot) - except TTransport.TTransportException, tx: + except TTransport.TTransportException as tx: pass except Exception as x: logging.exception(x) @@ -240,7 +240,7 @@ class TForkingServer(TServer): try: while True: self.processor.process(iprot, oprot) - except TTransport.TTransportException, tx: + except TTransport.TTransportException as tx: pass except Exception as e: logging.exception(e) @@ -251,7 +251,7 @@ class TForkingServer(TServer): os._exit(ecode) - except TTransport.TTransportException, tx: + except TTransport.TTransportException as tx: pass except Exception as x: logging.exception(x) diff --git a/thrift/server/TServer.py.bak b/thrift/server/TServer.py.bak new file mode 100644 index 0000000..97097cc --- /dev/null +++ b/thrift/server/TServer.py.bak @@ -0,0 +1,269 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +import Queue +import logging +import os +import sys +import threading +import traceback + +from thrift.Thrift import TProcessor +from thrift.protocol import TBinaryProtocol +from thrift.transport import TTransport + + +class TServer: + """Base interface for a server, which must have a serve() method. + + Three constructors for all servers: + 1) (processor, serverTransport) + 2) (processor, serverTransport, transportFactory, protocolFactory) + 3) (processor, serverTransport, + inputTransportFactory, outputTransportFactory, + inputProtocolFactory, outputProtocolFactory) + """ + def __init__(self, *args): + if (len(args) == 2): + self.__initArgs__(args[0], args[1], + TTransport.TTransportFactoryBase(), + TTransport.TTransportFactoryBase(), + TBinaryProtocol.TBinaryProtocolFactory(), + TBinaryProtocol.TBinaryProtocolFactory()) + elif (len(args) == 4): + self.__initArgs__(args[0], args[1], args[2], args[2], args[3], args[3]) + elif (len(args) == 6): + self.__initArgs__(args[0], args[1], args[2], args[3], args[4], args[5]) + + def __initArgs__(self, processor, serverTransport, + inputTransportFactory, outputTransportFactory, + inputProtocolFactory, outputProtocolFactory): + self.processor = processor + self.serverTransport = serverTransport + self.inputTransportFactory = inputTransportFactory + self.outputTransportFactory = outputTransportFactory + self.inputProtocolFactory = inputProtocolFactory + self.outputProtocolFactory = outputProtocolFactory + + def serve(self): + pass + + +class TSimpleServer(TServer): + """Simple single-threaded server that just pumps around one transport.""" + + def __init__(self, *args): + TServer.__init__(self, *args) + + def serve(self): + self.serverTransport.listen() + while True: + client = self.serverTransport.accept() + itrans = self.inputTransportFactory.getTransport(client) + otrans = self.outputTransportFactory.getTransport(client) + iprot = self.inputProtocolFactory.getProtocol(itrans) + oprot = self.outputProtocolFactory.getProtocol(otrans) + try: + while True: + self.processor.process(iprot, oprot) + except TTransport.TTransportException, tx: + pass + except Exception as x: + logging.exception(x) + + itrans.close() + otrans.close() + + +class TThreadedServer(TServer): + """Threaded server that spawns a new thread per each connection.""" + + def __init__(self, *args, **kwargs): + TServer.__init__(self, *args) + self.daemon = kwargs.get("daemon", False) + + def serve(self): + self.serverTransport.listen() + while True: + try: + client = self.serverTransport.accept() + t = threading.Thread(target=self.handle, args=(client,)) + t.setDaemon(self.daemon) + t.start() + except KeyboardInterrupt: + raise + except Exception as x: + logging.exception(x) + + def handle(self, client): + itrans = self.inputTransportFactory.getTransport(client) + otrans = self.outputTransportFactory.getTransport(client) + iprot = self.inputProtocolFactory.getProtocol(itrans) + oprot = self.outputProtocolFactory.getProtocol(otrans) + try: + while True: + self.processor.process(iprot, oprot) + except TTransport.TTransportException, tx: + pass + except Exception as x: + logging.exception(x) + + itrans.close() + otrans.close() + + +class TThreadPoolServer(TServer): + """Server with a fixed size pool of threads which service requests.""" + + def __init__(self, *args, **kwargs): + TServer.__init__(self, *args) + self.clients = Queue.Queue() + self.threads = 10 + self.daemon = kwargs.get("daemon", False) + + def setNumThreads(self, num): + """Set the number of worker threads that should be created""" + self.threads = num + + def serveThread(self): + """Loop around getting clients from the shared queue and process them.""" + while True: + try: + client = self.clients.get() + self.serveClient(client) + except Exception, x: + logging.exception(x) + + def serveClient(self, client): + """Process input/output from a client for as long as possible""" + itrans = self.inputTransportFactory.getTransport(client) + otrans = self.outputTransportFactory.getTransport(client) + iprot = self.inputProtocolFactory.getProtocol(itrans) + oprot = self.outputProtocolFactory.getProtocol(otrans) + try: + while True: + self.processor.process(iprot, oprot) + except TTransport.TTransportException, tx: + pass + except Exception as x: + logging.exception(x) + + itrans.close() + otrans.close() + + def serve(self): + """Start a fixed number of worker threads and put client into a queue""" + for i in range(self.threads): + try: + t = threading.Thread(target=self.serveThread) + t.setDaemon(self.daemon) + t.start() + except Exception as x: + logging.exception(x) + + # Pump the socket for clients + self.serverTransport.listen() + while True: + try: + client = self.serverTransport.accept() + self.clients.put(client) + except Exception as x: + logging.exception(x) + + +class TForkingServer(TServer): + """A Thrift server that forks a new process for each request + + This is more scalable than the threaded server as it does not cause + GIL contention. + + Note that this has different semantics from the threading server. + Specifically, updates to shared variables will no longer be shared. + It will also not work on windows. + + This code is heavily inspired by SocketServer.ForkingMixIn in the + Python stdlib. + """ + def __init__(self, *args): + TServer.__init__(self, *args) + self.children = [] + + def serve(self): + def try_close(file): + try: + file.close() + except IOError as e: + logging.warning(e, exc_info=True) + + self.serverTransport.listen() + while True: + client = self.serverTransport.accept() + try: + pid = os.fork() + + if pid: # parent + # add before collect, otherwise you race w/ waitpid + self.children.append(pid) + self.collect_children() + + # Parent must close socket or the connection may not get + # closed promptly + itrans = self.inputTransportFactory.getTransport(client) + otrans = self.outputTransportFactory.getTransport(client) + try_close(itrans) + try_close(otrans) + else: + itrans = self.inputTransportFactory.getTransport(client) + otrans = self.outputTransportFactory.getTransport(client) + + iprot = self.inputProtocolFactory.getProtocol(itrans) + oprot = self.outputProtocolFactory.getProtocol(otrans) + + ecode = 0 + try: + try: + while True: + self.processor.process(iprot, oprot) + except TTransport.TTransportException, tx: + pass + except Exception as e: + logging.exception(e) + ecode = 1 + finally: + try_close(itrans) + try_close(otrans) + + os._exit(ecode) + + except TTransport.TTransportException, tx: + pass + except Exception as x: + logging.exception(x) + + def collect_children(self): + while self.children: + try: + pid, status = os.waitpid(0, os.WNOHANG) + except os.error: + pid = None + + if pid: + self.children.remove(pid) + else: + break diff --git a/thrift/transport/THttpClient.py b/thrift/transport/THttpClient.py index ea80a1a..20be338 100644 --- a/thrift/transport/THttpClient.py +++ b/thrift/transport/THttpClient.py @@ -17,17 +17,17 @@ # under the License. # -import httplib +import http.client import os import socket import sys -import urllib -import urlparse +import urllib.request, urllib.parse, urllib.error +import urllib.parse import warnings -from cStringIO import StringIO +from io import StringIO -from TTransport import * +from .TTransport import * class THttpClient(TTransportBase): @@ -52,13 +52,13 @@ class THttpClient(TTransportBase): self.path = path self.scheme = 'http' else: - parsed = urlparse.urlparse(uri_or_host) + parsed = urllib.parse.urlparse(uri_or_host) self.scheme = parsed.scheme assert self.scheme in ('http', 'https') if self.scheme == 'http': - self.port = parsed.port or httplib.HTTP_PORT + self.port = parsed.port or http.client.HTTP_PORT elif self.scheme == 'https': - self.port = parsed.port or httplib.HTTPS_PORT + self.port = parsed.port or http.client.HTTPS_PORT self.host = parsed.hostname self.path = parsed.path if parsed.query: @@ -70,9 +70,9 @@ class THttpClient(TTransportBase): def open(self): if self.scheme == 'http': - self.__http = httplib.HTTP(self.host, self.port) + self.__http = http.client.HTTP(self.host, self.port) else: - self.__http = httplib.HTTPS(self.host, self.port) + self.__http = http.client.HTTPS(self.host, self.port) def close(self): self.__http.close() @@ -129,11 +129,11 @@ class THttpClient(TTransportBase): user_agent = 'Python/THttpClient' script = os.path.basename(sys.argv[0]) if script: - user_agent = '%s (%s)' % (user_agent, urllib.quote(script)) + user_agent = '%s (%s)' % (user_agent, urllib.parse.quote(script)) self.__http.putheader('User-Agent', user_agent) if self.__custom_headers: - for key, val in self.__custom_headers.iteritems(): + for key, val in self.__custom_headers.items(): self.__http.putheader(key, val) self.__http.endheaders() diff --git a/thrift/transport/THttpClient.py.bak b/thrift/transport/THttpClient.py.bak new file mode 100644 index 0000000..ea80a1a --- /dev/null +++ b/thrift/transport/THttpClient.py.bak @@ -0,0 +1,149 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +import httplib +import os +import socket +import sys +import urllib +import urlparse +import warnings + +from cStringIO import StringIO + +from TTransport import * + + +class THttpClient(TTransportBase): + """Http implementation of TTransport base.""" + + def __init__(self, uri_or_host, port=None, path=None): + """THttpClient supports two different types constructor parameters. + + THttpClient(host, port, path) - deprecated + THttpClient(uri) + + Only the second supports https. + """ + if port is not None: + warnings.warn( + "Please use the THttpClient('http://host:port/path') syntax", + DeprecationWarning, + stacklevel=2) + self.host = uri_or_host + self.port = port + assert path + self.path = path + self.scheme = 'http' + else: + parsed = urlparse.urlparse(uri_or_host) + self.scheme = parsed.scheme + assert self.scheme in ('http', 'https') + if self.scheme == 'http': + self.port = parsed.port or httplib.HTTP_PORT + elif self.scheme == 'https': + self.port = parsed.port or httplib.HTTPS_PORT + self.host = parsed.hostname + self.path = parsed.path + if parsed.query: + self.path += '?%s' % parsed.query + self.__wbuf = StringIO() + self.__http = None + self.__timeout = None + self.__custom_headers = None + + def open(self): + if self.scheme == 'http': + self.__http = httplib.HTTP(self.host, self.port) + else: + self.__http = httplib.HTTPS(self.host, self.port) + + def close(self): + self.__http.close() + self.__http = None + + def isOpen(self): + return self.__http is not None + + def setTimeout(self, ms): + if not hasattr(socket, 'getdefaulttimeout'): + raise NotImplementedError + + if ms is None: + self.__timeout = None + else: + self.__timeout = ms / 1000.0 + + def setCustomHeaders(self, headers): + self.__custom_headers = headers + + def read(self, sz): + return self.__http.file.read(sz) + + def write(self, buf): + self.__wbuf.write(buf) + + def __withTimeout(f): + def _f(*args, **kwargs): + orig_timeout = socket.getdefaulttimeout() + socket.setdefaulttimeout(args[0].__timeout) + result = f(*args, **kwargs) + socket.setdefaulttimeout(orig_timeout) + return result + return _f + + def flush(self): + if self.isOpen(): + self.close() + self.open() + + # Pull data out of buffer + data = self.__wbuf.getvalue() + self.__wbuf = StringIO() + + # HTTP request + self.__http.putrequest('POST', self.path) + + # Write headers + self.__http.putheader('Host', self.host) + self.__http.putheader('Content-Type', 'application/x-thrift') + self.__http.putheader('Content-Length', str(len(data))) + + if not self.__custom_headers or 'User-Agent' not in self.__custom_headers: + user_agent = 'Python/THttpClient' + script = os.path.basename(sys.argv[0]) + if script: + user_agent = '%s (%s)' % (user_agent, urllib.quote(script)) + self.__http.putheader('User-Agent', user_agent) + + if self.__custom_headers: + for key, val in self.__custom_headers.iteritems(): + self.__http.putheader(key, val) + + self.__http.endheaders() + + # Write payload + self.__http.send(data) + + # Get reply to flush the request + self.code, self.message, self.headers = self.__http.getreply() + + # Decorate if we know how to timeout + if hasattr(socket, 'getdefaulttimeout'): + flush = __withTimeout(flush) diff --git a/thrift/transport/TSocket.py b/thrift/transport/TSocket.py index 9e2b384..82ce568 100644 --- a/thrift/transport/TSocket.py +++ b/thrift/transport/TSocket.py @@ -22,7 +22,7 @@ import os import socket import sys -from TTransport import * +from .TTransport import * class TSocketBase(TTransportBase): @@ -84,13 +84,13 @@ class TSocket(TSocketBase): self.handle.settimeout(self._timeout) try: self.handle.connect(res[4]) - except socket.error, e: + except socket.error as e: if res is not res0[-1]: continue else: raise e break - except socket.error, e: + except socket.error as e: if self._unix_socket: message = 'Could not connect to socket %s' % self._unix_socket else: @@ -101,7 +101,7 @@ class TSocket(TSocketBase): def read(self, sz): try: buff = self.handle.recv(sz) - except socket.error, e: + except socket.error as e: if (e.args[0] == errno.ECONNRESET and (sys.platform == 'darwin' or sys.platform.startswith('freebsd'))): # freebsd and Mach don't follow POSIX semantic of recv @@ -157,7 +157,7 @@ class TServerSocket(TSocketBase, TServerTransportBase): tmp = socket.socket(res[0], res[1]) try: tmp.connect(res[4]) - except socket.error, err: + except socket.error as err: eno, message = err.args if eno == errno.ECONNREFUSED: os.unlink(res[4]) diff --git a/thrift/transport/TSocket.py.bak b/thrift/transport/TSocket.py.bak new file mode 100644 index 0000000..9e2b384 --- /dev/null +++ b/thrift/transport/TSocket.py.bak @@ -0,0 +1,176 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +import errno +import os +import socket +import sys + +from TTransport import * + + +class TSocketBase(TTransportBase): + def _resolveAddr(self): + if self._unix_socket is not None: + return [(socket.AF_UNIX, socket.SOCK_STREAM, None, None, + self._unix_socket)] + else: + return socket.getaddrinfo(self.host, + self.port, + socket.AF_UNSPEC, + socket.SOCK_STREAM, + 0, + socket.AI_PASSIVE | socket.AI_ADDRCONFIG) + + def close(self): + if self.handle: + self.handle.close() + self.handle = None + + +class TSocket(TSocketBase): + """Socket implementation of TTransport base.""" + + def __init__(self, host='localhost', port=9090, unix_socket=None): + """Initialize a TSocket + + @param host(str) The host to connect to. + @param port(int) The (TCP) port to connect to. + @param unix_socket(str) The filename of a unix socket to connect to. + (host and port will be ignored.) + """ + self.host = host + self.port = port + self.handle = None + self._unix_socket = unix_socket + self._timeout = None + + def setHandle(self, h): + self.handle = h + + def isOpen(self): + return self.handle is not None + + def setTimeout(self, ms): + if ms is None: + self._timeout = None + else: + self._timeout = ms / 1000.0 + + if self.handle is not None: + self.handle.settimeout(self._timeout) + + def open(self): + try: + res0 = self._resolveAddr() + for res in res0: + self.handle = socket.socket(res[0], res[1]) + self.handle.settimeout(self._timeout) + try: + self.handle.connect(res[4]) + except socket.error, e: + if res is not res0[-1]: + continue + else: + raise e + break + except socket.error, e: + if self._unix_socket: + message = 'Could not connect to socket %s' % self._unix_socket + else: + message = 'Could not connect to %s:%d' % (self.host, self.port) + raise TTransportException(type=TTransportException.NOT_OPEN, + message=message) + + def read(self, sz): + try: + buff = self.handle.recv(sz) + except socket.error, e: + if (e.args[0] == errno.ECONNRESET and + (sys.platform == 'darwin' or sys.platform.startswith('freebsd'))): + # freebsd and Mach don't follow POSIX semantic of recv + # and fail with ECONNRESET if peer performed shutdown. + # See corresponding comment and code in TSocket::read() + # in lib/cpp/src/transport/TSocket.cpp. + self.close() + # Trigger the check to raise the END_OF_FILE exception below. + buff = '' + else: + raise + if len(buff) == 0: + raise TTransportException(type=TTransportException.END_OF_FILE, + message='TSocket read 0 bytes') + return buff + + def write(self, buff): + if not self.handle: + raise TTransportException(type=TTransportException.NOT_OPEN, + message='Transport not open') + sent = 0 + have = len(buff) + while sent < have: + plus = self.handle.send(buff) + if plus == 0: + raise TTransportException(type=TTransportException.END_OF_FILE, + message='TSocket sent 0 bytes') + sent += plus + buff = buff[plus:] + + def flush(self): + pass + + +class TServerSocket(TSocketBase, TServerTransportBase): + """Socket implementation of TServerTransport base.""" + + def __init__(self, host=None, port=9090, unix_socket=None): + self.host = host + self.port = port + self._unix_socket = unix_socket + self.handle = None + + def listen(self): + res0 = self._resolveAddr() + for res in res0: + if res[0] is socket.AF_INET6 or res is res0[-1]: + break + + # We need remove the old unix socket if the file exists and + # nobody is listening on it. + if self._unix_socket: + tmp = socket.socket(res[0], res[1]) + try: + tmp.connect(res[4]) + except socket.error, err: + eno, message = err.args + if eno == errno.ECONNREFUSED: + os.unlink(res[4]) + + self.handle = socket.socket(res[0], res[1]) + self.handle.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + if hasattr(self.handle, 'settimeout'): + self.handle.settimeout(None) + self.handle.bind(res[4]) + self.handle.listen(128) + + def accept(self): + client, addr = self.handle.accept() + result = TSocket() + result.setHandle(client) + return result diff --git a/thrift/transport/TTransport.py b/thrift/transport/TTransport.py index 4481371..eae4b9a 100644 --- a/thrift/transport/TTransport.py +++ b/thrift/transport/TTransport.py @@ -17,7 +17,7 @@ # under the License. # -from cStringIO import StringIO +from io import StringIO from struct import pack, unpack from thrift.Thrift import TException diff --git a/thrift/transport/TTransport.py.bak b/thrift/transport/TTransport.py.bak new file mode 100644 index 0000000..4481371 --- /dev/null +++ b/thrift/transport/TTransport.py.bak @@ -0,0 +1,330 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +from cStringIO import StringIO +from struct import pack, unpack +from thrift.Thrift import TException + + +class TTransportException(TException): + """Custom Transport Exception class""" + + UNKNOWN = 0 + NOT_OPEN = 1 + ALREADY_OPEN = 2 + TIMED_OUT = 3 + END_OF_FILE = 4 + + def __init__(self, type=UNKNOWN, message=None): + TException.__init__(self, message) + self.type = type + + +class TTransportBase: + """Base class for Thrift transport layer.""" + + def isOpen(self): + pass + + def open(self): + pass + + def close(self): + pass + + def read(self, sz): + pass + + def readAll(self, sz): + buff = '' + have = 0 + while (have < sz): + chunk = self.read(sz - have) + have += len(chunk) + buff += chunk + + if len(chunk) == 0: + raise EOFError() + + return buff + + def write(self, buf): + pass + + def flush(self): + pass + + +# This class should be thought of as an interface. +class CReadableTransport: + """base class for transports that are readable from C""" + + # TODO(dreiss): Think about changing this interface to allow us to use + # a (Python, not c) StringIO instead, because it allows + # you to write after reading. + + # NOTE: This is a classic class, so properties will NOT work + # correctly for setting. + @property + def cstringio_buf(self): + """A cStringIO buffer that contains the current chunk we are reading.""" + pass + + def cstringio_refill(self, partialread, reqlen): + """Refills cstringio_buf. + + Returns the currently used buffer (which can but need not be the same as + the old cstringio_buf). partialread is what the C code has read from the + buffer, and should be inserted into the buffer before any more reads. The + return value must be a new, not borrowed reference. Something along the + lines of self._buf should be fine. + + If reqlen bytes can't be read, throw EOFError. + """ + pass + + +class TServerTransportBase: + """Base class for Thrift server transports.""" + + def listen(self): + pass + + def accept(self): + pass + + def close(self): + pass + + +class TTransportFactoryBase: + """Base class for a Transport Factory""" + + def getTransport(self, trans): + return trans + + +class TBufferedTransportFactory: + """Factory transport that builds buffered transports""" + + def getTransport(self, trans): + buffered = TBufferedTransport(trans) + return buffered + + +class TBufferedTransport(TTransportBase, CReadableTransport): + """Class that wraps another transport and buffers its I/O. + + The implementation uses a (configurable) fixed-size read buffer + but buffers all writes until a flush is performed. + """ + DEFAULT_BUFFER = 4096 + + def __init__(self, trans, rbuf_size=DEFAULT_BUFFER): + self.__trans = trans + self.__wbuf = StringIO() + self.__rbuf = StringIO("") + self.__rbuf_size = rbuf_size + + def isOpen(self): + return self.__trans.isOpen() + + def open(self): + return self.__trans.open() + + def close(self): + return self.__trans.close() + + def read(self, sz): + ret = self.__rbuf.read(sz) + if len(ret) != 0: + return ret + + self.__rbuf = StringIO(self.__trans.read(max(sz, self.__rbuf_size))) + return self.__rbuf.read(sz) + + def write(self, buf): + self.__wbuf.write(buf) + + def flush(self): + out = self.__wbuf.getvalue() + # reset wbuf before write/flush to preserve state on underlying failure + self.__wbuf = StringIO() + self.__trans.write(out) + self.__trans.flush() + + # Implement the CReadableTransport interface. + @property + def cstringio_buf(self): + return self.__rbuf + + def cstringio_refill(self, partialread, reqlen): + retstring = partialread + if reqlen < self.__rbuf_size: + # try to make a read of as much as we can. + retstring += self.__trans.read(self.__rbuf_size) + + # but make sure we do read reqlen bytes. + if len(retstring) < reqlen: + retstring += self.__trans.readAll(reqlen - len(retstring)) + + self.__rbuf = StringIO(retstring) + return self.__rbuf + + +class TMemoryBuffer(TTransportBase, CReadableTransport): + """Wraps a cStringIO object as a TTransport. + + NOTE: Unlike the C++ version of this class, you cannot write to it + then immediately read from it. If you want to read from a + TMemoryBuffer, you must either pass a string to the constructor. + TODO(dreiss): Make this work like the C++ version. + """ + + def __init__(self, value=None): + """value -- a value to read from for stringio + + If value is set, this will be a transport for reading, + otherwise, it is for writing""" + if value is not None: + self._buffer = StringIO(value) + else: + self._buffer = StringIO() + + def isOpen(self): + return not self._buffer.closed + + def open(self): + pass + + def close(self): + self._buffer.close() + + def read(self, sz): + return self._buffer.read(sz) + + def write(self, buf): + self._buffer.write(buf) + + def flush(self): + pass + + def getvalue(self): + return self._buffer.getvalue() + + # Implement the CReadableTransport interface. + @property + def cstringio_buf(self): + return self._buffer + + def cstringio_refill(self, partialread, reqlen): + # only one shot at reading... + raise EOFError() + + +class TFramedTransportFactory: + """Factory transport that builds framed transports""" + + def getTransport(self, trans): + framed = TFramedTransport(trans) + return framed + + +class TFramedTransport(TTransportBase, CReadableTransport): + """Class that wraps another transport and frames its I/O when writing.""" + + def __init__(self, trans,): + self.__trans = trans + self.__rbuf = StringIO() + self.__wbuf = StringIO() + + def isOpen(self): + return self.__trans.isOpen() + + def open(self): + return self.__trans.open() + + def close(self): + return self.__trans.close() + + def read(self, sz): + ret = self.__rbuf.read(sz) + if len(ret) != 0: + return ret + + self.readFrame() + return self.__rbuf.read(sz) + + def readFrame(self): + buff = self.__trans.readAll(4) + sz, = unpack('!i', buff) + self.__rbuf = StringIO(self.__trans.readAll(sz)) + + def write(self, buf): + self.__wbuf.write(buf) + + def flush(self): + wout = self.__wbuf.getvalue() + wsz = len(wout) + # reset wbuf before write/flush to preserve state on underlying failure + self.__wbuf = StringIO() + # N.B.: Doing this string concatenation is WAY cheaper than making + # two separate calls to the underlying socket object. Socket writes in + # Python turn out to be REALLY expensive, but it seems to do a pretty + # good job of managing string buffer operations without excessive copies + buf = pack("!i", wsz) + wout + self.__trans.write(buf) + self.__trans.flush() + + # Implement the CReadableTransport interface. + @property + def cstringio_buf(self): + return self.__rbuf + + def cstringio_refill(self, prefix, reqlen): + # self.__rbuf will already be empty here because fastbinary doesn't + # ask for a refill until the previous buffer is empty. Therefore, + # we can start reading new frames immediately. + while len(prefix) < reqlen: + self.readFrame() + prefix += self.__rbuf.getvalue() + self.__rbuf = StringIO(prefix) + return self.__rbuf + + +class TFileObjectTransport(TTransportBase): + """Wraps a file-like object to make it work as a Thrift transport.""" + + def __init__(self, fileobj): + self.fileobj = fileobj + + def isOpen(self): + return True + + def close(self): + self.fileobj.close() + + def read(self, sz): + return self.fileobj.read(sz) + + def write(self, buf): + self.fileobj.write(buf) + + def flush(self): + self.fileobj.flush() diff --git a/thrift/transport/TTwisted.py b/thrift/transport/TTwisted.py index 3ce3eb2..ffe5494 100644 --- a/thrift/transport/TTwisted.py +++ b/thrift/transport/TTwisted.py @@ -17,7 +17,7 @@ # under the License. # -from cStringIO import StringIO +from io import StringIO from zope.interface import implements, Interface, Attribute from twisted.internet.protocol import Protocol, ServerFactory, ClientFactory, \ @@ -81,7 +81,7 @@ class ThriftClientProtocol(basic.Int32StringReceiver): self.started.callback(self.client) def connectionLost(self, reason=connectionDone): - for k, v in self.client._reqs.iteritems(): + for k, v in self.client._reqs.items(): tex = TTransport.TTransportException( type=TTransport.TTransportException.END_OF_FILE, message='Connection closed') diff --git a/thrift/transport/TTwisted.py.bak b/thrift/transport/TTwisted.py.bak new file mode 100644 index 0000000..3ce3eb2 --- /dev/null +++ b/thrift/transport/TTwisted.py.bak @@ -0,0 +1,221 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +from cStringIO import StringIO + +from zope.interface import implements, Interface, Attribute +from twisted.internet.protocol import Protocol, ServerFactory, ClientFactory, \ + connectionDone +from twisted.internet import defer +from twisted.protocols import basic +from twisted.python import log +from twisted.web import server, resource, http + +from thrift.transport import TTransport + + +class TMessageSenderTransport(TTransport.TTransportBase): + + def __init__(self): + self.__wbuf = StringIO() + + def write(self, buf): + self.__wbuf.write(buf) + + def flush(self): + msg = self.__wbuf.getvalue() + self.__wbuf = StringIO() + self.sendMessage(msg) + + def sendMessage(self, message): + raise NotImplementedError + + +class TCallbackTransport(TMessageSenderTransport): + + def __init__(self, func): + TMessageSenderTransport.__init__(self) + self.func = func + + def sendMessage(self, message): + self.func(message) + + +class ThriftClientProtocol(basic.Int32StringReceiver): + + MAX_LENGTH = 2 ** 31 - 1 + + def __init__(self, client_class, iprot_factory, oprot_factory=None): + self._client_class = client_class + self._iprot_factory = iprot_factory + if oprot_factory is None: + self._oprot_factory = iprot_factory + else: + self._oprot_factory = oprot_factory + + self.recv_map = {} + self.started = defer.Deferred() + + def dispatch(self, msg): + self.sendString(msg) + + def connectionMade(self): + tmo = TCallbackTransport(self.dispatch) + self.client = self._client_class(tmo, self._oprot_factory) + self.started.callback(self.client) + + def connectionLost(self, reason=connectionDone): + for k, v in self.client._reqs.iteritems(): + tex = TTransport.TTransportException( + type=TTransport.TTransportException.END_OF_FILE, + message='Connection closed') + v.errback(tex) + + def stringReceived(self, frame): + tr = TTransport.TMemoryBuffer(frame) + iprot = self._iprot_factory.getProtocol(tr) + (fname, mtype, rseqid) = iprot.readMessageBegin() + + try: + method = self.recv_map[fname] + except KeyError: + method = getattr(self.client, 'recv_' + fname) + self.recv_map[fname] = method + + method(iprot, mtype, rseqid) + + +class ThriftServerProtocol(basic.Int32StringReceiver): + + MAX_LENGTH = 2 ** 31 - 1 + + def dispatch(self, msg): + self.sendString(msg) + + def processError(self, error): + self.transport.loseConnection() + + def processOk(self, _, tmo): + msg = tmo.getvalue() + + if len(msg) > 0: + self.dispatch(msg) + + def stringReceived(self, frame): + tmi = TTransport.TMemoryBuffer(frame) + tmo = TTransport.TMemoryBuffer() + + iprot = self.factory.iprot_factory.getProtocol(tmi) + oprot = self.factory.oprot_factory.getProtocol(tmo) + + d = self.factory.processor.process(iprot, oprot) + d.addCallbacks(self.processOk, self.processError, + callbackArgs=(tmo,)) + + +class IThriftServerFactory(Interface): + + processor = Attribute("Thrift processor") + + iprot_factory = Attribute("Input protocol factory") + + oprot_factory = Attribute("Output protocol factory") + + +class IThriftClientFactory(Interface): + + client_class = Attribute("Thrift client class") + + iprot_factory = Attribute("Input protocol factory") + + oprot_factory = Attribute("Output protocol factory") + + +class ThriftServerFactory(ServerFactory): + + implements(IThriftServerFactory) + + protocol = ThriftServerProtocol + + def __init__(self, processor, iprot_factory, oprot_factory=None): + self.processor = processor + self.iprot_factory = iprot_factory + if oprot_factory is None: + self.oprot_factory = iprot_factory + else: + self.oprot_factory = oprot_factory + + +class ThriftClientFactory(ClientFactory): + + implements(IThriftClientFactory) + + protocol = ThriftClientProtocol + + def __init__(self, client_class, iprot_factory, oprot_factory=None): + self.client_class = client_class + self.iprot_factory = iprot_factory + if oprot_factory is None: + self.oprot_factory = iprot_factory + else: + self.oprot_factory = oprot_factory + + def buildProtocol(self, addr): + p = self.protocol(self.client_class, self.iprot_factory, + self.oprot_factory) + p.factory = self + return p + + +class ThriftResource(resource.Resource): + + allowedMethods = ('POST',) + + def __init__(self, processor, inputProtocolFactory, + outputProtocolFactory=None): + resource.Resource.__init__(self) + self.inputProtocolFactory = inputProtocolFactory + if outputProtocolFactory is None: + self.outputProtocolFactory = inputProtocolFactory + else: + self.outputProtocolFactory = outputProtocolFactory + self.processor = processor + + def getChild(self, path, request): + return self + + def _cbProcess(self, _, request, tmo): + msg = tmo.getvalue() + request.setResponseCode(http.OK) + request.setHeader("content-type", "application/x-thrift") + request.write(msg) + request.finish() + + def render_POST(self, request): + request.content.seek(0, 0) + data = request.content.read() + tmi = TTransport.TMemoryBuffer(data) + tmo = TTransport.TMemoryBuffer() + + iprot = self.inputProtocolFactory.getProtocol(tmi) + oprot = self.outputProtocolFactory.getProtocol(tmo) + + d = self.processor.process(iprot, oprot) + d.addCallback(self._cbProcess, request, tmo) + return server.NOT_DONE_YET diff --git a/thrift/transport/TZlibTransport.py b/thrift/transport/TZlibTransport.py index a2f42a5..a21dc80 100644 --- a/thrift/transport/TZlibTransport.py +++ b/thrift/transport/TZlibTransport.py @@ -22,10 +22,10 @@ class, using the python standard library zlib module to implement data compression. """ -from __future__ import division + import zlib -from cStringIO import StringIO -from TTransport import TTransportBase, CReadableTransport +from io import StringIO +from .TTransport import TTransportBase, CReadableTransport class TZlibTransportFactory(object): diff --git a/thrift/transport/TZlibTransport.py.bak b/thrift/transport/TZlibTransport.py.bak new file mode 100644 index 0000000..a2f42a5 --- /dev/null +++ b/thrift/transport/TZlibTransport.py.bak @@ -0,0 +1,248 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +"""TZlibTransport provides a compressed transport and transport factory +class, using the python standard library zlib module to implement +data compression. +""" + +from __future__ import division +import zlib +from cStringIO import StringIO +from TTransport import TTransportBase, CReadableTransport + + +class TZlibTransportFactory(object): + """Factory transport that builds zlib compressed transports. + + This factory caches the last single client/transport that it was passed + and returns the same TZlibTransport object that was created. + + This caching means the TServer class will get the _same_ transport + object for both input and output transports from this factory. + (For non-threaded scenarios only, since the cache only holds one object) + + The purpose of this caching is to allocate only one TZlibTransport where + only one is really needed (since it must have separate read/write buffers), + and makes the statistics from getCompSavings() and getCompRatio() + easier to understand. + """ + # class scoped cache of last transport given and zlibtransport returned + _last_trans = None + _last_z = None + + def getTransport(self, trans, compresslevel=9): + """Wrap a transport, trans, with the TZlibTransport + compressed transport class, returning a new + transport to the caller. + + @param compresslevel: The zlib compression level, ranging + from 0 (no compression) to 9 (best compression). Defaults to 9. + @type compresslevel: int + + This method returns a TZlibTransport which wraps the + passed C{trans} TTransport derived instance. + """ + if trans == self._last_trans: + return self._last_z + ztrans = TZlibTransport(trans, compresslevel) + self._last_trans = trans + self._last_z = ztrans + return ztrans + + +class TZlibTransport(TTransportBase, CReadableTransport): + """Class that wraps a transport with zlib, compressing writes + and decompresses reads, using the python standard + library zlib module. + """ + # Read buffer size for the python fastbinary C extension, + # the TBinaryProtocolAccelerated class. + DEFAULT_BUFFSIZE = 4096 + + def __init__(self, trans, compresslevel=9): + """Create a new TZlibTransport, wrapping C{trans}, another + TTransport derived object. + + @param trans: A thrift transport object, i.e. a TSocket() object. + @type trans: TTransport + @param compresslevel: The zlib compression level, ranging + from 0 (no compression) to 9 (best compression). Default is 9. + @type compresslevel: int + """ + self.__trans = trans + self.compresslevel = compresslevel + self.__rbuf = StringIO() + self.__wbuf = StringIO() + self._init_zlib() + self._init_stats() + + def _reinit_buffers(self): + """Internal method to initialize/reset the internal StringIO objects + for read and write buffers. + """ + self.__rbuf = StringIO() + self.__wbuf = StringIO() + + def _init_stats(self): + """Internal method to reset the internal statistics counters + for compression ratios and bandwidth savings. + """ + self.bytes_in = 0 + self.bytes_out = 0 + self.bytes_in_comp = 0 + self.bytes_out_comp = 0 + + def _init_zlib(self): + """Internal method for setting up the zlib compression and + decompression objects. + """ + self._zcomp_read = zlib.decompressobj() + self._zcomp_write = zlib.compressobj(self.compresslevel) + + def getCompRatio(self): + """Get the current measured compression ratios (in,out) from + this transport. + + Returns a tuple of: + (inbound_compression_ratio, outbound_compression_ratio) + + The compression ratios are computed as: + compressed / uncompressed + + E.g., data that compresses by 10x will have a ratio of: 0.10 + and data that compresses to half of ts original size will + have a ratio of 0.5 + + None is returned if no bytes have yet been processed in + a particular direction. + """ + r_percent, w_percent = (None, None) + if self.bytes_in > 0: + r_percent = self.bytes_in_comp / self.bytes_in + if self.bytes_out > 0: + w_percent = self.bytes_out_comp / self.bytes_out + return (r_percent, w_percent) + + def getCompSavings(self): + """Get the current count of saved bytes due to data + compression. + + Returns a tuple of: + (inbound_saved_bytes, outbound_saved_bytes) + + Note: if compression is actually expanding your + data (only likely with very tiny thrift objects), then + the values returned will be negative. + """ + r_saved = self.bytes_in - self.bytes_in_comp + w_saved = self.bytes_out - self.bytes_out_comp + return (r_saved, w_saved) + + def isOpen(self): + """Return the underlying transport's open status""" + return self.__trans.isOpen() + + def open(self): + """Open the underlying transport""" + self._init_stats() + return self.__trans.open() + + def listen(self): + """Invoke the underlying transport's listen() method""" + self.__trans.listen() + + def accept(self): + """Accept connections on the underlying transport""" + return self.__trans.accept() + + def close(self): + """Close the underlying transport,""" + self._reinit_buffers() + self._init_zlib() + return self.__trans.close() + + def read(self, sz): + """Read up to sz bytes from the decompressed bytes buffer, and + read from the underlying transport if the decompression + buffer is empty. + """ + ret = self.__rbuf.read(sz) + if len(ret) > 0: + return ret + # keep reading from transport until something comes back + while True: + if self.readComp(sz): + break + ret = self.__rbuf.read(sz) + return ret + + def readComp(self, sz): + """Read compressed data from the underlying transport, then + decompress it and append it to the internal StringIO read buffer + """ + zbuf = self.__trans.read(sz) + zbuf = self._zcomp_read.unconsumed_tail + zbuf + buf = self._zcomp_read.decompress(zbuf) + self.bytes_in += len(zbuf) + self.bytes_in_comp += len(buf) + old = self.__rbuf.read() + self.__rbuf = StringIO(old + buf) + if len(old) + len(buf) == 0: + return False + return True + + def write(self, buf): + """Write some bytes, putting them into the internal write + buffer for eventual compression. + """ + self.__wbuf.write(buf) + + def flush(self): + """Flush any queued up data in the write buffer and ensure the + compression buffer is flushed out to the underlying transport + """ + wout = self.__wbuf.getvalue() + if len(wout) > 0: + zbuf = self._zcomp_write.compress(wout) + self.bytes_out += len(wout) + self.bytes_out_comp += len(zbuf) + else: + zbuf = '' + ztail = self._zcomp_write.flush(zlib.Z_SYNC_FLUSH) + self.bytes_out_comp += len(ztail) + if (len(zbuf) + len(ztail)) > 0: + self.__wbuf = StringIO() + self.__trans.write(zbuf + ztail) + self.__trans.flush() + + @property + def cstringio_buf(self): + """Implement the CReadableTransport interface""" + return self.__rbuf + + def cstringio_refill(self, partialread, reqlen): + """Implement the CReadableTransport interface for refill""" + retstring = partialread + if reqlen < self.DEFAULT_BUFFSIZE: + retstring += self.read(self.DEFAULT_BUFFSIZE) + while len(retstring) < reqlen: + retstring += self.read(reqlen - len(retstring)) + self.__rbuf = StringIO(retstring) + return self.__rbuf From 718d242ffe463d48289715674dfc2d5d9ac02fcc Mon Sep 17 00:00:00 2001 From: freemansw1 Date: Sun, 17 Apr 2016 18:22:20 -0600 Subject: [PATCH 3/7] Fixing bugs --- .gitignore | 2 ++ dynamicserialize/ThriftSerializationContext.py | 11 +++++------ dynamicserialize/adapters/__init__.py | 2 +- dynamicserialize/dstypes/__init__.py | 1 - .../activetable/OperationalActiveTableRecord.py | 2 +- .../common/activetable/PracticeActiveTableRecord.py | 2 +- .../server/notify/GridHistoryUpdateNotification.py | 2 +- .../gfe/server/notify/GridUpdateNotification.py | 2 +- .../dataplugin/gfe/server/notify/LockNotification.py | 2 +- .../notify/ServiceBackupJobStatusNotification.py | 2 +- .../gfe/server/notify/UserMessageNotification.py | 3 +-- .../com/raytheon/uf/common/dataplugin/level/Level.py | 2 +- 12 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 3d978be..b496937 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .ipynb_checkpoints docs/build/ + +*.pyc diff --git a/dynamicserialize/ThriftSerializationContext.py b/dynamicserialize/ThriftSerializationContext.py index ee8ebfa..c9ffaea 100644 --- a/dynamicserialize/ThriftSerializationContext.py +++ b/dynamicserialize/ThriftSerializationContext.py @@ -44,12 +44,11 @@ from thrift.Thrift import TType import inspect, sys, types import dynamicserialize from dynamicserialize import dstypes, adapters -from . import SelfDescribingBinaryProtocol +from dynamicserialize import SelfDescribingBinaryProtocol import numpy import collections dsObjTypes = {} - def buildObjMap(module): if '__all__' in module.__dict__: for i in module.__all__: @@ -75,7 +74,7 @@ pythonToThriftMap = { float: SelfDescribingBinaryProtocol.FLOAT, #types.FloatType: TType.DOUBLE, bool: TType.BOOL, - types.InstanceType: TType.STRUCT, + object: TType.STRUCT, type(None): TType.VOID, numpy.float32: SelfDescribingBinaryProtocol.FLOAT, numpy.int32: TType.I32, @@ -180,7 +179,7 @@ class ThriftSerializationContext(object): if b in self.typeDeserializationMethod: return self.typeDeserializationMethod[b]() else: - raise dynamicserialize.SerializationException("Unsupported type value " + str(b)) + raise SerializationException("Unsupported type value " + str(b)) def _deserializeField(self, structname, obj): @@ -200,9 +199,9 @@ class ThriftSerializationContext(object): if isinstance(setMethod, collections.Callable): setMethod(result) else: - raise dynamicserialize.SerializationException("Couldn't find setter method " + lookingFor) + raise SerializationException("Couldn't find setter method " + lookingFor) except: - raise dynamicserialize.SerializationException("Couldn't find setter method " + lookingFor) + raise SerializationException("Couldn't find setter method " + lookingFor) self.protocol.readFieldEnd() return True diff --git a/dynamicserialize/adapters/__init__.py b/dynamicserialize/adapters/__init__.py index 24db1bc..aa0e0f1 100644 --- a/dynamicserialize/adapters/__init__.py +++ b/dynamicserialize/adapters/__init__.py @@ -66,7 +66,7 @@ classAdapterRegistry = {} def getAdapterRegistry(): import sys for x in __all__: - exec('import ' + x) + exec('import dynamicserialize.adapters.' + x ) m = sys.modules['dynamicserialize.adapters.' + x] d = m.__dict__ if 'ClassAdapter' in d: diff --git a/dynamicserialize/dstypes/__init__.py b/dynamicserialize/dstypes/__init__.py index 6a8f2da..2757246 100644 --- a/dynamicserialize/dstypes/__init__.py +++ b/dynamicserialize/dstypes/__init__.py @@ -26,4 +26,3 @@ __all__ = [ 'java' ] - diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/OperationalActiveTableRecord.py b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/OperationalActiveTableRecord.py index 1c7dbbc..1c191e3 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/OperationalActiveTableRecord.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/OperationalActiveTableRecord.py @@ -28,7 +28,7 @@ from . import ActiveTableRecord -class OperationalActiveTableRecord(ActiveTableRecord.ActiveTableRecord): +class OperationalActiveTableRecord(ActiveTableRecord): def __init__(self): super(OperationalActiveTableRecord, self).__init__() diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/PracticeActiveTableRecord.py b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/PracticeActiveTableRecord.py index a9174f1..ca49cba 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/PracticeActiveTableRecord.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/PracticeActiveTableRecord.py @@ -28,7 +28,7 @@ from . import ActiveTableRecord -class PracticeActiveTableRecord(ActiveTableRecord.ActiveTableRecord): +class PracticeActiveTableRecord(ActiveTableRecord): def __init__(self): super(PracticeActiveTableRecord, self).__init__() diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridHistoryUpdateNotification.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridHistoryUpdateNotification.py index cf8c116..2bf448c 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridHistoryUpdateNotification.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridHistoryUpdateNotification.py @@ -28,7 +28,7 @@ from . import GfeNotification -class GridHistoryUpdateNotification(GfeNotification.GfeNotification): +class GridHistoryUpdateNotification(GfeNotification): def __init__(self): super(GridHistoryUpdateNotification, self).__init__() diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridUpdateNotification.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridUpdateNotification.py index 9be3e40..b0dcef6 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridUpdateNotification.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GridUpdateNotification.py @@ -29,7 +29,7 @@ from . import GfeNotification -class GridUpdateNotification(GfeNotification.GfeNotification): +class GridUpdateNotification(GfeNotification): def __init__(self): super(GridUpdateNotification, self).__init__() diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/LockNotification.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/LockNotification.py index 454225b..abed54e 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/LockNotification.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/LockNotification.py @@ -29,7 +29,7 @@ from . import GfeNotification -class LockNotification(GfeNotification.GfeNotification): +class LockNotification(GfeNotification): def __init__(self): super(LockNotification, self).__init__() diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/ServiceBackupJobStatusNotification.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/ServiceBackupJobStatusNotification.py index 20d15b3..78b1283 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/ServiceBackupJobStatusNotification.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/ServiceBackupJobStatusNotification.py @@ -28,7 +28,7 @@ from . import GfeNotification -class ServiceBackupJobStatusNotification(GfeNotification.GfeNotification): +class ServiceBackupJobStatusNotification(GfeNotification): def __init__(self): super(ServiceBackupJobStatusNotification, self).__init__() diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/UserMessageNotification.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/UserMessageNotification.py index 52043af..8c6bcba 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/UserMessageNotification.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/UserMessageNotification.py @@ -27,8 +27,7 @@ ## from . import GfeNotification - -class UserMessageNotification(GfeNotification.GfeNotification): +class UserMessageNotification(GfeNotification): def __init__(self): super(UserMessageNotification, self).__init__() diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py index 14b658f..309f9d7 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py @@ -36,7 +36,7 @@ import numpy import re -from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.level import MasterLevel +from .MasterLevel import MasterLevel LEVEL_NAMING_REGEX = re.compile("^(\d*(?:\.\d*)?)(?:_(\d*(?:\.\d*)?))?([a-zA-Z]+)$") From 91f230b45a6262ae1c28afa0b8913d4e126cc02e Mon Sep 17 00:00:00 2001 From: freemansw1 Date: Sun, 17 Apr 2016 19:38:33 -0600 Subject: [PATCH 4/7] fixing for python 2 compatibility now requires module six --- awips/ThriftClient.py | 12 +++++++----- awips/dataaccess/__init__.py | 6 +++--- .../uf/common/activetable/ActiveTableRecord.py | 4 ++-- .../uf/common/auth/resp/AbstractFailedResponse.py | 3 ++- .../dataaccess/request/AbstractDataAccessRequest.py | 4 ++-- .../dataaccess/request/AbstractIdentifierRequest.py | 3 ++- .../dataaccess/response/AbstractResponseData.py | 3 ++- .../dataplugin/gfe/request/AbstractGfeRequest.py | 3 ++- .../dataplugin/gfe/request/GetGridDataRequest.py | 3 ++- .../dataplugin/gfe/server/notify/GfeNotification.py | 3 ++- .../common/dataplugin/gfe/slice/AbstractGridSlice.py | 4 ++-- .../stream/AbstractLocalizationStreamRequest.py | 3 ++- .../dstypes/com/raytheon/uf/common/message/WsId.py | 5 ++++- setup.py | 2 +- 14 files changed, 35 insertions(+), 23 deletions(-) diff --git a/awips/ThriftClient.py b/awips/ThriftClient.py index 94b24d9..38ed1cc 100644 --- a/awips/ThriftClient.py +++ b/awips/ThriftClient.py @@ -17,8 +17,10 @@ # See the AWIPS II Master Rights File ("Master Rights File.pdf") for # further licensing information. ## - -import http.client +try: + import http.client as httpcl +except ImportError: + import httplib as httpcl from dynamicserialize import DynamicSerializationManager from dynamicserialize.dstypes.com.raytheon.uf.common.serialization.comm.response import ServerErrorResponse from dynamicserialize.dstypes.com.raytheon.uf.common.serialization import SerializableExceptionWrapper @@ -54,12 +56,12 @@ class ThriftClient: if (len(hostParts) > 1): hostString = hostParts[0] self.__uri = "/" + hostParts[1] - self.__httpConn = http.client.HTTPConnection(hostString) + self.__httpConn = httpcl.HTTPConnection(hostString) else: if (port is None): - self.__httpConn = http.client.HTTPConnection(host) + self.__httpConn = httpcl.HTTPConnection(host) else: - self.__httpConn = http.client.HTTPConnection(host, port) + self.__httpConn = httpcl.HTTPConnection(host, port) self.__uri = uri diff --git a/awips/dataaccess/__init__.py b/awips/dataaccess/__init__.py index 389f6e4..c84c076 100644 --- a/awips/dataaccess/__init__.py +++ b/awips/dataaccess/__init__.py @@ -41,8 +41,8 @@ __all__ = [ ] import abc - -class IDataRequest(object, metaclass=abc.ABCMeta): +from six import with_metaclass +class IDataRequest(with_metaclass(abc.ABCMeta, object)): """ An IDataRequest to be submitted to the DataAccessLayer to retrieve data. """ @@ -163,7 +163,7 @@ class IDataRequest(object, metaclass=abc.ABCMeta): -class IData(object, metaclass=abc.ABCMeta): +class IData(with_metaclass(abc.ABCMeta, object)): """ An IData representing data returned from the DataAccessLayer. """ diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/ActiveTableRecord.py b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/ActiveTableRecord.py index d201ccb..a1e3106 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/ActiveTableRecord.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/activetable/ActiveTableRecord.py @@ -28,8 +28,8 @@ from . import ActiveTableKey import abc - -class ActiveTableRecord(object, metaclass=abc.ABCMeta): +from six import with_metaclass +class ActiveTableRecord(with_metaclass(abc.ABCMeta, object)): @abc.abstractmethod def __init__(self): self.key = ActiveTableKey.ActiveTableKey() diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/AbstractFailedResponse.py b/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/AbstractFailedResponse.py index e852ae9..2d6e991 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/AbstractFailedResponse.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/auth/resp/AbstractFailedResponse.py @@ -22,8 +22,9 @@ import abc +from six import with_metaclass -class AbstractFailedResponse(object, metaclass=abc.ABCMeta): +class AbstractFailedResponse(with_metaclass(abc.ABCMeta, object)): @abc.abstractmethod def __init__(self): self.request = None diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractDataAccessRequest.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractDataAccessRequest.py index a70c46f..9ce388e 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractDataAccessRequest.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractDataAccessRequest.py @@ -31,8 +31,8 @@ import abc - -class AbstractDataAccessRequest(object, metaclass=abc.ABCMeta): +from six import with_metaclass +class AbstractDataAccessRequest(with_metaclass(abc.ABCMeta, object)): def __init__(self): self.requestParameters = None diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractIdentifierRequest.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractIdentifierRequest.py index 337035c..eeca6ca 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractIdentifierRequest.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/request/AbstractIdentifierRequest.py @@ -30,8 +30,9 @@ # import abc +from six import with_metaclass -class AbstractIdentifierRequest(object, metaclass=abc.ABCMeta): +class AbstractIdentifierRequest(with_metaclass(abc.ABCMeta, object)): def __init__(self): self.datatype = None diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/AbstractResponseData.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/AbstractResponseData.py index 7e9520a..6482ec5 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/AbstractResponseData.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataaccess/response/AbstractResponseData.py @@ -21,9 +21,10 @@ # File auto-generated against equivalent DynamicSerialize Java class import abc +from six import with_metaclass -class AbstractResponseData(object, metaclass=abc.ABCMeta): +class AbstractResponseData(with_metaclass(abc.ABCMeta, object)): @abc.abstractmethod def __init__(self): self.time = None diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfeRequest.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfeRequest.py index f5c8209..b31ba16 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfeRequest.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/AbstractGfeRequest.py @@ -21,9 +21,10 @@ # File auto-generated against equivalent DynamicSerialize Java class import abc +from six import with_metaclass -class AbstractGfeRequest(object, metaclass=abc.ABCMeta): +class AbstractGfeRequest(with_metaclass(abc.ABCMeta, object)): @abc.abstractmethod def __init__(self): self.siteID = None diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/GetGridDataRequest.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/GetGridDataRequest.py index 41b666c..725c3a3 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/GetGridDataRequest.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/request/GetGridDataRequest.py @@ -23,9 +23,10 @@ import abc from dynamicserialize.dstypes.com.raytheon.uf.common.dataplugin.gfe.server.request import GetGridRequest +from six import with_metaclass -class GetGridDataRequest(object, metaclass=abc.ABCMeta): +class GetGridDataRequest(with_metaclass(abc.ABCMeta, object)): @abc.abstractmethod def __init__(self): self.requests = [] diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GfeNotification.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GfeNotification.py index dd2fca7..d0f0ad8 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GfeNotification.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/server/notify/GfeNotification.py @@ -25,8 +25,9 @@ # ## import abc +from six import with_metaclass -class GfeNotification(object, metaclass=abc.ABCMeta): +class GfeNotification(with_metaclass(abc.ABCMeta, object)): @abc.abstractmethod def __init__(self): self.siteID = None diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/AbstractGridSlice.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/AbstractGridSlice.py index 7faae2b..65832cd 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/AbstractGridSlice.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/gfe/slice/AbstractGridSlice.py @@ -19,9 +19,9 @@ ## import abc +from six import with_metaclass - -class AbstractGridSlice(object, metaclass=abc.ABCMeta): +class AbstractGridSlice(with_metaclass(abc.ABCMeta, object)): @abc.abstractmethod def __init__(self): self.validTime = None diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/AbstractLocalizationStreamRequest.py b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/AbstractLocalizationStreamRequest.py index 58d2fb9..c0a61e9 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/AbstractLocalizationStreamRequest.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/localization/stream/AbstractLocalizationStreamRequest.py @@ -23,8 +23,9 @@ import abc import os from dynamicserialize.dstypes.com.raytheon.uf.common.plugin.nwsauth.user import User +from six import with_metaclass -class AbstractLocalizationStreamRequest(object, metaclass=abc.ABCMeta): +class AbstractLocalizationStreamRequest(with_metaclass(abc.ABCMeta, object)): @abc.abstractmethod def __init__(self): self.context = None diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/message/WsId.py b/dynamicserialize/dstypes/com/raytheon/uf/common/message/WsId.py index 33627ed..7a73d09 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/message/WsId.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/message/WsId.py @@ -31,7 +31,10 @@ import struct import socket import os import pwd -import _thread +try: + import _thread +except ImportError: + import thread as _thread class WsId(object): diff --git a/setup.py b/setup.py index 1b9169a..fe6c986 100644 --- a/setup.py +++ b/setup.py @@ -11,6 +11,6 @@ setup( download_url='https://github.com/Unidata/python-awips/tarball/0.9.3', author='Unidata', author_email='mjames@ucar.edu', - requires=['argparse','shapely','numpy'] + requires=['argparse','shapely','numpy','six'] ) From aae0d15bc0735b12bdce3d393c1d6a14a03fa6c7 Mon Sep 17 00:00:00 2001 From: freemansw1 Date: Mon, 18 Apr 2016 22:43:57 -0600 Subject: [PATCH 5/7] Fixing more python 3 unicode errors --- awips/ThriftClient.py | 3 +- .../ThriftSerializationContext.py | 18 ++++++---- .../uf/common/dataplugin/level/Level.py | 2 +- .../com/raytheon/uf/common/time/DataTime.py | 4 +-- thrift/protocol/TBinaryProtocol.py | 6 +++- thrift/transport/TTransport.py | 34 +++++++++++-------- 6 files changed, 40 insertions(+), 27 deletions(-) diff --git a/awips/ThriftClient.py b/awips/ThriftClient.py index 38ed1cc..c2908a1 100644 --- a/awips/ThriftClient.py +++ b/awips/ThriftClient.py @@ -69,14 +69,13 @@ class ThriftClient: def sendRequest(self, request, uri="/thrift"): message = self.__dsm.serializeObject(request) - + #message = message.decode('cp437') self.__httpConn.connect() self.__httpConn.request("POST", self.__uri + uri, message) response = self.__httpConn.getresponse() if (response.status != 200): raise ThriftRequestException("Unable to post request to server") - rval = self.__dsm.deserializeBytes(response.read()) self.__httpConn.close() diff --git a/dynamicserialize/ThriftSerializationContext.py b/dynamicserialize/ThriftSerializationContext.py index c9ffaea..a68d96f 100644 --- a/dynamicserialize/ThriftSerializationContext.py +++ b/dynamicserialize/ThriftSerializationContext.py @@ -75,6 +75,7 @@ pythonToThriftMap = { #types.FloatType: TType.DOUBLE, bool: TType.BOOL, object: TType.STRUCT, + str: TType.STRING, type(None): TType.VOID, numpy.float32: SelfDescribingBinaryProtocol.FLOAT, numpy.int32: TType.I32, @@ -151,13 +152,15 @@ class ThriftSerializationContext(object): def deserializeMessage(self): name = self.protocol.readStructBegin() - name = name.replace('_', '.') + #print(name) + name = name.replace(b'_', b'.') + bytes(name) if name.isdigit(): obj = self._deserializeType(int(name)) return obj elif name in adapters.classAdapterRegistry: return adapters.classAdapterRegistry[name].deserialize(self) - elif name.find('$') > -1: + elif name.find(b'$') > -1: # it's an inner class, we're going to hope it's an enum, treat it special fieldName, fieldType, fieldId = self.protocol.readFieldBegin() if fieldName != '__enumValue__': @@ -166,7 +169,7 @@ class ThriftSerializationContext(object): self.protocol.readFieldEnd() return obj else: - clz = dsObjTypes[name] + clz = dsObjTypes[bytes.decode(name)] obj = clz() while self._deserializeField(name, obj): @@ -191,7 +194,8 @@ class ThriftSerializationContext(object): # result = adapters.fieldAdapterRegistry[structname][fieldName].deserialize(self) # else: 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: setMethod = getattr(obj, lookingFor) @@ -244,13 +248,13 @@ class ThriftSerializationContext(object): if pyt in pythonToThriftMap: return pythonToThriftMap[pyt] elif pyt.__module__.startswith('dynamicserialize.dstypes'): - return pythonToThriftMap[types.InstanceType] + return pythonToThriftMap[object] else: raise dynamicserialize.SerializationException("Don't know how to serialize object of type: " + str(pyt)) def serializeMessage(self, obj): + tt = self._lookupType(obj) - if tt == TType.STRUCT: fqn = obj.__module__.replace('dynamicserialize.dstypes.', '') if fqn in adapters.classAdapterRegistry: @@ -288,9 +292,11 @@ class ThriftSerializationContext(object): self.protocol.writeStructEnd() def _serializeField(self, fieldName, fieldType, fieldId, fieldValue): + #print("SERFIELD", fieldName, fieldType, fieldId, fieldValue) self.protocol.writeFieldBegin(fieldName, fieldType, fieldId) self._serializeType(fieldValue, fieldType) self.protocol.writeFieldEnd() + #print(self.protocol) def _serializeType(self, fieldValue, fieldType): if fieldType in self.typeSerializationMethod: diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py index 309f9d7..32bc996 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/dataplugin/level/Level.py @@ -55,7 +55,7 @@ class Level(object): matcher = LEVEL_NAMING_REGEX.match(str(levelString)) if matcher is not None: self.levelonevalue = numpy.float64(matcher.group(1)) - self.masterLevel = MasterLevel.MasterLevel(matcher.group(3)) + self.masterLevel = MasterLevel(matcher.group(3)) levelTwo = matcher.group(2) if levelTwo: self.leveltwovalue = numpy.float64(levelTwo) diff --git a/dynamicserialize/dstypes/com/raytheon/uf/common/time/DataTime.py b/dynamicserialize/dstypes/com/raytheon/uf/common/time/DataTime.py index af96b40..6dc4088 100644 --- a/dynamicserialize/dstypes/com/raytheon/uf/common/time/DataTime.py +++ b/dynamicserialize/dstypes/com/raytheon/uf/common/time/DataTime.py @@ -40,7 +40,7 @@ import calendar import datetime import numpy import time -import io +from six.moves import cStringIO as StringIO from dynamicserialize.dstypes.java.util import Date from dynamicserialize.dstypes.java.util import EnumSet @@ -114,7 +114,7 @@ class DataTime(object): self.levelValue = numpy.float64(levelValue) def __str__(self): - buffer = io.StringIO() + buffer = StringIO() if self.refTime is not None: refTimeInSecs = self.refTime.getTime() / 1000 diff --git a/thrift/protocol/TBinaryProtocol.py b/thrift/protocol/TBinaryProtocol.py index 2af4a2d..dbcb1e9 100644 --- a/thrift/protocol/TBinaryProtocol.py +++ b/thrift/protocol/TBinaryProtocol.py @@ -204,7 +204,11 @@ class TBinaryProtocol(TProtocolBase): def readI32(self): buff = self.trans.readAll(4) - val, = unpack('!i', buff) + try: + val, = unpack('!i', buff) + except TypeError: + #str does not support the buffer interface + val, = unpack('!i', buff) return val def readI64(self): diff --git a/thrift/transport/TTransport.py b/thrift/transport/TTransport.py index eae4b9a..c72ad06 100644 --- a/thrift/transport/TTransport.py +++ b/thrift/transport/TTransport.py @@ -17,7 +17,7 @@ # under the License. # -from io import StringIO +from six import BytesIO from struct import pack, unpack from thrift.Thrift import TException @@ -52,9 +52,10 @@ class TTransportBase: pass def readAll(self, sz): - buff = '' + buff = b'' have = 0 while (have < sz): + #print(self) chunk = self.read(sz - have) have += len(chunk) buff += chunk @@ -138,8 +139,8 @@ class TBufferedTransport(TTransportBase, CReadableTransport): def __init__(self, trans, rbuf_size=DEFAULT_BUFFER): self.__trans = trans - self.__wbuf = StringIO() - self.__rbuf = StringIO("") + self.__wbuf = BytesIO() + self.__rbuf = BytesIO("") self.__rbuf_size = rbuf_size def isOpen(self): @@ -156,7 +157,7 @@ class TBufferedTransport(TTransportBase, CReadableTransport): if len(ret) != 0: return ret - self.__rbuf = StringIO(self.__trans.read(max(sz, self.__rbuf_size))) + self.__rbuf = BytesIO(self.__trans.read(max(sz, self.__rbuf_size))) return self.__rbuf.read(sz) def write(self, buf): @@ -165,7 +166,7 @@ class TBufferedTransport(TTransportBase, CReadableTransport): def flush(self): out = self.__wbuf.getvalue() # reset wbuf before write/flush to preserve state on underlying failure - self.__wbuf = StringIO() + self.__wbuf = BytesIO() self.__trans.write(out) self.__trans.flush() @@ -184,7 +185,7 @@ class TBufferedTransport(TTransportBase, CReadableTransport): if len(retstring) < reqlen: retstring += self.__trans.readAll(reqlen - len(retstring)) - self.__rbuf = StringIO(retstring) + self.__rbuf = BytesIO(retstring) return self.__rbuf @@ -203,9 +204,9 @@ class TMemoryBuffer(TTransportBase, CReadableTransport): If value is set, this will be a transport for reading, otherwise, it is for writing""" if value is not None: - self._buffer = StringIO(value) + self._buffer = BytesIO(value) else: - self._buffer = StringIO() + self._buffer = BytesIO() def isOpen(self): return not self._buffer.closed @@ -220,7 +221,10 @@ class TMemoryBuffer(TTransportBase, CReadableTransport): return self._buffer.read(sz) def write(self, buf): - self._buffer.write(buf) + try: + self._buffer.write(buf) + except TypeError: + self._buffer.write(buf.encode('cp437')) def flush(self): pass @@ -251,8 +255,8 @@ class TFramedTransport(TTransportBase, CReadableTransport): def __init__(self, trans,): self.__trans = trans - self.__rbuf = StringIO() - self.__wbuf = StringIO() + self.__rbuf = BytesIO() + self.__wbuf = BytesIO() def isOpen(self): return self.__trans.isOpen() @@ -274,7 +278,7 @@ class TFramedTransport(TTransportBase, CReadableTransport): def readFrame(self): buff = self.__trans.readAll(4) sz, = unpack('!i', buff) - self.__rbuf = StringIO(self.__trans.readAll(sz)) + self.__rbuf = BytesIO(self.__trans.readAll(sz)) def write(self, buf): self.__wbuf.write(buf) @@ -283,7 +287,7 @@ class TFramedTransport(TTransportBase, CReadableTransport): wout = self.__wbuf.getvalue() wsz = len(wout) # reset wbuf before write/flush to preserve state on underlying failure - self.__wbuf = StringIO() + self.__wbuf = BytesIO() # N.B.: Doing this string concatenation is WAY cheaper than making # two separate calls to the underlying socket object. Socket writes in # Python turn out to be REALLY expensive, but it seems to do a pretty @@ -304,7 +308,7 @@ class TFramedTransport(TTransportBase, CReadableTransport): while len(prefix) < reqlen: self.readFrame() prefix += self.__rbuf.getvalue() - self.__rbuf = StringIO(prefix) + self.__rbuf = BytesIO(prefix) return self.__rbuf From 35f3568d240ad5b1c8b070669b3215fffb57edcc Mon Sep 17 00:00:00 2001 From: freemansw1 Date: Mon, 18 Apr 2016 23:01:56 -0600 Subject: [PATCH 6/7] fixed silly bytes/string error. --- dynamicserialize/ThriftSerializationContext.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dynamicserialize/ThriftSerializationContext.py b/dynamicserialize/ThriftSerializationContext.py index a68d96f..8b0e508 100644 --- a/dynamicserialize/ThriftSerializationContext.py +++ b/dynamicserialize/ThriftSerializationContext.py @@ -152,15 +152,17 @@ class ThriftSerializationContext(object): def deserializeMessage(self): name = self.protocol.readStructBegin() - #print(name) name = name.replace(b'_', b'.') - bytes(name) + name = name.decode('cp437') + print(name, name in adapters.classAdapterRegistry) if name.isdigit(): + print("before deserialize", name) obj = self._deserializeType(int(name)) + print("Object", obj, name) return obj elif name in adapters.classAdapterRegistry: return adapters.classAdapterRegistry[name].deserialize(self) - elif name.find(b'$') > -1: + elif name.find('$') > -1: # it's an inner class, we're going to hope it's an enum, treat it special fieldName, fieldType, fieldId = self.protocol.readFieldBegin() if fieldName != '__enumValue__': @@ -169,7 +171,7 @@ class ThriftSerializationContext(object): self.protocol.readFieldEnd() return obj else: - clz = dsObjTypes[bytes.decode(name)] + clz = dsObjTypes[name] obj = clz() while self._deserializeField(name, obj): From ac7ddd17e1cc47df0f311bfd3a6677e966be5097 Mon Sep 17 00:00:00 2001 From: freemansw1 Date: Tue, 19 Apr 2016 10:30:36 -0600 Subject: [PATCH 7/7] Fixed radar data --- awips/RadarCommon.py | 8 ++++---- dynamicserialize/ThriftSerializationContext.py | 7 ++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/awips/RadarCommon.py b/awips/RadarCommon.py index c0f592a..a4fe0b4 100644 --- a/awips/RadarCommon.py +++ b/awips/RadarCommon.py @@ -60,14 +60,14 @@ def get_hdf5_data(idra): threshVals = [] if len(idra) > 0: for ii in range(len(idra)): - if idra[ii].getName() == "Data": + if idra[ii].getName() == b"Data": rdat = idra[ii] - elif idra[ii].getName() == "Angles": + elif idra[ii].getName() == b"Angles": azdat = idra[ii] dattyp = "radial" - elif idra[ii].getName() == "DependentValues": + elif idra[ii].getName() == b"DependentValues": depVals = idra[ii].getShortData() - elif idra[ii].getName() == "Thresholds": + elif idra[ii].getName() == b"Thresholds": threshVals = idra[ii].getShortData() return rdat,azdat,depVals,threshVals diff --git a/dynamicserialize/ThriftSerializationContext.py b/dynamicserialize/ThriftSerializationContext.py index 8b0e508..d7de565 100644 --- a/dynamicserialize/ThriftSerializationContext.py +++ b/dynamicserialize/ThriftSerializationContext.py @@ -154,18 +154,15 @@ class ThriftSerializationContext(object): name = self.protocol.readStructBegin() name = name.replace(b'_', b'.') name = name.decode('cp437') - print(name, name in adapters.classAdapterRegistry) if name.isdigit(): - print("before deserialize", name) obj = self._deserializeType(int(name)) - print("Object", obj, name) return obj elif name in adapters.classAdapterRegistry: return adapters.classAdapterRegistry[name].deserialize(self) elif name.find('$') > -1: # it's an inner class, we're going to hope it's an enum, treat it special fieldName, fieldType, fieldId = self.protocol.readFieldBegin() - if fieldName != '__enumValue__': + if fieldName != b'__enumValue__': raise dynamiceserialize.SerializationException("Expected to find enum payload. Found: " + fieldName) obj = self.protocol.readString() self.protocol.readFieldEnd() @@ -184,7 +181,7 @@ class ThriftSerializationContext(object): if b in self.typeDeserializationMethod: return self.typeDeserializationMethod[b]() else: - raise SerializationException("Unsupported type value " + str(b)) + raise dynamiceserialize.SerializationException("Unsupported type value " + str(b)) def _deserializeField(self, structname, obj):