comparison web/log.py @ 78:c7b6da1adb47

ui tweaks
author Matt Johnston <matt@ucc.asn.au>
date Sat, 07 Jul 2012 23:32:02 +0800
parents 959e88c0bdfa
children 6f4497a448e8
comparison
equal deleted inserted replaced
77:959e88c0bdfa 78:c7b6da1adb47
1 # -*- coding: utf-8 -*-
1 #:vim:et:ts=4:sts=4:sw=4: 2 #:vim:et:ts=4:sts=4:sw=4:
2 import rrdtool 3 import rrdtool
3 import os 4 import os
4 import os.path 5 import os.path
5 import sys 6 import sys
63 continue 64 continue
64 if 'voltage' in sensor: 65 if 'voltage' in sensor:
65 have_volts = True 66 have_volts = True
66 vname = 'scalevolts' 67 vname = 'scalevolts'
67 graph_args.append('DEF:%(vname)s=%(rrdfile)s:temp:AVERAGE:step=3600' % locals()) 68 graph_args.append('DEF:%(vname)s=%(rrdfile)s:temp:AVERAGE:step=3600' % locals())
69 unit = 'V'
68 else: 70 else:
69 vname = 'temp%d' % n 71 vname = 'temp%d' % n
70 graph_args.append('DEF:raw%(vname)s=%(rrdfile)s:temp:AVERAGE' % locals()) 72 graph_args.append('DEF:raw%(vname)s=%(rrdfile)s:temp:AVERAGE' % locals())
71 graph_args.append('CDEF:%(vname)s=raw%(vname)s,0.1,*,2,+' % locals()) 73 graph_args.append('CDEF:%(vname)s=raw%(vname)s,0.1,*,2,+' % locals())
74 unit = '<span face="Liberation Serif">ยบ</span>C'
75
76 last_value = float(rrdtool.info(rrdfile)['ds[temp].last_ds'])
72 width = config.LINE_WIDTH 77 width = config.LINE_WIDTH
73 legend = config.SENSOR_NAMES.get(sensor, sensor) 78 legend = config.SENSOR_NAMES.get(sensor, sensor)
74 colour = config.SENSOR_COLOURS.get(legend, colour_from_string(sensor)) 79 colour = config.SENSOR_COLOURS.get(legend, colour_from_string(sensor))
75 graph_args.append('LINE%(width)f:%(vname)s#%(colour)s:%(legend)s' % locals()) 80 format_last_value = ('%f' % last_value).rstrip('0') + unit
81 print_legend = '%s (%s)' % (legend, format_last_value)
82 graph_args.append('LINE%(width)f:%(vname)s#%(colour)s:%(print_legend)s' % locals())
76 83
77 end = int(start+length) 84 end = int(start+length)
78 start = int(start) 85 start = int(start)
79 86
80 tempf = tempfile.NamedTemporaryFile() 87 tempf = tempfile.NamedTemporaryFile()
99 '--zoom', str(config.ZOOM), 106 '--zoom', str(config.ZOOM),
100 '--color', 'GRID#00000000', 107 '--color', 'GRID#00000000',
101 '--color', 'MGRID#aaaaaa', 108 '--color', 'MGRID#aaaaaa',
102 '--color', 'BACK#ffffff', 109 '--color', 'BACK#ffffff',
103 '--disable-rrdtool-tag', 110 '--disable-rrdtool-tag',
111 '--pango-markup',
104 '--watermark', watermark, 112 '--watermark', watermark,
105 '--imgformat', 'PNG'] \ 113 '--imgformat', 'PNG'] \
106 + graph_args 114 + graph_args
107 args += ['--font', 'DEFAULT:12:%s' % config.GRAPH_FONT] 115 args += ['--font', 'DEFAULT:12:%s' % config.GRAPH_FONT]
108 args += ['--font', 'WATERMARK:10:%s' % config.GRAPH_FONT] 116 args += ['--font', 'WATERMARK:10:%s' % config.GRAPH_FONT]