aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2011-02-16 18:29:41 -0500
committerGravatar rcoh <rcoh@mit.edu>2011-02-16 18:29:41 -0500
commitfffc14c4672294d9bbf8c60edfe8c309f0d54698 (patch)
tree19057b2e98735cc30fa1e0b3932d416946f8d705 /util
parent24aa31808de6a4dc06a651076e5b292aebd9240d (diff)
parent2df9e408a0ff74539862c4a4e562a878cc11a329 (diff)
Merge branch 'conner5' of https://github.com/dxiao/SmootLight into dxiao-conner5
Conflicts: config/C5Sign.xml layouts/SpecifiedLayout.py
Diffstat (limited to 'util')
-rw-r--r--util/ComponentRegistry.py18
-rw-r--r--util/Config.py8
2 files changed, 16 insertions, 10 deletions
diff --git a/util/ComponentRegistry.py b/util/ComponentRegistry.py
index be913df..1db5135 100644
--- a/util/ComponentRegistry.py
+++ b/util/ComponentRegistry.py
@@ -1,12 +1,17 @@
-import pdb
import hashlib
from logger import main_log
+import thread
#TODO: make component registry a singleton
def initRegistry():
#TODO: don't overwrite existing registry
if not 'Registry' in globals():
globals()['Registry'] = {}
-
+ makelock()
+
+
+def makelock():
+ global utilLock
+ utilLock = thread.allocate_lock()
def clearRegistry():
initRegistry()
@@ -14,6 +19,9 @@ def removeComponent(cid):
global Registry
Registry.pop(cid)
+def getLock():
+ global utilLock
+ return utilLock
def getComponent(cid):
global Registry
return Registry[cid]
@@ -31,6 +39,8 @@ def registerComponent(component, cid=None):
cid = getNewId()
component['Id'] = cid
main_log.debug(cid + 'automatically assigned')
+ if cid in Registry:
+ main_log.warn(cid + 'overwritten.')
Registry[cid] = component
return cid
@@ -42,10 +52,6 @@ def removeComponent(cid):
global Registry
Registry.pop(cid)
-def getComponent(cid):
- global Registry
- return Registry[cid]
-
def getNewId():
global Registry
trialKey = len(Registry)
diff --git a/util/Config.py b/util/Config.py
index 25018a8..962aa25 100644
--- a/util/Config.py
+++ b/util/Config.py
@@ -26,8 +26,8 @@ def loadConfigFile(fileName): #TODO: error handling etc.
resolveDocumentInheritances(config.getroot())
return config
except Exception as inst:
- main_log.error('Error loading config file ' + fileName)#, inst) TODO: log exception too
- main_log.error(str(inst))
+ main_log.info('Error loading config file ' + fileName)#, inst) TODO: log exception too
+ main_log.info(str(inst))
return None
def getElement(el):
"""Takes an Element or an ElementTree. If it is a tree, it returns its root. Otherwise, just returns
@@ -89,7 +89,7 @@ def fileToDict(fileName):
for line in f:
fileText += line.rstrip('\n').lstrip('\t') + ' '
except IOError:
- exception_log.exception('Failure reading ' + fileName)
+ main_log.info('Failure reading ' + fileName)
return {}
if fileText == '':
return {}
@@ -98,7 +98,7 @@ def fileToDict(fileName):
main_log.info(fileName + ' read and parsed')
return resultDict
except:
- exception_log.info(fileName + ' is not a well formed python dict. Parsing failed')
+ main_log.exception(fileName + ' is not a well formed python dict. Parsing failed')
return eval(fileText)
def pullArgsFromItem(parentNode):