openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #09543
[Merge] lp:~gerald-britton/openlp/importer into lp:openlp
jerryb has proposed merging lp:~gerald-britton/openlp/importer into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~gerald-britton/openlp/importer/+merge/62913
This branch contains a change to a single module -- importer.py. The purpose of the change is to add exception reporting for the three imports done under try/except. This will ensure that an entry is written to the log detailing the reason for the failed import. This is important since if the module to be imported is found but it suffers an import failure for some reason, it is helpful to know that reason. For example:
Given a file t.py that has a single line:
import foo
Running an interactive session:
$ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import t
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "t.py", line 1, in <module>
import foo
ImportError: No module named foo
So, the problem above is that "foo" is not found even though module "t" is. Currently, we just catch the ImportError and set a flag indicating that we cannot import that type of song file. With this patch, we will be able to see more about the cause of the failed import, especially if it is a subsequent import failure in a subordinate module.
--
https://code.launchpad.net/~gerald-britton/openlp/importer/+merge/62913
Your team OpenLP Core is requested to review the proposed merge of lp:~gerald-britton/openlp/importer into lp:openlp.
=== modified file 'openlp/plugins/songs/lib/importer.py'
--- openlp/plugins/songs/lib/importer.py 2011-05-26 17:11:22 +0000
+++ openlp/plugins/songs/lib/importer.py 2011-05-30 19:43:26 +0000
@@ -38,20 +38,25 @@
from songshowplusimport import SongShowPlusImport
from foilpresenterimport import FoilPresenterImport
# Imports that might fail
+import logging
+log = logging.getLogger(__name__)
try:
from olp1import import OpenLP1SongImport
HAS_OPENLP1 = True
except ImportError:
+ log.exception('Error importing %s', 'OpenLP1SongImport')
HAS_OPENLP1 = False
try:
from sofimport import SofImport
HAS_SOF = True
except ImportError:
+ log.exception('Error importing %s', 'SofImport')
HAS_SOF = False
try:
from oooimport import OooImport
HAS_OOO = True
except ImportError:
+ log.exception('Error importing %s', 'OooImport')
HAS_OOO = False
class SongFormat(object):
Follow ups