Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(576)

Unified Diff: tools/telemetry/telemetry/util/external_modules.py

Issue 804513002: [Telemetry] Helpers for optional and required external modules (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comment Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/util/external_modules.py
diff --git a/tools/telemetry/telemetry/util/external_modules.py b/tools/telemetry/telemetry/util/external_modules.py
index 4d2bc83515db391c8684bb968a607e9c5f88f968..6a504aeb353121d37f2bebe8c1ff150389511b9c 100644
--- a/tools/telemetry/telemetry/util/external_modules.py
+++ b/tools/telemetry/telemetry/util/external_modules.py
@@ -11,9 +11,11 @@ MODULES = {
'numpy': (version.StrictVersion('1.6.1'), None),
}
-def ImportOptionalModule(module):
+def ImportRequiredModule(module):
"""Tries to import the desired module.
+ Returns:
+ The module on success, raises error on failure.
Raises:
ImportError: The import failed."""
versions = MODULES.get(module)
@@ -41,3 +43,13 @@ def ImportOptionalModule(module):
else:
raise
return module
+
+def ImportOptionalModule(module):
+ """Tries to import the desired module.
+
+ Returns:
+ The module if successful, None if not."""
+ try:
+ return ImportRequiredModule(module)
+ except ImportError:
+ return None
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698