Mercurial > templog
changeset 32:e18d7e89c17d
More minor work
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 14 Jun 2012 00:00:57 +0800 |
parents | 5e75e08d20ac |
children | 024f5571df8c |
files | main.c server/ts.py web/log.py |
diffstat | 3 files changed, 21 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/main.c Wed Jun 13 23:41:05 2012 +0800 +++ b/main.c Thu Jun 14 00:00:57 2012 +0800 @@ -262,7 +262,7 @@ cmd_clear() { n_measurements = 0; - printf_P(PSTR("Cleared\n")); + printf_P(PSTR("cleared\n")); } static void
--- a/server/ts.py Wed Jun 13 23:41:05 2012 +0800 +++ b/server/ts.py Thu Jun 14 00:00:57 2012 +0800 @@ -109,13 +109,28 @@ return int(next_wake) +@retry() +def clear_meas(sock): + sock.send("clear\n"); + l = readline(sock) + if l and l.rstrip() == 'cleared': + return True + + print>>sys.stderr, "Bad response to clear %s\n" % str(l) + return False + def send_results(lines): enc_lines = binascii.b2a_base64(zlib.compress('\n'.join(lines))) hmac.new(config.HMAC_KEY, enc_lines).hexdigest() url_data = urllib.url_encode( ('lines', enc_lines), ('hmac', mac) ) con = urllib2.urlopen(config.UPDATE_URL, url_data) - + result = con.read(100) + if result == 'OK': + return True + else: + print>>sys.stderr, "Bad result '%s'" % result + return False def do_comms(sock): print "do_comms"
--- a/web/log.py Wed Jun 13 23:41:05 2012 +0800 +++ b/web/log.py Thu Jun 14 00:00:57 2012 +0800 @@ -71,7 +71,10 @@ zip((first_real_time + time_step*t for t in xrange(len(measurements))), measurements)] - rrdtool.update(sensor_rrd_path(sensor_id), *values) + rrdfile = sensor_rrd_path(sensor_id) + rrdtool.update(rrdfile, *values) + f = file(rrdfile) + os.fsync(f.fileno()) def parse(lines): entries = dict(l.split('=', 1) for l in lines)