Mercurial > code > home > repos > light9
comparison bin/curvecalc @ 687:454e381cd24f
curvecalc refactor and module fixes
Ignore-this: afb03eba0af8d2daa7f03d4cace00d3e
author | drewp@bigasterisk.com |
---|---|
date | Tue, 05 Jun 2012 21:38:16 +0000 |
parents | a301a0039c66 |
children | 97b028ed0e47 |
comparison
equal
deleted
inserted
replaced
686:a301a0039c66 | 687:454e381cd24f |
---|---|
15 try: | 15 try: |
16 from dispatch import dispatcher | 16 from dispatch import dispatcher |
17 except ImportError: | 17 except ImportError: |
18 import louie as dispatcher | 18 import louie as dispatcher |
19 from twisted.internet import reactor,tksupport | 19 from twisted.internet import reactor,tksupport |
20 import jsonlib, restkit | 20 import json, restkit |
21 import twisted | 21 import twisted |
22 from twisted.web.client import Agent | 22 from twisted.web.client import Agent |
23 from twisted.internet.protocol import Protocol | 23 from twisted.internet.protocol import Protocol |
24 from twisted.internet.defer import Deferred | 24 from twisted.internet.defer import Deferred |
25 from zope.interface import implements | 25 from zope.interface import implements |
33 | 33 |
34 import run_local | 34 import run_local |
35 from light9 import Submaster, dmxclient, networking, showconfig, prof, Patch | 35 from light9 import Submaster, dmxclient, networking, showconfig, prof, Patch |
36 from light9.TLUtility import make_attributes_from_args | 36 from light9.TLUtility import make_attributes_from_args |
37 from light9.zoomcontrol import Zoomcontrol | 37 from light9.zoomcontrol import Zoomcontrol |
38 from light9.curve import Curveset, Curvesetview | 38 from light9.curve import Curveset |
39 from light9.curveview import Curvesetview | |
39 from light9.wavelength import wavelength | 40 from light9.wavelength import wavelength |
40 from light9.uihelpers import toplevelat | 41 from light9.uihelpers import toplevelat |
41 from light9.namespaces import L9 | 42 from light9.namespaces import L9 |
42 import light9.Effects | 43 import light9.Effects |
43 | 44 |
50 | 51 |
51 def dataReceived(self, bytes): | 52 def dataReceived(self, bytes): |
52 self.buf += bytes | 53 self.buf += bytes |
53 | 54 |
54 def connectionLost(self, reason): | 55 def connectionLost(self, reason): |
55 self.finished.callback(jsonlib.read(self.buf, use_float=True)) | 56 self.finished.callback(json.loads(self.buf)) |
56 | 57 |
57 class StringProducer(object): | 58 class StringProducer(object): |
58 # http://twistedmatrix.com/documents/current/web/howto/client.html | 59 # http://twistedmatrix.com/documents/current/web/howto/client.html |
59 implements(IBodyProducer) | 60 implements(IBodyProducer) |
60 | 61 |
97 return data['t'] # pass along to the real receiver | 98 return data['t'] # pass along to the real receiver |
98 | 99 |
99 def seekplay_or_pause(self,t): | 100 def seekplay_or_pause(self,t): |
100 d = self.player.request("POST", | 101 d = self.player.request("POST", |
101 networking.musicPlayer.path("seekPlayOrPause"), | 102 networking.musicPlayer.path("seekPlayOrPause"), |
102 bodyProducer=StringProducer(jsonlib.write({"t" : t}))) | 103 bodyProducer=StringProducer(json.dumps({"t" : t}))) |
103 | 104 |
104 class Expr(object): | 105 class Expr(object): |
105 """singleton, provides functions for use in subterm expressions, | 106 """singleton, provides functions for use in subterm expressions, |
106 e.g. chases""" | 107 e.g. chases""" |
107 def __init__(self): | 108 def __init__(self): |
498 anchor='w') | 499 anchor='w') |
499 line.pack(side='top',fill='x') | 500 line.pack(side='top',fill='x') |
500 | 501 |
501 def currentlyPlayingSong(): | 502 def currentlyPlayingSong(): |
502 """ask the music player what song it's on""" | 503 """ask the music player what song it's on""" |
503 t = jsonlib.read(restkit.Resource(networking.musicPlayer.url).get("time").body) | 504 player = restkit.Resource(networking.musicPlayer.url) |
505 t = json.loads(player.get("time").body_string()) | |
504 if t['song'] is None: | 506 if t['song'] is None: |
505 raise ValueError("music player is not playing any song") | 507 raise ValueError("music player is not playing any song") |
506 return URIRef(t['song']) | 508 return URIRef(t['song']) |
507 | 509 |
508 def main(): | 510 def main(): |