annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
1 """ module for clients to use for easy talking to the dmx
45b12307c695 Initial revision
drewp
parents:
diff changeset
2 server. sending levels is now a simple call to
45b12307c695 Initial revision
drewp
parents:
diff changeset
3 dmxclient.outputlevels(..)
45b12307c695 Initial revision
drewp
parents:
diff changeset
4
45b12307c695 Initial revision
drewp
parents:
diff changeset
5 client id is formed from sys.argv[0] and the PID. """
45b12307c695 Initial revision
drewp
parents:
diff changeset
6
45b12307c695 Initial revision
drewp
parents:
diff changeset
7 import xmlrpclib,os,sys,socket,time
45b12307c695 Initial revision
drewp
parents:
diff changeset
8 _dmx=None
45b12307c695 Initial revision
drewp
parents:
diff changeset
9
45b12307c695 Initial revision
drewp
parents:
diff changeset
10 _id="%s-%s" % (sys.argv[0].replace('.py','').replace('./',''),os.getpid())
45b12307c695 Initial revision
drewp
parents:
diff changeset
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
45b12307c695 Initial revision
drewp
parents:
diff changeset
13 """present a list of dmx channel levels, each scaled from
45b12307c695 Initial revision
drewp
parents:
diff changeset
14 0..1. list can be any length- it will apply to the first len() dmx
45b12307c695 Initial revision
drewp
parents:
diff changeset
15 channels.
45b12307c695 Initial revision
drewp
parents:
diff changeset
16
45b12307c695 Initial revision
drewp
parents:
diff changeset
17 if the server is not found, outputlevels will block for a
45b12307c695 Initial revision
drewp
parents:
diff changeset
18 second."""
45b12307c695 Initial revision
drewp
parents:
diff changeset
19
45b12307c695 Initial revision
drewp
parents:
diff changeset
20 global _dmx,_id
45b12307c695 Initial revision
drewp
parents:
diff changeset
21
45b12307c695 Initial revision
drewp
parents:
diff changeset
22 if _dmx is None:
120
b75bfbcf5979 new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents: 0
diff changeset
23 _dmx=xmlrpclib.Server("http://localhost:8030")
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
24
120
b75bfbcf5979 new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents: 0
diff changeset
25 try:
b75bfbcf5979 new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents: 0
diff changeset
26 _dmx.outputlevels(_id,levellist)
b75bfbcf5979 new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents: 0
diff changeset
27 except socket.error,e:
b75bfbcf5979 new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents: 0
diff changeset
28 print "dmx server error %r, waiting"%e
b75bfbcf5979 new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents: 0
diff changeset
29 time.sleep(1)
b75bfbcf5979 new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents: 0
diff changeset
30 except xmlrpclib.Fault,e:
b75bfbcf5979 new modules: dmxclient provides a very convenient way for clients to talk to the
drewp
parents: 0
diff changeset
31 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
32 time.sleep(1)
0
45b12307c695 Initial revision
drewp
parents:
diff changeset
33