Issues (227)

awips/dataaccess/PyGridNotification.py (1 issue)

1
#
2
# Notification object that produces grid data
3
#
4
#
5
#     SOFTWARE HISTORY
6
#
7
#    Date            Ticket#       Engineer       Description
8
#    ------------    ----------    -----------    --------------------------
9
#    06/03/16        2416          rjpeter        Initial Creation.
10
#    09/06/17        6175          tgurney        Override messageReceived
11
#
12
13
import dynamicserialize
14
import traceback
15
from awips.dataaccess.PyNotification import PyNotification
16
17
18 View Code Duplication
class PyGridNotification(PyNotification):
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
19
20
    def messageReceived(self, msg):
21
        dataUriMsg = dynamicserialize.deserialize(msg)
22
        dataUris = dataUriMsg.getDataURIs()
23
        for dataUri in dataUris:
24
            if not self.notificationFilter.accept(dataUri):
25
                continue
26
            try:
27
                # This improves performance over requesting by datatime since it requests only the
28
                # parameter that the notification was received for (instead of this and all previous
29
                # parameters for the same forecast hour)
30
                # TODO: This utterly fails for derived requests
31
                newReq = self.DAL.newDataRequest(self.request.getDatatype())
32
                newReq.addIdentifier("dataURI", dataUri)
33
                newReq.setParameters(self.request.getParameters())
34
                data = self.getData(newReq, [])
35
                self.callback(data)
36
            except ValueError:
37
                traceback.print_exc()
38
39
    def getData(self, request, dataTimes):
40
        return self.DAL.getGridData(request, dataTimes)
41