comparison web/log.py @ 49:206294a354a7

update values one at a time, ignore failure
author Matt Johnston <matt@ucc.asn.au>
date Sun, 24 Jun 2012 10:37:38 +0800
parents 425af63d584d
children 79761ee67134
comparison
equal deleted inserted replaced
45:425af63d584d 49:206294a354a7
7 import hashlib 7 import hashlib
8 import tempfile 8 import tempfile
9 import time 9 import time
10 import syslog 10 import syslog
11 import sqlite3 11 import sqlite3
12 import traceback
12 from colorsys import hls_to_rgb 13 from colorsys import hls_to_rgb
13 14
14 import config 15 import config
15 16
16 def sensor_rrd_path(s): 17 def sensor_rrd_path(s):
85 measurements)] 86 measurements)]
86 87
87 rrdfile = sensor_rrd_path(sensor_id) 88 rrdfile = sensor_rrd_path(sensor_id)
88 print>>sys.stderr, values 89 print>>sys.stderr, values
89 # XXX what to do here when it fails... 90 # XXX what to do here when it fails...
90 rrdtool.update(rrdfile, *values) 91 for v in values:
92 try:
93 rrdtool.update(rrdfile, v)
94 except Exception, e:
95 print>>sys.stderr, "Bad rrdtool update '%s'" % v
96 traceback.print_exc(file=sys.stderr)
91 97
92 # be paranoid 98 # be paranoid
93 f = file(rrdfile) 99 f = file(rrdfile)
94 os.fsync(f.fileno()) 100 os.fsync(f.fileno())
95 101