[ocrfeeder/langs: 1/15] Prevent errors when the OCR engine's configuration has unknown settings
- From: Joaquim Manuel Pereira Rocha <jrocha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ocrfeeder/langs: 1/15] Prevent errors when the OCR engine's configuration has unknown settings
- Date: Tue, 5 Feb 2013 06:24:48 +0000 (UTC)
commit c0366bd8f03cd63e009eeaf0349fadb8b054c886
Author: Joaquim Rocha <jrocha igalia com>
Date: Fri Feb 1 17:36:39 2013 +0100
Prevent errors when the OCR engine's configuration has unknown settings
src/ocrfeeder/feeder/ocrEngines.py | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/src/ocrfeeder/feeder/ocrEngines.py b/src/ocrfeeder/feeder/ocrEngines.py
index 3d73a1c..d25ca79 100644
--- a/src/ocrfeeder/feeder/ocrEngines.py
+++ b/src/ocrfeeder/feeder/ocrEngines.py
@@ -151,12 +151,9 @@ class OcrEnginesManager:
self.ocr_engines = []
favorite_engine_exists = False
for xml_file in self.getXmlFilesInFolder(folder):
- try:
- engine = self.getEngineFromXml(xml_file)
+ engine = self.getEngineFromXml(xml_file)
+ if engine:
self.ocr_engines.append((engine, xml_file))
- except WrongSettingsForEngine, we:
- lib.debug("Cannot load engine at %s: %s" %( xml_file, str(we)))
- else:
favorite_engine_exists = favorite_engine_exists or \
self.configuration_manager.favorite_engine == engine.name
if not len(self.ocr_engines):
@@ -195,8 +192,17 @@ class OcrEnginesManager:
arg_name = child.tag
arg_value = child.text
arguments[arg_name] = arg_value
- engine = Engine(**arguments)
- engine.temporary_folder = self.configuration_manager.TEMPORARY_FOLDER
+
+ try:
+ engine = Engine(**arguments)
+ except TypeError, exception:
+ lib.debug('Error when unserializing engine: %s', exception.message)
+ engine = None
+ except WrongSettingsForEngine, we:
+ lib.debug("Cannot load engine at %s: %s" %( xml_file_name, str(we)))
+ engine = None
+ else:
+ engine.temporary_folder = self.configuration_manager.TEMPORARY_FOLDER
return engine
def getXmlFilesInFolder(self, folder):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]