# HG changeset patch # User Matt Johnston # Date 1345982927 -28800 # Node ID 910324f14fe49a6ad7c374c99cc39581e0a9aa15 # Parent 1854abee5a599c6fbf94cc02a0d9b4e4ba1f1c97 - few more web tweaks. don't fsync, it's slow. diff -r 1854abee5a59 -r 910324f14fe4 web/log.py --- a/web/log.py Thu Aug 02 22:11:13 2012 +0800 +++ b/web/log.py Sun Aug 26 20:08:47 2012 +0800 @@ -55,6 +55,8 @@ return ''.join(["%.2x" % int(x * 256) for x in hls_to_rgb(hue, li, sat)]) def graph_png(start, length): + os.environ['MATT_PNG_BODGE_COMPRESS'] = '4' + os.environ['MATT_PNG_BODGE_FILTER'] = 'paeth' rrds = all_sensors() graph_args = [] @@ -121,7 +123,9 @@ # '--right-axis-label', 'Temperature' ] + print>>sys.stderr, ' '.join("'%s'" % s for s in args) rrdtool.graph(*args) + #return tempf return tempf.read() def sensor_update(sensor_id, measurements, first_real_time, time_step): @@ -141,12 +145,12 @@ try: rrdtool.update(rrdfile, v) except rrdtool.error, e: - print>>sys.stderr, "Bad rrdtool update '%s'" % v + print>>sys.stderr, "Bad rrdtool update '%s': %s" % (v, str(e)) traceback.print_exc(file=sys.stderr) # be paranoid - f = file(rrdfile) - os.fsync(f.fileno()) + #f = file(rrdfile) + #os.fsync(f.fileno()) def debug_file(mode='r'): return open('%s/debug.log' % config.DATA_PATH, mode) @@ -178,6 +182,8 @@ return val_ticks + float(val_rem) * tick_secs / tick_wake def parse(lines): + + start_time = time.time() debugf = record_debug(lines) @@ -229,5 +235,6 @@ # XXX sqlite add sensor_update(sensor_id, measurements, first_real_time, time_step) - debugf.write("Updated %d sensors\n" % len(sensors)) + timedelta = time.time() - start_time + debugf.write("Updated %d sensors in %.2f secs\n" % (len(sensors), timedelta)) debugf.flush() diff -r 1854abee5a59 -r 910324f14fe4 web/templog.wsgi --- a/web/templog.wsgi Thu Aug 02 22:11:13 2012 +0800 +++ b/web/templog.wsgi Sun Aug 26 20:08:47 2012 +0800 @@ -3,6 +3,7 @@ # Change working directory so relative paths (and template lookup) work again thisdir = os.path.dirname(__file__) os.chdir(thisdir) +os.environ['LD_LIBRARY_PATH'] = '/home/matt/templog/web' # for some reason local imports don't work... sys.path.append(thisdir)