changeset 1157:dc86936969d8

SC don't break so much on corrupt subs (but we don't yet remove their dangling graph links) Ignore-this: 21e85113aa81d0026080c3e01ee848db
author drewp@bigasterisk.com
date Sat, 14 Jun 2014 23:41:47 +0000
parents f66586649ae3
children da006651b531
files light9/dmxchanedit.py
diffstat 1 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/light9/dmxchanedit.py	Sat Jun 14 23:41:25 2014 +0000
+++ b/light9/dmxchanedit.py	Sat Jun 14 23:41:47 2014 +0000
@@ -19,10 +19,10 @@
 from __future__ import nested_scopes,division
 import Tkinter as tk
 from rdflib import RDF, Literal
-import math
+import math, logging
 from decimal import Decimal
 from light9.namespaces import L9
-
+log = logging.getLogger('dmxchanedit')
 stdfont = ('Arial', 9)
 
 def gradient(lev, low=(80,80,180), high=(255,55,50)):
@@ -192,12 +192,20 @@
         remaining = set(self.levelFromUri.keys())
         for ll in self.graph.objects(sub, L9['lightLevel']):
             chan = self.graph.value(ll, L9['channel'])
-            lev = self.graph.value(ll, L9['level']).toPython()
+            try:
+                 lev = self.graph.value(ll, L9['level']).toPython()
+            except AttributeError as e:
+                 log.error('on lightlevel %r:', ll)
+                 log.exception(e)
+                 continue
             if isinstance(lev, Decimal):
                  lev = float(lev)
             assert isinstance(lev, (int, long, float)), repr(lev)
-            self.levelFromUri[chan].setTo(lev)
-            remaining.remove(chan)
+            try:
+                 self.levelFromUri[chan].setTo(lev)
+                 remaining.remove(chan)
+            except KeyError as e:
+                 log.exception(e)
         for channel in remaining:
             self.levelFromUri[channel].setTo(0)