aboutsummaryrefslogtreecommitdiff
path: root/util/ComponentRegistry.py
diff options
context:
space:
mode:
Diffstat (limited to 'util/ComponentRegistry.py')
-rw-r--r--util/ComponentRegistry.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/util/ComponentRegistry.py b/util/ComponentRegistry.py
index 776cd17..be913df 100644
--- a/util/ComponentRegistry.py
+++ b/util/ComponentRegistry.py
@@ -11,16 +11,19 @@ def clearRegistry():
initRegistry()
def removeComponent(cid):
- globals()['Registry'].pop(cid)
+ global Registry
+ Registry.pop(cid)
def getComponent(cid):
- return globals()['Registry'][cid]
+ global Registry
+ return Registry[cid]
#Registry of all components of the light system
#TODO: pick a graceful failure behavior and implement it
def registerComponent(component, cid=None):
+ global Registry
if cid != None:
- globals()['Registry'][cid] = component
+ Registry[cid] = component
else:
try:
cid = component['Id']
@@ -28,22 +31,26 @@ def registerComponent(component, cid=None):
cid = getNewId()
component['Id'] = cid
main_log.debug(cid + 'automatically assigned')
- globals()['Registry'][cid] = component
+ Registry[cid] = component
return cid
def verifyUniqueId(cid):
- return not cid in globals()['Registry']
+ global Registry
+ return not cid in Registry
def removeComponent(cid):
- globals()['Registry'].pop(cid)
+ global Registry
+ Registry.pop(cid)
def getComponent(cid):
- return globals()['Registry'][cid]
+ global Registry
+ return Registry[cid]
def getNewId():
- trialKey = len(globals()['Registry'])
+ global Registry
+ trialKey = len(Registry)
trialId = hashlib.md5(str(trialKey)).hexdigest()
- while trialId in globals()['Registry']:
+ while trialId in Registry:
trialKey += 1
trialId = hashlib.md5(str(trialKey)).hexdigest()
return trialId