configRoot.find("smtp").find("server").attrib["host"]) smtpPort = int( configRoot.find("smtp").find("server").attrib["port"]) smtpFromAddr = str( 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)
smtpActivated = config.getboolean("smtp", "smtpActivated") if smtpActivated is True: smtpServer = config.get("smtp", "server") smtpPort = config.getint("smtp", "serverPort") 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)
configRoot.find("smtp").find("server").attrib["host"]) smtpPort = int( configRoot.find("smtp").find("server").attrib["port"]) smtpFromAddr = str( 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."
smtpActivated = config.getboolean("smtp", "smtpActivated") if smtpActivated is True: smtpServer = config.get("smtp", "server") smtpPort = config.getint("smtp", "serverPort") 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