Skip to content

Commit

Permalink
Handle import error
Browse files Browse the repository at this point in the history
  • Loading branch information
kalaspuff committed Jul 2, 2018
1 parent 8d242f1 commit 7c45082
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ python:
- 3.6.4
- 3.6.5
- 3.6.6
- 3.7.0
- 3.6-dev # 3.6 development branch
- 3.7-dev # 3.7 development branch
services:
Expand Down
4 changes: 3 additions & 1 deletion tomodachi/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def import_service_file(cls, file_name: str) -> ModuleType:
except ModuleNotFoundError as e: # noqa
file_path_package_name = file_path[:-3] if file_path.endswith('.py') else file_path
if str(e) == "__path__ attribute not found on '{}' while trying to find '{}'".format(file_path_package_name.rsplit('/', 2)[1], '.'.join(file_path_package_name.rsplit('/', 2)[1:])):
# ModuleNotFoundError: __path__ attribute not found on 'os' while trying to find 'os.code'
logging.getLogger('import').warning('Invalid service package/parent name, may conflict with Python internals: "{}" - change parent folder name'.format(file_path.rsplit('/', 2)[1]))
raise ServicePackageError from e
if str(e) == "module '{}' has no attribute '__path__'".format(file_path_package_name.rsplit('/', 2)[1], '.'.join(file_path_package_name.rsplit('/', 2)[1:])):
logging.getLogger('import').warning('Invalid service package/parent name, may conflict with Python internals: "{}" - change parent folder name'.format(file_path.rsplit('/', 2)[1]))
raise ServicePackageError from e
raise e
Expand Down

0 comments on commit 7c45082

Please sign in to comment.