comparison web/log.py @ 33:024f5571df8c

- Debug log file for server - Fix some variable sizes, turn off local echo for avr code - symlink config for wrt server
author Matt Johnston <matt@ucc.asn.au>
date Fri, 15 Jun 2012 23:34:24 +0800
parents e18d7e89c17d
children 8da0fdadc8d7
comparison
equal deleted inserted replaced
32:e18d7e89c17d 33:024f5571df8c
71 zip((first_real_time + time_step*t for t in xrange(len(measurements))), 71 zip((first_real_time + time_step*t for t in xrange(len(measurements))),
72 measurements)] 72 measurements)]
73 73
74 rrdfile = sensor_rrd_path(sensor_id) 74 rrdfile = sensor_rrd_path(sensor_id)
75 rrdtool.update(rrdfile, *values) 75 rrdtool.update(rrdfile, *values)
76
77 # be paranois
76 f = file(rrdfile) 78 f = file(rrdfile)
77 os.fsync(f.fileno()) 79 os.fsync(f.fileno())
78 80
81 def record_debug(lines):
82 f = open('%s/debug.log', config.DATA_PATH, 'a+')
83 f.write('===== %s =====' % time.strftime('%a, %d %b %Y %H:%M:%S')
84 f.writelines(('%s\n' % s for s in lines))
85 f.flush()
86 return f
87
79 def parse(lines): 88 def parse(lines):
89
90 debugf = record_debug(lines):
91
80 entries = dict(l.split('=', 1) for l in lines) 92 entries = dict(l.split('=', 1) for l in lines)
81 if len(entries) != len(lines): 93 if len(entries) != len(lines):
82 raise Exception("Keys are not unique") 94 raise Exception("Keys are not unique")
83 95
84 num_sensors = int(entries['sensors']) 96 num_sensors = int(entries['sensors'])
108 120
109 first_real_time = time.time() - (avr_now - avr_first_time) 121 first_real_time = time.time() - (avr_now - avr_first_time)
110 122
111 for sensor_id, measurements in zip(sensors, meas): 123 for sensor_id, measurements in zip(sensors, meas):
112 sensor_update(sensor_id, measurements, first_real_time, time_step) 124 sensor_update(sensor_id, measurements, first_real_time, time_step)
125
126 debugf.write("Updated %d sensors\n" % len(sensors)
127 debugf.flush()