GPS Event [10] – WordPress

This small series of moving event around, would not be complete without WordPress as a event-notification target. WordPress is a neat content-management system, ideal for any type of periodic reports.

The template accepts html tags, so I have formatted  event data as a table and added an icon.

"""
gps_template_wp.py
Wordpress template for GPS event
"
""
 
# 0=empty, 1=ok, 2=info, 3=question, 4=warning, 5=error
img_id = 2
 
def template(pretty = False):
    """
<div style="
float: left;" class="ico">
<img border="
0"
src="
http://www.damirsystems.com/dp_images/Alm$image_id_here$.png" />
</div>
<div style="
float: left;">
<table id="
hor-min-b">
<tr><th>Field</th><th>Value</th></tr>
<tr><td>Entity</td><td>$entity_here$</td></tr>
<tr><td>Type</td><td>$type_here$</td></tr>
<tr><td>Time</td><td>$time_stamp_here$</td></tr>
<tr><td>ID</td><td>$id_here$</td></tr>
<tr><td>Latitude</td><td>$latitude_here$</td></tr>
<tr><td>Longitude</td><td>$longitude_here$</td></tr>
<tr><td>Altitude</td><td>$altitude_here$</td></tr>
<tr><td>Speed</td><td>$speed_here$</td></tr>
<tr><td>Course</td><td>$course_here$</td></tr>
<tr><td>Valid</td><td>$valid_here$</td></tr>
</table>
</div>
<br clear="
all" />
<p>&nbsp;</p>
"
""
    return compress_template(template.__doc__)
 
def compress_template(s):
    """ Compress template """
    rli = {'{ ':'{', ' }':'}', ', "':',"', '> <':'><'}
    st = ' '.join(s.split())
    for (k, v) in rli.items():
        st = st.replace(k, v)
    st = st.replace('$image_id_here$', str(img_id))   
    return st
     
if __name__ == "__main__":
    print template(True)

The service and the authorization modules:

To select the service in the main gps_event.py module:

# select service: none, aws, rc, tweet, email, gtalk, coral8, wp
use_service = 'wp'
 
# define sampling delay in seconds
sample_delay = 60

The previous post is the result .


Leave a comment