configRoot.find("smtp").find("general").attrib["fromAddr"]) smtpToAddr = str( configRoot.find("smtp").find("general").attrib["toAddr"]) # parse all alerts for item in configRoot.find("alerts").iterfind("alert"): # PLACE YOUR CODE HERE # replace the creation of an instance of the template alert # class with your own alert class (you can also add # your own needed configuration parameters for this alert) alert = TemplateAlert() # these options are needed by the server to # differentiate between the registered alerts alert.id = int(item.find("general").attrib["id"]) alert.description = str(item.find("general").attrib["description"]) alert.alertLevels = list() for alertLevelXml in item.iterfind("alertLevel"): alert.alertLevels.append(int(alertLevelXml.text)) # check if description is empty if len(alert.description) == 0: raise ValueError("Description of alert %d is empty." % alert.id) # check if the id of the alert is unique for registeredAlert in globalData.alerts: if registeredAlert.id == alert.id: raise ValueError("Id of alert %d" % alert.id +
# parse all alerts for section in config.sections(): if section.find("alert") != -1: # PLACE YOUR CODE HERE # replace the creation of an instance of the template alert # class with your own alert class (you can also add # your own needed configuration parameters for this alert) alert = TemplateAlert() # these options are needed for the by the server to # differentiate between the registered alerts alert.id = config.getint(section, "id") alert.description = config.get(section, "description") alert.alertLevels = map(int, config.get(section, "alertLevels").split(",")) # register alert levels globally (only once) for alertLevel in alert.alertLevels: if not alertLevel in globalData.alertLevels: globalData.alertLevels.append(alertLevel) # check if description is empty if len(alert.description) == 0: print "Description of alert '%s' is empty." % section sys.exit(1) # check if the id of the alert is unique
configRoot.find("smtp").find("general").attrib["toAddr"]) # parse all alerts for item in configRoot.find("alerts").iterfind("alert"): # PLACE YOUR CODE HERE # replace the creation of an instance of the template alert # class with your own alert class (you can also add # your own needed configuration parameters for this alert) alert = TemplateAlert() # these options are needed by the server to # differentiate between the registered alerts alert.id = int(item.find("general").attrib["id"]) alert.description = str(item.find("general").attrib["description"]) alert.alertLevels = list() for alertLevelXml in item.iterfind("alertLevel"): alert.alertLevels.append(int(alertLevelXml.text)) # check if description is empty if len(alert.description) == 0: raise ValueError("Description of alert %d is empty." % alert.id) # check if the id of the alert is unique for registeredAlert in globalData.alerts: if registeredAlert.id == alert.id: raise ValueError("Id of alert %d"
smtpFromAddr = config.get("smtp", "fromAddr") smtpToAddr = config.get("smtp", "toAddr") # parse all alerts for section in config.sections(): if section.find("alert") != -1: # PLACE YOUR CODE HERE # replace the creation of an instance of the template alert # class with your own alert class (you can also add # your own needed configuration parameters for this alert) alert = TemplateAlert() # these options are needed for the by the server to # differentiate between the registered alerts alert.id = config.getint(section, "id") alert.description = config.get(section, "description") alert.alertLevels = map( int, config.get(section, "alertLevels").split(",")) # register alert levels globally (only once) for alertLevel in alert.alertLevels: if not alertLevel in globalData.alertLevels: globalData.alertLevels.append(alertLevel) # check if description is empty if len(alert.description) == 0: print "Description of alert '%s' is empty." % section sys.exit(1)