Mercurial > code > home > repos > light9
annotate light8/dmxclient.py @ 187:867863cc2ab0
new candle dimmer
author | dmcc |
---|---|
date | Mon, 14 Jul 2003 02:26:48 +0000 |
parents | 79bc84310e80 |
children | 238eede02bf9 |
rev | line source |
---|---|
0 | 1 """ module for clients to use for easy talking to the dmx |
2 server. sending levels is now a simple call to | |
3 dmxclient.outputlevels(..) | |
4 | |
5 client id is formed from sys.argv[0] and the PID. """ | |
6 | |
7 import xmlrpclib,os,sys,socket,time | |
8 _dmx=None | |
9 | |
10 _id="%s-%s" % (sys.argv[0].replace('.py','').replace('./',''),os.getpid()) | |
11 | |
120
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
12 def outputlevels(levellist): |
0 | 13 """present a list of dmx channel levels, each scaled from |
14 0..1. list can be any length- it will apply to the first len() dmx | |
15 channels. | |
16 | |
17 if the server is not found, outputlevels will block for a | |
18 second.""" | |
19 | |
20 global _dmx,_id | |
21 | |
22 if _dmx is None: | |
167 | 23 host = os.getenv('DMXHOST', 'localhost') |
24 _dmx=xmlrpclib.Server("http://%s:8030" % host) | |
0 | 25 |
120
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
26 try: |
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
27 _dmx.outputlevels(_id,levellist) |
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
28 except socket.error,e: |
141 | 29 print "dmx server error %s, waiting"%e |
120
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
30 time.sleep(1) |
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
31 except xmlrpclib.Fault,e: |
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
32 print "outputlevels had xml fault: %s" % e |
b75bfbcf5979
new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents:
0
diff
changeset
|
33 time.sleep(1) |
0 | 34 |
167 | 35 dummy = os.getenv('DMXDUMMY') |
36 if dummy: | |
37 print "dmxclient: DMX is in dummy mode." | |
38 def bogus(*args): | |
39 pass | |
40 outputlevels = bogus |