Skip to main content

Common Alerting Protocol (CAP) parser

Project description

Common Alerting Procotol (CAP) Parser

What is CAP ?

The Common Alerting Protocol (CAP), a digital format for exchanging emergency alerts, allows a consistent alert message to be disseminated simultaneously over multiple communications pathways.

In www.fema.gov

Simply putting, CAP is XML message-formatted based communication focussed one structuring the main aspects of any given emergency in a easy to read / easy to exchange message. This messages can then be used for communication between devices and for long-term storage in XML files.

It was developed by Oasis Open, and full specifications can be found here.

An example of a CAP message can be seen bellow

Capabilities

  • Add rich multimedia such as photographs, maps, streaming video and audio
  • Geographically target emergency alerts to a defined warning area. This is limited only by the capacity of the delivery system used.
  • Serve the needs of people who are deaf, hard of hearing, blind or low vision.
  • Send alerts in multiple languages.

Example

<alert xmlns="urn:oasis:names:tc:emergency:cap:1.2">
    <identifier>43b080713727</identifier>
    <sender>hsas@dhs.gov</sender>
    <sent>2003-04-02T14:39:01-05:00</sent>
    <status>Actual</status>
    <msgType>Alert</msgType>
    <scope>Private</scope>
    <info>
        <category>Security</category>
        <event>Homeland Security Advisory System Update</event>
        <urgency>Immediate</urgency>
        <severity>Severe</severity>
        <certainty>Likely</certainty>
        <senderName>U.S. Government, Department of Homeland Security</senderName>
        <headline>Homeland Security Sets Code ORANGE</headline>
        <description>The Department of Homeland Security has elevated the Homeland Security Advisory
            System threat level to ORANGE / High in response to intelligence which may indicate a
            heightened threat of terrorism.</description>
        <instruction> A High Condition is declared when there is a high risk of terrorist attacks.
            In addition to the Protective Measures taken in the previous Threat Conditions, Federal
            departments and agencies should consider agency-specific Protective Measures in
            accordance with their existing plans.</instruction>
        <web><http://www.dhs.gov/dhspublic/display?theme=29></web>
        <parameter>
            <valueName>HSAS</valueName>
            <value>ORANGE</value>
        </parameter>
        <resource>
            <resourceDesc>Image file (GIF)</resourceDesc>
            <mimeType>image/gif</mimeType>
            <uri><http://www.dhs.gov/dhspublic/getAdvisoryImage></uri>
        </resource>
        <area>
            <areaDesc>U.S. nationwide and interests worldwide</areaDesc>
        </area>
    </info>
</alert>

How to Use

import capparser

alert = capparser.element.Alert(sender="FireTec",
                                status=capparser.enums.Status.Actual,
                                msgType=capparser.enums.MsgType.Alert,
                                scope=capparser.enums.Scope.Private)
alert.setSource("FireTec")
alert.addAddress("Radio Renascenca")

info = capparser.element.Info(category=[capparser.enums.Category.Fire],
                              event="Incendio Florestal em Sever do Vouga",
                              urgency=capparser.enums.Urgency.Immediate,
                              severity=capparser.enums.Severity.Severe,
                              certainty=capparser.enums.Certainty.Observed)
info.setSenderName("FireTec")
info.setInstruction(
    "Foi detetado um possivel incendio florestal na sua area, precaucao e aconselhada.")

param1 = capparser.element.Parameter(parameterName="PS",
                                     parameterValue="PS=Radio Renascenca")
param2 = capparser.element.Parameter(parameterName="PI",
                                     parameterValue="PI=80XX")
param3 = capparser.element.Parameter(parameterName="AF",
                                     parameterValue="AF=95.0")
param4 = capparser.element.Parameter(parameterName="AF",
                                     parameterValue="AF=100.0")
param5 = capparser.element.Parameter(parameterName="AF",
                                     parameterValue="AF=105.0")

info.addParameter(param1)
info.addParameter(param2)
info.addParameter(param3)
info.addParameter(param4)
info.addParameter(param5)

alert.addInfo(info)

capparser.writeAlertToFile(alert, "output.xml")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

capparser-2.0.4.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

capparser-2.0.4-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file capparser-2.0.4.tar.gz.

File metadata

  • Download URL: capparser-2.0.4.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for capparser-2.0.4.tar.gz
Algorithm Hash digest
SHA256 947843c7e60f3a13a5820bfe6436485b4552426a8b679fdb72b9405dd74b4ae7
MD5 354ca147c42e3e1498e2159d505b0538
BLAKE2b-256 4b2e8e5cf0ae7597e26aee3947db824a8a9ffd1b40ee7e34737b9bce7bb2265e

See more details on using hashes here.

File details

Details for the file capparser-2.0.4-py3-none-any.whl.

File metadata

  • Download URL: capparser-2.0.4-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for capparser-2.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 030dfc45667aadc565b189c71a54c9919468582d24ab0aab4a3265f0f9210a3e
MD5 e823f11b24b4dbe03b18787a592ecbdf
BLAKE2b-256 10439288187356e0ee64a9ccfd28eb3f2f33a78e787803329b0e8b3b1f5ced69

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page