changeset 410:910324f14fe4

- few more web tweaks. don't fsync, it's slow.
author Matt Johnston <matt@ucc.asn.au>
date Sun, 26 Aug 2012 20:08:47 +0800
parents 1854abee5a59
children 4a04b63a6b4a
files web/log.py web/templog.wsgi
diffstat 2 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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()
--- 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)