qmsk.dmx.heads: python3, and make dmx optional
authorTero Marttila <terom@paivola.fi>
Sat, 07 Jun 2014 16:22:56 +0300
changeset 95 478b9d0485aa
parent 94 28ae9bc41c63
child 96 e6dfc98ec50f
qmsk.dmx.heads: python3, and make dmx optional
qmsk/dmx/heads.py
--- a/qmsk/dmx/heads.py	Sat Jun 07 16:21:59 2014 +0300
+++ b/qmsk/dmx/heads.py	Sat Jun 07 16:22:56 2014 +0300
@@ -2,7 +2,7 @@
     High-level DMX output.
 """
 
-class Head (object) :
+class Head :
     CHANNELS = None
 
     def __init__ (self, channel) :
@@ -78,29 +78,30 @@
     ]
 
 
-class Universe (object) :
+class Universe :
     """
         An universe of Heads for DMX output.
     """
 
-    def __init__ (self, dmx, heads) :
+    def __init__ (self, heads, dmx=None) :
+        self.heads = heads
         self.dmx = dmx
-        self.heads = heads
 
     def __getitem__ (self, name) :
         return self.heads[name]
 
     def __iter__ (self) :
-        return self.heads.iteritems()
+        return iter(self.heads.items())
 
     def update (self, head, attrs) :
         """
             Update per-head values..
         """
 
-        for attr, value in attrs.iteritems():
+        for attr, value in attrs.items():
             head[attr] = value
         
         # output
-        self.dmx.set(head.channel, *head)
+        if self.dmx:
+            self.dmx.set(head.channel, *head)