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 alerts for item in configRoot.find("alerts").iterfind("alert"): alert = RaspberryPiGPIOAlert() # get gpio pin settings alert.gpioPin = int(item.find("gpio").attrib["gpioPin"]) if int(item.find("gpio").attrib["gpioPinStateNormal"]) == 1: alert.gpioPinStateNormal = GPIO.HIGH else: alert.gpioPinStateNormal = GPIO.LOW if int(item.find("gpio").attrib["gpioPinStateTriggered"]) == 1: alert.gpioPinStateTriggered = GPIO.HIGH else: alert.gpioPinStateTriggered = GPIO.LOW # 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()
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 alerts for item in configRoot.find("alerts").iterfind("alert"): alert = RaspberryPiGPIOAlert() # get gpio pin settings alert.gpioPin = int(item.find("gpio").attrib["gpioPin"]) if int(item.find("gpio").attrib["gpioPinStateNormal"]) == 1: alert.gpioPinStateNormal = GPIO.HIGH else: alert.gpioPinStateNormal = GPIO.LOW if int(item.find("gpio").attrib["gpioPinStateTriggered"]) == 1: alert.gpioPinStateTriggered = GPIO.HIGH else: alert.gpioPinStateTriggered = GPIO.LOW # 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()
smtpToAddr = config.get("smtp", "toAddr") # parse all alerts for section in config.sections(): if section.find("alert") != -1: alert = RaspberryPiGPIOAlert() # 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(",")) # get gpio pin settings alert.gpioPin = config.getint(section, "gpioPin") if config.getint(section, "gpioPinStateNormal") == 1: alert.gpioPinStateNormal = GPIO.HIGH else: alert.gpioPinStateNormal = GPIO.LOW if config.getint(section, "gpioPinStateTriggered") == 1: alert.gpioPinStateTriggered = GPIO.HIGH else: alert.gpioPinStateTriggered = GPIO.LOW # 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