Skip to content

Commit

Permalink
Let a provider import raise an exception on a missing library and fix…
Browse files Browse the repository at this point in the history
… imports for non-dev library installs
  • Loading branch information
afgane committed Jan 30, 2016
1 parent b77a41f commit 9eb6995
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
9 changes: 3 additions & 6 deletions cloudbridge/cloud/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,11 @@ def register_provider_class(self, cls):
def discover_providers(self):
"""
Discover all available providers within the
cloudbridge.cloud.providers package.
``cloudbridge.cloud.providers`` package.
Note that this methods does not guard against a failed import.
"""
for _, modname, _ in pkgutil.iter_modules(providers.__path__):
try:
self._import_provider(modname)
except:
log.exception("Could not import providers from module: %s",
modname)
self._import_provider(modname)

def _import_provider(self, module_name):
"""
Expand Down
11 changes: 8 additions & 3 deletions cloudbridge/cloud/providers/aws/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@

import boto
from boto.ec2.regioninfo import RegionInfo
from httpretty import HTTPretty
from moto.ec2 import mock_ec2
from moto.s3 import mock_s3
try:
# These are installed only for the case of a dev instance
from httpretty import HTTPretty
from moto.ec2 import mock_ec2
from moto.s3 import mock_s3
except ImportError:
# TODO: Once library logging is configured, change this
print("[aws provider] moto library not available!")

from cloudbridge.cloud.base import BaseCloudProvider
from cloudbridge.cloud.interfaces import TestMockHelperMixin
Expand Down

0 comments on commit 9eb6995

Please sign in to comment.