changeset 1067:c33158b367a5

inputdemo reports latency of posting each point. takes curve uri on cmdline Ignore-this: 640cf036dfb5f5ae956be1cde5190846
author Drew Perttula <drewp@bigasterisk.com>
date Mon, 02 Jun 2014 06:04:19 +0000
parents e71abaa857ed
children 0fb89da08e66
files bin/inputdemo
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/bin/inputdemo	Mon Jun 02 06:04:07 2014 +0000
+++ b/bin/inputdemo	Mon Jun 02 06:04:19 2014 +0000
@@ -5,7 +5,7 @@
 gtk3reactor.install()
 from twisted.internet import reactor
 from rdflib import URIRef
-import optparse, logging, urllib
+import optparse, logging, urllib, time
 from gi.repository import Gtk
 from run_local import log
 from light9 import showconfig, networking
@@ -16,7 +16,7 @@
 class App(object):
     def __init__(self):
         parser = optparse.OptionParser()
-        parser.set_usage("%prog [opts]")
+        parser.set_usage("%prog [opts] [curve uri]")
         parser.add_option("--debug", action="store_true",
                           help="log at DEBUG")
         clientsession.add_option(parser)
@@ -29,7 +29,7 @@
 
         self.graph.initiallySynced.addCallback(lambda _: self.launch())
 
-        self.curve = URIRef('http://light9.bigasterisk.com/show/dance2014/song1/curve/c-1401259747.675542')
+        self.curve = args[0] if args else URIRef('http://light9.bigasterisk.com/show/dance2014/song1/curve/c-1401259747.675542')
         print "sending points on curve %s" % self.curve
         
         reactor.run()
@@ -52,12 +52,15 @@
         f = cyclone.httpclient.fetch(
             networking.curveCalc.path('liveInputPoint'),
             method='POST', timeout=1,
-            postdata=urllib.urlencode({'curve': self.curve,
-                                       'value': str(scale.get_value())}))
+            postdata=urllib.urlencode({
+                'curve': self.curve,
+                'value': str(scale.get_value()),
+            }))
         @f.addCallback
         def cb(result):
             if result.code // 100 != 2:
                 log.error("curveCalc said %s: %s", result.code, result.body)
+            print "posted in %.1f ms" % (1000 * (time.time() - t1))
         @f.addErrback
         def eb(err):
             print "err", err