Changeset 184:8c6eaaf8908a
- Timestamp:
- 11/28/08 15:08:22 (3 years ago)
- Branch:
- unix
- 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
r122 r184 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 66 self.__history_file = '' 67 self.__max_history = History.DEFAULT_MAX_HISTORICAL_EVENTS 68 self.__history_file = self.config_dir + '/' + __APPNAME__ + '.history' 65 69 self.log = logging.getLogger('StormConfig') 66 self.__max_history = History.DEFAULT_MAX_HISTORICAL_EVENTS 67 68 super(StormConfig,self).__init__(__APPNAME__,config_file, log_config_file) 69 70 self.__history_file = self.config_dir + '/' + __APPNAME__ + '.history' 70 71 self.log.setLevel(logging.INFO) 72 73 self._load() 71 74 72 75 def _load(self): … … 118 121 119 122 for i in range(1,int(num_watchers)+1): 120 dev = self.getRequired(str(i),"device") 121 alerts = self.getRequired(str(i),"alert") 122 areas = self.getRequired(str(i),"areas") 123 124 if(dev == "email"): 123 dev = self.getRequired(str(i),"device") 124 alerts = self.getRequired(str(i),"alert") 125 areas = self.getRequired(str(i),"areas") 126 self.log.debug("AlertDevice(%s) Areas(%s) Alerts(%s)" % (dev, alerts,areas)) 127 128 if(dev == "email"): 129 to = self.getRequired(str(i),"to") 130 textwidth = int(self.get(str(i),"textwidth",-1)) 131 self.devices.append(EmailAlertDevice(to,textwidth,smtpInfo,alerts,areas)) 132 self.log.debug("Adding email device") 133 if(dev == "sms"): 134 to = self.getRequired(str(i),"to") 135 textwidth = int(self.get(str(i),"textwidth",-1)) 136 self.devices.append(SmsAlertDevice(to,textwidth,smtpInfo,alerts,areas)) 137 self.log.debug("Adding sms device") 138 if(dev == "jabber"): 139 if(not jabberLoadAttempted): 140 jabber_available = self.__loadXmpp() 141 jabberLoadAttempted = True 142 143 if(jabber_available): 125 144 to = self.getRequired(str(i),"to") 126 textwidth = int(self.get(str(i),"textwidth",-1)) 127 self.devices.append(EmailAlertDevice(to,textwidth,smtpInfo,alerts,areas)) 128 if(dev == "sms"): 129 to = self.getRequired(str(i),"to") 130 textwidth = int(self.get(str(i),"textwidth",-1)) 131 self.devices.append(SmsAlertDevice(to,textwidth,smtpInfo,alerts,areas)) 132 if(dev == "jabber"): 133 if(not jabberLoadAttempted): 134 jabber_available = self.__loadXmpp() 135 jabberLoadAttempted = True 136 137 if(jabber_available): 138 to = self.getRequired(str(i),"to") 139 self.devices.append(JabberAlertDevice(to,jabberInfo,alerts,areas)) 140 else: 141 self.log.error("Jabber Support Not Enabled, but Jabber Device Requested!") 142 if(dev == "osd"): 143 if(not osdLoadAttempted): 144 osd_available = self.__loadOsd() 145 osdLoadAttempted = True 146 147 if(osd_available): 148 position = self.get(str(i),"position", DEFAULT_OSD_POSITION) 149 alignment = self.get(str(i),"alignment", DEFAULT_OSD_ALIGNMENT) 150 offset = int(self.get(str(i),"offset", DEFAULT_OSD_OFFSET)) 151 timeout = int(self.get(str(i),"timeout", DEFAULT_OSD_TIMEOUT)) 152 color = self.get(str(i),"color", DEFAULT_OSD_COLOR) 153 font = self.get(str(i),"font", DEFAULT_OSD_FONT) 154 self.devices.append(OsdAlertDevice(OsdAlertDeviceInfo(position, 155 alignment, 156 offset, 157 timeout, 158 color, 159 font), 160 alerts,areas)) 161 else: 162 self.log.error("OSD Support Not Enabled, but OSD Device Requested!") 163 if(dev == "mythtv"): 164 to = self.getRequired(str(i),"to") 165 wait_time = int(self.getRequired(str(i),"wait_time")) 166 self.devices.append(MythtvAlertDevice(MythtvAlertDeviceInfo(to,wait_time),alerts,areas)) 167 if(dev == "media"): 168 self.devices.append(MediaAlertDevice(mediaInfo,alerts,areas)) 169 if(dev == "execution"): 170 self.devices.append(ExecutionAlertDevice(exeInfo,alerts,areas)) 145 self.devices.append(JabberAlertDevice(to,jabberInfo,alerts,areas)) 146 self.log.debug("Adding jabber device") 147 else: 148 self.log.error("Jabber Support Not Enabled, but Jabber Device Requested!") 149 if(dev == "osd"): 150 if(not osdLoadAttempted): 151 osd_available = self.__loadOsd() 152 osdLoadAttempted = True 153 154 if(osd_available): 155 position = self.get(str(i),"position", DEFAULT_OSD_POSITION) 156 alignment = self.get(str(i),"alignment", DEFAULT_OSD_ALIGNMENT) 157 offset = int(self.get(str(i),"offset", DEFAULT_OSD_OFFSET)) 158 timeout = int(self.get(str(i),"timeout", DEFAULT_OSD_TIMEOUT)) 159 color = self.get(str(i),"color", DEFAULT_OSD_COLOR) 160 font = self.get(str(i),"font", DEFAULT_OSD_FONT) 161 self.devices.append(OsdAlertDevice(OsdAlertDeviceInfo(position, 162 alignment, 163 offset, 164 timeout, 165 color, 166 font), 167 alerts,areas)) 168 self.log.debug("Adding OSD device") 169 else: 170 self.log.error("OSD Support Not Enabled, but OSD Device Requested!") 171 if(dev == "mythtv"): 172 to = self.getRequired(str(i),"to") 173 wait_time = int(self.getRequired(str(i),"wait_time")) 174 self.devices.append(MythtvAlertDevice(MythtvAlertDeviceInfo(to,wait_time),alerts,areas)) 175 self.log.debug("Adding MythTv device") 176 if(dev == "media"): 177 self.devices.append(MediaAlertDevice(mediaInfo,alerts,areas)) 178 self.log.debug("Adding media device") 179 if(dev == "execution"): 180 self.devices.append(ExecutionAlertDevice(exeInfo,alerts,areas)) 181 self.log.debug("Adding execution device") 171 182 172 183 def __str__(self): -
StormSiren/StormWeather.py
r122 r184 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
r122 r184 64 64 self.log = logging.getLogger("XmlWeather") 65 65 66 self.log.setLevel(logging.DEBUG) 67 66 68 def fetch(self): 67 69 self.__fetch() -
siren
r135 r184 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):
