configRoot.find("smtp").find( "general").attrib["activated"]).upper() == "TRUE") if smtpActivated is True: smtpServer = str( 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 sensors for item in configRoot.find("sensors").iterfind("sensor"): sensor = ExecuterSensor() # these options are needed by the server to # differentiate between the registered sensors sensor.id = int(item.find("general").attrib["id"]) sensor.description = str( item.find("general").attrib["description"]) sensor.alertDelay = int(item.find("general").attrib["alertDelay"]) sensor.triggerAlert = (str( item.find("general").attrib["triggerAlert"]).upper() == "TRUE") sensor.triggerAlertNormal = (str( item.find("general").attrib["triggerAlertNormal"]).upper() == "TRUE") sensor.triggerState = 1 sensor.alertLevels = list()
configRoot.find("smtp").find("general").attrib[ "activated"]).upper() == "TRUE") if smtpActivated is True: smtpServer = str( 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 sensors for item in configRoot.find("sensors").iterfind("sensor"): sensor = ExecuterSensor() # these options are needed by the server to # differentiate between the registered sensors sensor.id = int(item.find("general").attrib["id"]) sensor.description = str(item.find("general").attrib[ "description"]) sensor.alertDelay = int(item.find("general").attrib["alertDelay"]) sensor.triggerAlert = (str(item.find("general").attrib[ "triggerAlert"]).upper() == "TRUE") sensor.triggerAlertNormal = (str(item.find("general").attrib[ "triggerAlertNormal"]).upper() == "TRUE") sensor.triggerState = 1 sensor.alertLevels = list() for alertLevelXml in item.iterfind("alertLevel"):
updateInterval = int( configRoot.find("update").find("general").attrib["interval"]) updateEmailNotification = (str( configRoot.find("update").find("general").attrib[ "emailNotification"]).upper() == "TRUE") # email notification works only if smtp is activated if (updateEmailNotification is True and smtpActivated is False): raise ValueError("Update check can not have email " + "notification activated when smtp is not activated.") # parse all sensors for item in configRoot.find("sensors").iterfind("sensor"): sensor = ExecuterSensor() # these options are needed by the server to # differentiate between the registered sensors sensor.id = int(item.find("general").attrib["id"]) sensor.description = str(item.find("general").attrib[ "description"]) sensor.alertDelay = int(item.find("general").attrib["alertDelay"]) sensor.triggerAlert = (str(item.find("general").attrib[ "triggerAlert"]).upper() == "TRUE") sensor.triggerAlertNormal = (str(item.find("general").attrib[ "triggerAlertNormal"]).upper() == "TRUE") sensor.triggerState = int(item.find("general").attrib[ "triggerState"]) sensor.alertLevels = list()
updateInterval = int( configRoot.find("update").find("general").attrib["interval"]) updateEmailNotification = (str( configRoot.find("update").find( "general").attrib["emailNotification"]).upper() == "TRUE") # email notification works only if smtp is activated if (updateEmailNotification is True and smtpActivated is False): raise ValueError( "Update check can not have email " + "notification activated when smtp is not activated.") # parse all sensors for item in configRoot.find("sensors").iterfind("sensor"): sensor = ExecuterSensor() # these options are needed by the server to # differentiate between the registered sensors sensor.id = int(item.find("general").attrib["id"]) sensor.description = str( item.find("general").attrib["description"]) sensor.alertDelay = int(item.find("general").attrib["alertDelay"]) sensor.triggerAlert = (str( item.find("general").attrib["triggerAlert"]).upper() == "TRUE") sensor.triggerAlertNormal = (str( item.find("general").attrib["triggerAlertNormal"]).upper() == "TRUE") sensor.triggerState = int( item.find("general").attrib["triggerState"])