8 # Based on http://thehelpfulhacker.net/2011/03/27/a-rss-feed-for-your-crontabs/
21 current_timestamp
= int(time
.time())
22 # We only build the RSS for the last ten days
23 period
= 3600 * 24 * 10
24 db
= sqlite3
.connect(db_path
)
25 rows
= db
.execute("select timestamp, status from status where timestamp>? order by timestamp", (current_timestamp
- period
,))
27 line_timestamp
, line_status
= row
28 line_status
= line_status
.encode()
30 if line_status
== status
:
35 event_time
= datetime
.datetime
.fromtimestamp(line_timestamp
).strftime('%Y-%m-%d %H:%M:%S')
37 rss_item
= PyRSS2Gen
.RSSItem(
39 description
= "%s: %s" %
(event_time
, status
),
42 guid
= PyRSS2Gen
.Guid(base64
.b64encode("%s, %s" %
(event_time
, status
)))
44 items
.append(rss_item
)
46 ### Build the rss feed
48 rss_feed
= PyRSS2Gen
.RSS2 (
51 description
= DESCRIPTION
,
52 lastBuildDate
= datetime
.datetime
.utcnow(),
56 print rss_feed
.to_xml()