Quit on errors loading initial annotations

This commit is contained in:
Mika Fischer
2011-06-16 11:58:26 +02:00
parent 2d4e401cb2
commit 514fd9cf92
+11 -3
View File
@@ -140,7 +140,11 @@ class LabelTool(QObject):
# no command is matching, then -- if not empty --
# args must contain a labelfile filename to load
if len(args) > 1:
self.loadAnnotations(args[1])
try:
self.loadAnnotations(args[1], handleErrors=False)
except Exception, e:
print "Error loading annotations:", e
sys.exit(1)
else:
self.clearAnnotations()
@@ -196,8 +200,9 @@ class LabelTool(QObject):
###
### Annoation file handling
###___________________________________________________________________________________________
def loadAnnotations(self, fname):
def loadAnnotations(self, fname, handleErrors=True):
fname = str(fname) # convert from QString
try:
self.container_ = self.container_factory_.create(fname)
self.container_.load(fname)
@@ -205,7 +210,10 @@ class LabelTool(QObject):
msg = "Successfully loaded %s (%d files, %d annotations)" % \
(fname, self._model.root().numFiles(), self._model.root().numAnnotations())
except Exception, e:
msg = "Error: Loading failed (%s)" % str(e)
if handleErrors:
msg = "Error: Loading failed (%s)" % str(e)
else:
raise
self.statusMessage.emit(msg)
self.annotationsLoaded.emit()