Mercurial > code > home > repos > light9
comparison light8/dmxclient.py @ 120:b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
new modules: dmxclient provides a very convenient way for clients to talk to the
dmxserver; updatefreq stores event times and computes a report about how frequently
they occur
author | drewp |
---|---|
date | Fri, 13 Jun 2003 14:00:36 +0000 |
parents | 45b12307c695 |
children | 2dfe2c0ba052 |
comparison
equal
deleted
inserted
replaced
119:6f9898f00c9c | 120:b75bfbcf5979 |
---|---|
3 dmxclient.outputlevels(..) | 3 dmxclient.outputlevels(..) |
4 | 4 |
5 client id is formed from sys.argv[0] and the PID. """ | 5 client id is formed from sys.argv[0] and the PID. """ |
6 | 6 |
7 import xmlrpclib,os,sys,socket,time | 7 import xmlrpclib,os,sys,socket,time |
8 from twisted.web.xmlrpc import Proxy | |
9 _dmx=None | 8 _dmx=None |
10 | 9 |
11 _id="%s-%s" % (sys.argv[0].replace('.py','').replace('./',''),os.getpid()) | 10 _id="%s-%s" % (sys.argv[0].replace('.py','').replace('./',''),os.getpid()) |
12 | 11 |
13 def outputlevels(levellist,twisted=0): | 12 def outputlevels(levellist): |
14 """present a list of dmx channel levels, each scaled from | 13 """present a list of dmx channel levels, each scaled from |
15 0..1. list can be any length- it will apply to the first len() dmx | 14 0..1. list can be any length- it will apply to the first len() dmx |
16 channels. | 15 channels. |
17 | 16 |
18 if the server is not found, outputlevels will block for a | 17 if the server is not found, outputlevels will block for a |
19 second.""" | 18 second.""" |
20 | 19 |
21 global _dmx,_id | 20 global _dmx,_id |
22 | 21 |
23 if _dmx is None: | 22 if _dmx is None: |
24 host = os.getenv('DMXHOST', 'localhost') | 23 _dmx=xmlrpclib.Server("http://localhost:8030") |
25 url = "http://%s:8030" % host | |
26 if not twisted: | |
27 _dmx=xmlrpclib.Server(url) | |
28 else: | |
29 _dmx = Proxy(url) | |
30 | 24 |
31 if not twisted: | 25 try: |
32 try: | 26 _dmx.outputlevels(_id,levellist) |
33 _dmx.outputlevels(_id,levellist) | 27 except socket.error,e: |
34 except socket.error,e: | 28 print "dmx server error %r, waiting"%e |
35 print "dmx server error %s, waiting"%e | 29 time.sleep(1) |
36 time.sleep(1) | 30 except xmlrpclib.Fault,e: |
37 except xmlrpclib.Fault,e: | 31 print "outputlevels had xml fault: %s" % e |
38 print "outputlevels had xml fault: %s" % e | 32 time.sleep(1) |
39 time.sleep(1) | |
40 else: | |
41 def err(error): | |
42 print "dmx server error",error | |
43 time.sleep(1) | |
44 d = _dmx.callRemote('outputlevels',_id,levellist) | |
45 d.addErrback(err) | |
46 | |
47 | 33 |
48 dummy = os.getenv('DMXDUMMY') | |
49 if dummy: | |
50 print "dmxclient: DMX is in dummy mode." | |
51 def bogus(*args): | |
52 pass | |
53 outputlevels = bogus |