aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Tardy <pierre.tardy@intel.com>2011-03-22 12:15:07 +0100
committerPierre Tardy <pierre.tardy@intel.com>2011-03-22 12:17:29 +0100
commite6aee1612bc1be3a88a233cf1a916e4c1f97b96d (patch)
treec4556cfb334dd61ccbcddbf9aab9b19ee6679ef4
parent85cf2786c1a62fc5d35b1120c2db38aa5e387dd7 (diff)
plugins: better handle uncomplete plugins
-rw-r--r--timechart/model.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/timechart/model.py b/timechart/model.py
index 5b00a14..31510aa 100644
--- a/timechart/model.py
+++ b/timechart/model.py
@@ -3,7 +3,7 @@
from numpy import amin, amax, arange, searchsorted, sin, pi, linspace
import numpy as np
-
+import traceback
from enthought.traits.api import HasTraits, Instance, Str, Float,Delegate,\
DelegatesTo, Int, Long, Enum, Color, List, Bool, CArray, Property, cached_property, String, Button
from enthought.traits.ui.api import Group, HGroup, Item, View, spring, Handler,VGroup,TableEditor
@@ -497,8 +497,21 @@ class tcProject(HasTraits):
if event.event=='function':
callback = "do_event_"+event.callee
if self.plugin_methods.has_key(callback):
- self.plugin_methods[callback](self,event)
- elif self.methods.has_key(callback):
+ try:
+ self.plugin_methods[callback](self,event)
+ return
+ except AttributeError:
+ if not hasattr(self.plugin_methods[callback],"num_exc"):
+ self.plugin_methods[callback].num_exc = 0
+ self.plugin_methods[callback].num_exc += 1
+ if self.plugin_methods[callback].num_exc <10:
+ print "bug in ",self.plugin_methods[callback],"still continue.."
+ traceback.print_exc()
+ print event
+ if self.plugin_methods[callback].num_exc == 10:
+ print self.plugin_methods[callback], "is too buggy, disabling, please report bug!"
+ del self.plugin_methods[callback]
+ if self.methods.has_key(callback):
self.methods[callback](event)
elif event.event=='function':
self.do_function_default(event)