1 import pdb
2 import threading
3 import thread
4 import util.Config as configGetter
5 import types
6
8 """SmootCoreObject is essentially a super-object class which grants us some niceties. It allows
9 us to use objects as if they are dictionaries -- we use this to store their arguments
10 convienently -- note that querying for a parameter that does not exist will return None. It
11 also offers some basic ThreadSafety."""
12 - def __init__(self, argDict, skipValidation = False):
21
24
26 self.lock = thread.allocate_lock()
27 self.lock.acquire()
28
31
33 return self.__class__.__name__
34
37
39 if key in self.argDict:
40 item = self.argDict[key]
41 if isinstance(item, types.FunctionType):
42 return item(self.argDict)
43
44
45 else:
46 return item
47 else:
48 return None
53
56
57
59 for item in validationDict:
60 if not item in self.argDict:
61 raise Exception(validationDict[item])
62
64 if listener not in self.dieListeners:
65 self.dieListeners.append(listener)
66
68 if listener in self.dieListeners:
69 self.dieListeners.remove(listener)
70
72 for listener in self.dieListeners:
73 listener.handleDie(self)
74