Changeset 186:fdaf10ceded4
- Timestamp:
- 11/28/08 16:33:28 (3 years ago)
- Branch:
- default
- Files:
-
- 12 modified
-
StormSiren/AlertDevice.py (modified) (1 diff)
-
StormSiren/Config.py (modified) (3 diffs)
-
StormSiren/ExecutionAlertDevice.py (modified) (1 diff)
-
StormSiren/History.py (modified) (1 diff)
-
StormSiren/JabberAlertDevice.py (modified) (2 diffs)
-
StormSiren/OsdAlertDevice.py (modified) (1 diff)
-
StormSiren/SmsAlertDevice.py (modified) (1 diff)
-
StormSiren/StormConfig.py (modified) (2 diffs)
-
StormSiren/StormWeather.py (modified) (1 diff)
-
StormSiren/TestAlert.py (modified) (1 diff)
-
StormSiren/XmlWeather.py (modified) (1 diff)
-
siren (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
StormSiren/AlertDevice.py
r122 r184 59 59 self.log = logging.getLogger('AlertDevice') 60 60 61 self.log.setLevel(logging.INFO) 61 62 self.__parse_weather_types(alerts) 62 63 self.__parse_areas(areas) -
StormSiren/Config.py
r122 r184 48 48 49 49 class Config(object): 50 def __init__(self, appname, config_file = None, log_config_file = None): 51 self.log = None 50 def __init__(self, appname, config_file = None): 52 51 self.__appname = appname 53 52 self.__config_file = '' … … 55 54 self.__config_dir = self.___getConfigDir() 56 55 self.__config_file = self.__config_dir + '/' + appname + '.conf' 57 self. __log_config_file = self.__config_dir + '/' + appname + '-log.conf'56 self.log = logging.getLogger('Config') 58 57 59 if(log_config_file): 60 self.__log_config_file = log_config_file 61 62 if(os.path.exists(self.__log_config_file)): 63 logging.config.fileConfig(self.__log_config_file) 64 else: 65 print("Log configuration file [%s] not found" % self.__log_config_file) 66 print("See the example StormSiren-log.conf file in the examples directory") 67 if(not os.path.exists(self.__config_dir)): 68 os.mkdir(self.__config_dir) 69 sys.exit(1) 70 71 self.log = logging.getLogger('Config') 72 self.log.debug("Using logging configuration file %s" % self.__log_config_file) 58 self.log.setLevel(logging.INFO) 73 59 74 60 if(config_file): 75 61 self.__config_file = config_file 76 self.log.info("Override configuration file %s" % self.__config_file)77 62 78 63 if(os.path.exists(self.__config_file)): 79 64 self.log.debug("Using configuration file with %s" % self.__config_file) 80 self.__configParser.read(self.__config_file)81 self._load()82 65 else: 83 66 self.log.error("Configuration file [%s] not found" % self.__config_file) … … 121 104 def _load(self): 122 105 self.log.debug("Loading Configuration File") 106 self.__configParser.read(self.__config_file) 123 107 124 108 def __str__(self): -
StormSiren/ExecutionAlertDevice.py
r122 r184 51 51 super(ExecutionAlertDevice,self).__init__(alerts,areas) 52 52 self.__exeInfo = exeInfo 53 self.log = logging.getLogger('ExecutionAlertDevice') 54 self.log.setLevel(logging.DEBUG) 53 55 54 56 def display(self): -
StormSiren/History.py
r122 r184 57 57 self.log = logging.getLogger('History') 58 58 self.modified = False 59 60 self.log.setLevel(logging.INFO) 59 61 60 62 # See if we can open the history file. -
StormSiren/JabberAlertDevice.py
r122 r184 49 49 pass 50 50 51 52 51 from AlertDevice import * 53 52 … … 61 60 self.__to = to 62 61 self.a = alerts 62 self.log = logging.getLogger('JabberAlertDevice') 63 64 self.log.setLevel(logging.INFO) 63 65 64 66 def display(self): -
StormSiren/OsdAlertDevice.py
r122 r184 63 63 super(OsdAlertDevice,self).__init__(alerts,areas) 64 64 self.__osdInfo = osdInfo 65 self.log = logging.getLogger('OsdAlertDevice') 66 67 self.log.setLevel(logging.INFO) 65 68 66 69 def display(self): -
StormSiren/SmsAlertDevice.py
r122 r184 47 47 def __init__(self, to, textwidth, smtpInfo, alerts, areas): 48 48 super(SmsAlertDevice,self).__init__(to, textwidth, smtpInfo, alerts, areas) 49 self.log = logging.getLogger('SmsAlertDevice') 50 51 self.log.setLevel(logging.INFO) 49 52 50 53 def display(self): -
StormSiren/StormConfig.py
r142 r186 59 59 60 60 class StormConfig(Config): 61 def __init__(self, config_file = None, log_config_file = None): 61 def __init__(self, config_file = None): 62 super(StormConfig,self).__init__(__APPNAME__,config_file) 63 62 64 self.__states = [] 63 65 self.devices = [] 64 self.__history_file = ''66 self.__history_file = self.config_dir + '/' + __APPNAME__ + '.history' 65 67 self.log = logging.getLogger('StormConfig') 66 68 self.__max_history = History.DEFAULT_MAX_HISTORICAL_EVENTS 67 69 self.__proxy = '' 68 70 69 super(StormConfig,self).__init__(__APPNAME__,config_file, log_config_file)70 71 self.__history_file = self.config_dir + '/' + __APPNAME__ + '.history' 71 self.log.setLevel(logging.INFO) 72 self._load() 73 72 74 73 75 def _load(self): … … 121 123 122 124 for i in range(1,int(num_watchers)+1): 123 dev = self.getRequired(str(i),"device") 124 alerts = self.getRequired(str(i),"alert") 125 areas = self.getRequired(str(i),"areas") 126 127 if(dev == "email"): 125 dev = self.getRequired(str(i),"device") 126 alerts = self.getRequired(str(i),"alert") 127 areas = self.getRequired(str(i),"areas") 128 self.log.debug("AlertDevice(%s) Areas(%s) Alerts(%s)" % (dev, alerts,areas)) 129 130 if(dev == "email"): 131 to = self.getRequired(str(i),"to") 132 textwidth = int(self.get(str(i),"textwidth",-1)) 133 self.devices.append(EmailAlertDevice(to,textwidth,smtpInfo,alerts,areas)) 134 self.log.debug("Adding email device") 135 if(dev == "sms"): 136 to = self.getRequired(str(i),"to") 137 textwidth = int(self.get(str(i),"textwidth",-1)) 138 self.devices.append(SmsAlertDevice(to,textwidth,smtpInfo,alerts,areas)) 139 self.log.debug("Adding sms device") 140 if(dev == "jabber"): 141 if(not jabberLoadAttempted): 142 jabber_available = self.__loadXmpp() 143 jabberLoadAttempted = True 144 145 if(jabber_available): 128 146 to = self.getRequired(str(i),"to") 129 textwidth = int(self.get(str(i),"textwidth",-1)) 130 self.devices.append(EmailAlertDevice(to,textwidth,smtpInfo,alerts,areas)) 131 if(dev == "sms"): 132 to = self.getRequired(str(i),"to") 133 textwidth = int(self.get(str(i),"textwidth",-1)) 134 self.devices.append(SmsAlertDevice(to,textwidth,smtpInfo,alerts,areas)) 135 if(dev == "jabber"): 136 if(not jabberLoadAttempted): 137 jabber_available = self.__loadXmpp() 138 jabberLoadAttempted = True 139 140 if(jabber_available): 141 to = self.getRequired(str(i),"to") 142 self.devices.append(JabberAlertDevice(to,jabberInfo,alerts,areas)) 143 else: 144 self.log.error("Jabber Support Not Enabled, but Jabber Device Requested!") 145 if(dev == "osd"): 146 if(not osdLoadAttempted): 147 osd_available = self.__loadOsd() 148 osdLoadAttempted = True 149 150 if(osd_available): 151 position = self.get(str(i),"position", DEFAULT_OSD_POSITION) 152 alignment = self.get(str(i),"alignment", DEFAULT_OSD_ALIGNMENT) 153 offset = int(self.get(str(i),"offset", DEFAULT_OSD_OFFSET)) 154 timeout = int(self.get(str(i),"timeout", DEFAULT_OSD_TIMEOUT)) 155 color = self.get(str(i),"color", DEFAULT_OSD_COLOR) 156 font = self.get(str(i),"font", DEFAULT_OSD_FONT) 157 self.devices.append(OsdAlertDevice(OsdAlertDeviceInfo(position, 158 alignment, 159 offset, 160 timeout, 161 color, 162 font), 163 alerts,areas)) 164 else: 165 self.log.error("OSD Support Not Enabled, but OSD Device Requested!") 166 if(dev == "mythtv"): 167 to = self.getRequired(str(i),"to") 168 wait_time = int(self.getRequired(str(i),"wait_time")) 169 self.devices.append(MythtvAlertDevice(MythtvAlertDeviceInfo(to,wait_time),alerts,areas)) 170 if(dev == "media"): 171 self.devices.append(MediaAlertDevice(mediaInfo,alerts,areas)) 172 if(dev == "execution"): 173 self.devices.append(ExecutionAlertDevice(exeInfo,alerts,areas)) 147 self.devices.append(JabberAlertDevice(to,jabberInfo,alerts,areas)) 148 self.log.debug("Adding jabber device") 149 else: 150 self.log.error("Jabber Support Not Enabled, but Jabber Device Requested!") 151 if(dev == "osd"): 152 if(not osdLoadAttempted): 153 osd_available = self.__loadOsd() 154 osdLoadAttempted = True 155 156 if(osd_available): 157 position = self.get(str(i),"position", DEFAULT_OSD_POSITION) 158 alignment = self.get(str(i),"alignment", DEFAULT_OSD_ALIGNMENT) 159 offset = int(self.get(str(i),"offset", DEFAULT_OSD_OFFSET)) 160 timeout = int(self.get(str(i),"timeout", DEFAULT_OSD_TIMEOUT)) 161 color = self.get(str(i),"color", DEFAULT_OSD_COLOR) 162 font = self.get(str(i),"font", DEFAULT_OSD_FONT) 163 self.devices.append(OsdAlertDevice(OsdAlertDeviceInfo(position, 164 alignment, 165 offset, 166 timeout, 167 color, 168 font), 169 alerts,areas)) 170 self.log.debug("Adding OSD device") 171 else: 172 self.log.error("OSD Support Not Enabled, but OSD Device Requested!") 173 if(dev == "mythtv"): 174 to = self.getRequired(str(i),"to") 175 wait_time = int(self.getRequired(str(i),"wait_time")) 176 self.devices.append(MythtvAlertDevice(MythtvAlertDeviceInfo(to,wait_time),alerts,areas)) 177 self.log.debug("Adding MythTv device") 178 if(dev == "media"): 179 self.devices.append(MediaAlertDevice(mediaInfo,alerts,areas)) 180 self.log.debug("Adding media device") 181 if(dev == "execution"): 182 self.devices.append(ExecutionAlertDevice(exeInfo,alerts,areas)) 183 self.log.debug("Adding execution device") 174 184 175 185 def __str__(self): -
StormSiren/StormWeather.py
r142 r186 56 56 self.__alert_devs = [] 57 57 self.__simalert = simalert 58 59 self.log.setLevel(logging.INFO) 58 60 59 61 def display(self): -
StormSiren/TestAlert.py
r122 r184 60 60 self.log = logging.getLogger("TestAlert") 61 61 62 self.log.setLevel(logging.INFO) 63 62 64 def fetch(self): 63 65 self.__fetch() -
StormSiren/XmlWeather.py
r143 r186 65 65 self.log = logging.getLogger("XmlWeather") 66 66 67 self.log.setLevel(logging.DEBUG) 68 67 69 def fetch(self): 68 70 self.__fetch() -
siren
r142 r186 43 43 44 44 import logging 45 import sys 45 46 from optparse import OptionParser 46 47 … … 51 52 from StormSiren.History import History, DEFAULT_MAX_HISTORICAL_EVENTS 52 53 53 __RELEASE_VERSION = "2.0 RC 3"54 __RELEASE_VERSION = "2.0 RC4" 54 55 __RELEASE_MONTH = "12" 55 __RELEASE_DAY = "0 8"56 __RELEASE_DAY = "01" 56 57 __RELEASE_YEAR = "2008" 58 59 logging.basicConfig(level=logging.INFO, 60 format='%(asctime)s - %(name)s:%(lineno)d - %(levelname)s - %(message)s') 57 61 58 62 def main(): … … 60 64 log = logging.getLogger() 61 65 66 log.setLevel(logging.DEBUG) 62 67 63 68 parser.add_option("-c", "--conf", dest="conf", … … 82 87 help="Print only important messages to the console") 83 88 84 parser.add_option("-l", "--logconf", dest="logconf",85 help="Override log configuration file", metavar="file_name", default=None)86 87 89 parser.add_option("-t", "--testpage", 88 90 action="store_true", dest="testpage", default=False, … … 96 98 logging.disable(logging.info) 97 99 98 conf = StormConfig(options.conf , options.logconf)100 conf = StormConfig(options.conf) 99 101 100 102 log.info("StormSiren: v%s (%s/%s/%s)" % (__RELEASE_VERSION, … … 111 113 #conf.display() 112 114 #history.display() 115 116 if(len(conf.devices) == 0): 117 log.error("No valid devices found, exiting..") 118 sys.exit(1) 113 119 114 120 if(not options.testpage):
