Ejemplo n.º 1
0
            alert.password = alertrPassword
            alert.channel = str(item.find("push").attrib["channel"])
            alert.encSecret = str(item.find("push").attrib["secret"])
            alert.subject = str(item.find("push").attrib["subject"])
            alert.templateFile = make_path(
                str(item.find("push").attrib["templateFile"]))

            # check if the template file exists
            if not os.path.isfile(alert.templateFile):
                raise ValueError("Message template file '%s' does not exist." %
                                 alert.templateFile)

            # 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)

            # check if the id of the alert is unique
            for registeredAlert in globalData.alerts:
                if registeredAlert.id == alert.id:
                    raise ValueError("Id of alert %d is already taken." %
                                     alert.id)
Ejemplo n.º 2
0
            alert.password = alertrPassword
            alert.channel = str(item.find("push").attrib["channel"])
            alert.encSecret = str(item.find("push").attrib["secret"])
            alert.subject = str(item.find("push").attrib["subject"])
            alert.templateFile = makePath(
                str(item.find("push").attrib["templateFile"]))

            # check if the template file exists
            if not os.path.isfile(alert.templateFile):
                raise ValueError("Message template file '%s' does not exist."
                    % alert.templateFile)

            # 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)

            # check if the id of the alert is unique
            for registeredAlert in globalData.alerts:
                if registeredAlert.id == alert.id:
                    raise ValueError("Id of alert %d"
                        % alert.id + "is already taken.")
Ejemplo n.º 3
0
    for alert in alerts:
        logging.info("[%s]: Sending message for alert id %d (%s)." %
                     (fileName, alert["id"], alert["description"]))

        globalData.pushRetryTimeout = 5
        globalData.pushRetries = 1

        subject = "Test message for alert with id %d" % alert["id"]
        message = "This is a test message for the alert:\n\n" \
            + "Id: %d\nDescription: %s\n\nCheers,\nalertR" \
            % (alert["id"], alert["description"])

        # Initialize alert object.
        alertObj = PushAlert(globalData)
        alertObj.id = alert["id"]
        alertObj.description = alert["description"]
        alertObj.username = alert["username"]
        alertObj.password = alert["password"]
        alertObj.channel = alert["channel"]
        alertObj.encSecret = alert["encSecret"]
        alertObj.templateFile = alert["templateFile"]
        alertObj.alertLevels = list()
        alertObj.subject = subject
        alertObj.initializeAlert()

        sensorAlert = SensorAlert()
        sensorAlert.state = 1
        sensorAlert.timeReceived = int(time.time())

        errorCode = alertObj._sendMessage(subject, message, sensorAlert)
Ejemplo n.º 4
0
            % (fileName, alert["id"], alert["description"]))



        globalData.pushRetryTimeout = 5
        globalData.pushRetries = 1

        subject = "Test message for alert with id %d" % alert["id"]
        message = "This is a test message for the alert:\n\n" \
            + "Id: %d\nDescription: %s\n\nCheers,\nalertR" \
            % (alert["id"], alert["description"])

        # Initialize alert object.
        alertObj = PushAlert(globalData)
        alertObj.id = alert["id"]
        alertObj.description = alert["description"]
        alertObj.username = alert["username"]
        alertObj.password = alert["password"]
        alertObj.channel = alert["channel"]
        alertObj.encSecret = alert["encSecret"]
        alertObj.templateFile = alert["templateFile"]
        alertObj.alertLevels = list()
        alertObj.subject = subject
        alertObj.initializeAlert()

        sensorAlert = SensorAlert()
        sensorAlert.state = 1
        sensorAlert.timeReceived = int(time.time())

        errorCode = alertObj._sendMessage(subject, message, sensorAlert)