From fe11bad826433ce6a8dcc922cbbd2e42aa6ad465 Mon Sep 17 00:00:00 2001 From: Chris LaRose Date: Sat, 25 Mar 2017 18:32:11 -0700 Subject: [PATCH] Silence ImportErrors for optional dependencies. Fixes #55. --- bumblebee/modules/cpu.py | 6 +++++- bumblebee/modules/memory.py | 5 ++++- bumblebee/modules/nic.py | 5 ++++- bumblebee/modules/weather.py | 5 ++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/bumblebee/modules/cpu.py b/bumblebee/modules/cpu.py index 79e9229..6a24bdc 100644 --- a/bumblebee/modules/cpu.py +++ b/bumblebee/modules/cpu.py @@ -7,7 +7,11 @@ Parameters: * cpu.critical: Critical threshold in % of CPU usage (defaults to 80%) """ -import psutil +try: + import psutil +except ImportError: + pass + import bumblebee.input import bumblebee.output import bumblebee.engine diff --git a/bumblebee/modules/memory.py b/bumblebee/modules/memory.py index 0ab1176..0534f7d 100644 --- a/bumblebee/modules/memory.py +++ b/bumblebee/modules/memory.py @@ -7,7 +7,10 @@ Parameters: * cpu.critical: Critical threshold in % of memory used (defaults to 90%) """ -import psutil +try: + import psutil +except ImportError: + pass import bumblebee.util import bumblebee.input diff --git a/bumblebee/modules/nic.py b/bumblebee/modules/nic.py index 68ef7d1..2ca87a7 100644 --- a/bumblebee/modules/nic.py +++ b/bumblebee/modules/nic.py @@ -6,7 +6,10 @@ Parameters: * nic.exclude: Comma-separated list of interface prefixes to exclude (defaults to "lo,virbr,docker,vboxnet,veth") """ -import netifaces +try: + import netifaces +except ImportError: + pass import bumblebee.util import bumblebee.input diff --git a/bumblebee/modules/weather.py b/bumblebee/modules/weather.py index f959593..4d0416e 100644 --- a/bumblebee/modules/weather.py +++ b/bumblebee/modules/weather.py @@ -18,7 +18,10 @@ import bumblebee.output import bumblebee.engine import json import time -import requests +try: + import requests +except ImportError: + pass class Module(bumblebee.engine.Module): def __init__(self, engine, config):