Exemplo n.º 1
0
		# parse all sensors
		for item in configRoot.find("sensors").iterfind("sensor"):

			sensor = SensorFIFO()

			# 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()
			for alertLevelXml in item.iterfind("alertLevel"):
				sensor.alertLevels.append(int(alertLevelXml.text))

			# fifo specific options
			sensor.umask = int(item.find("fifo").attrib[
				"umask"], 8)
			sensor.fifoFile = str(item.find("fifo").attrib[
				"fifoFile"])

			# check if description is empty
			if len(sensor.description) == 0:
				raise ValueError("Description of sensor %d is empty."
					% sensor.id)
Exemplo n.º 2
0
            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 = SensorFIFO()

            # 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"):
                sensor.alertLevels.append(int(alertLevelXml.text))

            # fifo specific options
            sensor.umask = int(item.find("fifo").attrib["umask"], 8)
            sensor.fifoFile = makePath(str(item.find("fifo").attrib["fifoFile"]))
            sensor.sensorDataType = int(item.find("fifo").attrib["dataType"])

            # Check sanity of sensor data type.
            if (sensor.sensorDataType != SensorDataType.NONE
                and sensor.sensorDataType != SensorDataType.INT
                and sensor.sensorDataType != SensorDataType.FLOAT):
                raise ValueError("Illegal data type for sensor %d." % sensor.id)
Exemplo n.º 3
0
        for item in configRoot.find("sensors").iterfind("sensor"):

            sensor = SensorFIFO()

            # 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()
            for alertLevelXml in item.iterfind("alertLevel"):
                sensor.alertLevels.append(int(alertLevelXml.text))

            # fifo specific options
            sensor.umask = int(item.find("fifo").attrib["umask"], 8)
            sensor.fifoFile = str(item.find("fifo").attrib["fifoFile"])

            # check if description is empty
            if len(sensor.description) == 0:
                raise ValueError("Description of sensor %d is empty." %
                                 sensor.id)

            # check if the id of the sensor is unique
Exemplo n.º 4
0
        # parse all sensors
        for item in configRoot.find("sensors").iterfind("sensor"):

            sensor = SensorFIFO()

            # 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"):
                sensor.alertLevels.append(int(alertLevelXml.text))

            # fifo specific options
            sensor.umask = int(item.find("fifo").attrib[
                "umask"], 8)
            sensor.fifoFile = makePath(str(item.find("fifo").attrib[
                "fifoFile"]))
            sensor.sensorDataType = int(item.find("fifo").attrib[
                "dataType"])

            # Check sanity of sensor data type.
            if (sensor.sensorDataType != SensorDataType.NONE