3
"""Helioviewer.org Status Information Conky Script
5
This script queries Helioviewer.org to find how far behind data is for
6
each instrument, and generates a small conky snippet to display the
7
results. This can be used with the conky execp/execpi commands, e.g.:
11
The net result should be similar to the information obtained when visiting
12
the Helioviewer.org status page at http://www.helioviewer.org/status.
14
from urllib2 import urlopen
17
# Conky formatting parameters
18
CONKY_FONT = "DroidSansMono"
26
HV_QUERY_URL = "http://www.helioviewer.org/api/?action=getStatus"
28
# Query Helioviewer.org
29
response = urlopen(HV_QUERY_URL).read()
30
instruments = json.loads(response)
32
# Sort results by instrument
35
# Generate conky snippet
36
voffset = "${voffset %d}" % CONKY_VOFFSET
37
font = "${font %s:size=%0.1f}" % (CONKY_FONT, CONKY_FONT_SIZE)
38
color = "${color%d}" % CONKY_COLOR_NUM
39
alignc = "${alignc %d}" % CONKY_ALIGNC
41
for inst, status in instruments.items():
42
# Ignore non-active datasets (30 days or more behind real-time)
43
if status['secondsBehind'] > (30 * 24 * 60 * 60):
46
#icon = "${font WingDings}${color green}n${font}"
47
# Icon and time string
48
icon = "${color green}O"
49
time = "%d Minutes Behind" % (status['secondsBehind'] / 60)
52
print (voffset + icon + font + color + alignc + inst + ": " +
53
str(status['level']) + " - " + time + "${font}")
55
if __name__ == '__main__':