Exemplo n.º 1
0
 def getNotificationFromNodeByIndex (self, nodeId, index, queue = "control"):
     indexInt = int(index)
     nodeIdStr = str(nodeId)
     logger.info("From node(" + nodeIdStr + ") getting notification at index[" + str(index) + "]")
     notifications = self.notifications.find({"nodeId": str(nodeId), "queue": queue})
     notificationdict = notifications.get(indexInt)
     return fromDict(**notificationdict)
Exemplo n.º 2
0
 def getLatestNotificationFromNode (self, nodeId, queue = "control"):
     # Need to reverse sort on time
     notifications = self.notifications.find({"nodeId": str(nodeId), "queue": queue})
     for notification in notifications:
         if (notification["ignore"] == False):
             print str(notification)
             return fromDict(**notification)
     return None
Exemplo n.º 3
0
 def getEarliestNotificationOfCurrentState (self, nodeId, queue = "control"):
     nodeIdStr = str(nodeId)
     logger.info("From node(" + nodeIdStr + ") getting earliest notification of current state")
     topnotification = self.notifications.findOne({"nodeId": str(nodeId), "queue": queue}) # make sure this gets the first one.
     notifications = self.notifications.find({"nodeId": str(nodeId), "queue": queue})
     for n in notifications:
         if n.value == topnotification.value:
             topnotification = n
     return fromDict(**topnotification)
Exemplo n.º 4
0
 def getNotificationFromNodeById (self, nodeId, notificationId, queue = "control"):
     nodeIdStr = str(nodeId)
     logger.info("From node(" + nodeIdStr + ") getting notification with nid[" + str(notificationId) + "]")
     notifications = self.notifications.find({"nodeId": str(nodeId), "queue": queue, "nid": notificationId})
     notificationdict = notifications.get(0) #There should be exactly one
     return fromDict(**notificationdict)