summaryrefslogtreecommitdiff
path: root/cloudinit/importer.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2014-09-02 13:31:18 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2014-09-02 13:31:18 -0700
commit141caf7f3b224c0265c7bb0014b96ca08aa67193 (patch)
tree92e23f731504ee7f2d9f2f31feb76b28179ae3b9 /cloudinit/importer.py
parent128fd80cb0b27430def29bee7a8c473facd84be8 (diff)
downloadvyos-cloud-init-141caf7f3b224c0265c7bb0014b96ca08aa67193.tar.gz
vyos-cloud-init-141caf7f3b224c0265c7bb0014b96ca08aa67193.zip
Remove/adjust the verbose 'failed at attempted import of' log
Instead of using this log (which really isn't a failure) we should instead of just return the looked up locations and then if there really is an error the caller can handle the usage of the looked up locations as they choose fit.
Diffstat (limited to 'cloudinit/importer.py')
-rw-r--r--cloudinit/importer.py21
1 files changed, 8 insertions, 13 deletions
diff --git a/cloudinit/importer.py b/cloudinit/importer.py
index a1929137..fb57253c 100644
--- a/cloudinit/importer.py
+++ b/cloudinit/importer.py
@@ -22,10 +22,6 @@
import sys
-from cloudinit import log as logging
-
-LOG = logging.getLogger(__name__)
-
def import_module(module_name):
__import__(module_name)
@@ -33,25 +29,24 @@ def import_module(module_name):
def find_module(base_name, search_paths, required_attrs=None):
- found_places = []
if not required_attrs:
required_attrs = []
# NOTE(harlowja): translate the search paths to include the base name.
- real_paths = []
+ lookup_paths = []
for path in search_paths:
real_path = []
if path:
real_path.extend(path.split("."))
real_path.append(base_name)
full_path = '.'.join(real_path)
- real_paths.append(full_path)
- for full_path in real_paths:
+ lookup_paths.append(full_path)
+ found_paths = []
+ for full_path in lookup_paths:
mod = None
try:
mod = import_module(full_path)
- except ImportError as e:
- LOG.debug("Failed at attempted import of '%s' due to: %s",
- full_path, e)
+ except ImportError:
+ pass
if not mod:
continue
found_attrs = 0
@@ -59,5 +54,5 @@ def find_module(base_name, search_paths, required_attrs=None):
if hasattr(mod, attr):
found_attrs += 1
if found_attrs == len(required_attrs):
- found_places.append(full_path)
- return found_places
+ found_paths.append(full_path)
+ return (found_paths, lookup_paths)