smtpFromAddr = "" smtpToAddr = "" 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 alerts for item in configRoot.find("alerts").iterfind("alert"): alert = RaspberryPiGPIOAlert() # Get gpio pin settings. alert.gpio_pin = int(item.find("gpio").attrib["gpioPin"]) if int(item.find("gpio").attrib["gpioPinStateNormal"]) == 1: alert.gpio_pin_state_normal = GPIO.HIGH else: alert.gpio_pin_state_normal = GPIO.LOW if int(item.find("gpio").attrib["gpioPinStateTriggered"]) == 1: alert.gpio_pin_state_triggered = GPIO.HIGH else: alert.gpio_pin_state_triggered = GPIO.LOW
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 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"])
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 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"])
loglevel = logging.CRITICAL else: raise ValueError("No valid log level in config file.") # parse smtp options if activated 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: 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: