Changeset - ffecebbdcc95
[Not reviewed]
default
0 2 0
drewp@bigasterisk.com - 13 years ago 2012-06-16 02:53:49
drewp@bigasterisk.com
curvecalc serves the time you're hovering over
Ignore-this: 1175a24abc1de8f6e995e925bb25caab
2 files changed with 21 insertions and 3 deletions:
0 comments (0 inline, 0 general)
bin/curvecalc
Show inline comments
 
@@ -12,20 +12,20 @@ todo: curveview should preserve more obj
 
from __future__ import division
 

	
 
from twisted.internet import gtk2reactor
 
gtk2reactor.install()
 
from twisted.internet import reactor
 

	
 
import time, textwrap, os, optparse, gtk, linecache, signal, traceback
 
import time, textwrap, os, optparse, gtk, linecache, signal, traceback, json
 
import louie as dispatcher 
 
from rdflib import URIRef, Graph, Literal, RDF, RDFS
 
import logging
 
log = logging.getLogger()
 

	
 
import run_local
 
from light9 import showconfig, prof
 
from light9 import showconfig, prof, networking
 
from light9.curvecalc.curve import Curveset
 
from light9.curvecalc import curveview 
 
from light9.curvecalc.musicaccess import Music, currentlyPlayingSong
 
from light9.wavelength import wavelength
 
from light9.namespaces import L9
 
from light9.curvecalc.subterm import read_all_subs, savekey, graphPathForSubterms
 
@@ -329,9 +329,27 @@ def main():
 
    dispatcher.send("show all")
 
        
 
    if opts.startup_only:
 
        log.debug("quitting now because of --startup-only")
 
        return
 

	
 
    from twisted.web import server, resource
 
    class Hover(resource.Resource):
 
        isLeaf = True
 
        def render_GET(self, request):
 
            if request.path == '/hoverTime':
 
                results = dispatcher.send("onPlayPause")
 
                times = [t for listener, t in results if t is not None]
 
                if not times:
 
                    request.setResponseCode(404)
 
                    return "not hovering over any time"
 
                
 
                return json.dumps({"song":song, "hoverTime" : times[0]})
 
            raise NotImplementedError()
 

	
 
    reactor.listenTCP(networking.curveCalc.port,
 
                      server.Site(Hover()))
 

	
 

	
 
    prof.run(reactor.run, profile=False)
 

	
 
main()
light9/networking.py
Show inline comments
 
@@ -31,7 +31,7 @@ class ServiceAddress(object):
 
    def path(self, more):
 
        return self.url + str(more)
 

	
 
dmxServer = ServiceAddress(L9['dmxServer'])
 
musicPlayer = ServiceAddress(L9['musicPlayer'])
 
keyboardComposer = ServiceAddress(L9['keyboardComposer'])
 

	
 
curveCalc = ServiceAddress(L9['curveCalc'])
0 comments (0 inline, 0 general)