Skip to content

Commit d9a4b18

Browse files
authored
Merge pull request #278 from aaron-long/get_submodules_add_exception_for_import_submodules
Extended exception logic to get_submodules on import_module
2 parents 931d96b + 47dc40e commit d9a4b18

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

requirements-dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ sphinx_rtd_theme
77
semantic_version
88
PyYAML
99
scanf>=1.4.1
10-
pytest
10+
pytest>=3.6
1111
pytest-cov
1212
coverage
13-
flake8
13+
flake8==3.5.0
1414
tox

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ def readme():
5959

6060
extras_require={
6161
'epics': ['pcaspy'],
62-
'dev': ['flake8', 'mock>=1.0.1', 'sphinx>=1.4.5', 'sphinx_rtd_theme',
63-
'pytest', 'pytest-cov', 'coverage', 'tox'],
62+
'dev': ['flake8==3.5.0', 'mock>=1.0.1', 'sphinx>=1.4.5', 'sphinx_rtd_theme',
63+
'pytest>=3.6', 'pytest-cov', 'coverage', 'tox'],
6464
},
6565

6666
entry_points={

src/lewis/core/utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@
3737

3838
from .exceptions import LewisException, LimitViolationException
3939
from lewis import __version__
40+
from lewis.core.logging import has_log
4041

4142

43+
@has_log
4244
def get_submodules(module):
4345
"""
4446
This function imports all sub-modules of the supplied module and returns a dictionary
@@ -65,10 +67,11 @@ def get_submodules(module):
6567
try:
6668
submodules[module_name] = importlib.import_module(
6769
'.{}'.format(module_name), package=module.__name__)
68-
except ImportError:
70+
except ImportError as import_error:
6971
# This is necessary in case random directories are in the path or things can
7072
# just not be imported due to other ImportErrors.
71-
pass
73+
get_submodules.log.error("ImportError for {module}: {error}"
74+
.format(module=module_name, error=import_error))
7275

7376
return submodules
7477

0 commit comments

Comments
 (0)