Changeset 190:75d280708ff5 for StormSiren/StormWeather.py
- Timestamp:
- 11/29/08 00:48:18 (3 years ago)
- Branch:
- default
- Parents:
- 189:8190540dae37 (diff), 185:c20e85874308 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 1 modified
-
StormSiren/StormWeather.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
StormSiren/StormWeather.py
r184 r190 48 48 from WeatherAlert import * 49 49 from XmlWeather import * 50 from CAP import CAP51 50 52 51 class StormWeather(XmlWeather): 53 def __init__(self, state, history, simfetch = False, simalert = False ):54 super(StormWeather,self).__init__(state, history,simfetch)52 def __init__(self, state, history, simfetch = False, simalert = False, proxy = None): 53 super(StormWeather,self).__init__(state,simfetch,proxy) 55 54 self.log = logging.getLogger("StormWeather") 56 55 self.__alert_devs = [] 57 56 self.__simalert = simalert 57 self.__history = history 58 58 59 59 self.log.setLevel(logging.INFO) 60 60 61 def display(self):62 return self.__str__()63 64 61 def __str__(self): 65 62 str = "StormWeather: " + "\n" … … 72 69 return str 73 70 74 def display(self):75 print self.__str__()76 77 71 def registerDevice(self, dev): 78 72 self.log.debug("Registering Device") 79 73 self.__alert_devs.append(dev) 80 74 81 def handleAlert(self, cap_item): 82 alerted = False 75 def logAtomShort(self, cap_atom): 76 self.log.info("---------CAP ATOM---------") 77 for l in (cap_atom.__str__().split('\n')): 78 self.log.info(l) 79 self.log.info("---------CAP ATOM---------") 83 80 84 for dev in self.__alert_devs: 85 if(dev.isAlertWanted(cap_item)): 86 if(not self.__simalert): 87 dev.send(WeatherAlert(cap_item)) 88 alerted = True 89 else: 90 self.log.info("Simulated Alert on: %s" % cap_item.id) 81 def logAtomFull(self, cap_atom): 82 self.log.info("---------CAP ATOM---------") 83 for l in (cap_atom.__str__().split('\n')): 84 self.log.info(l) 85 self.log.info("========DESCRIPTION=======") 86 if(cap_atom.description): 87 for l in (cap_atom.description.split('\n')): 88 self.log.info(l) 89 self.log.info("========DESCRIPTION=======") 90 self.log.info("---------CAP ATOM---------") 91 91 92 return alerted 92 def handleAtom(self, cap_atom): 93 self.logAtomShort(cap_atom) 94 if(not self.__history.exists(cap_atom.id)): 95 for dev in self.__alert_devs: 96 if(dev.isAlertWanted(cap_atom)): 97 if(not self.__simalert): 98 cap_atom.expand(self.simfetch,self.proxy) 99 self.logAtomFull(cap_atom) 100 dev.send(cap_atom) 101 self.__history.add(cap_atom.id) 102 else: 103 self.log.info("Simulated Alert on: %s" % cap_atom.id) 104 else: 105 self.log.debug("Ignoring %s: Already alerted on" % cap_atom.id)
