From a579f3287900ab2b98022a59a268b9d7b6b22b47 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Thu, 18 Oct 2018 19:34:27 +0200 Subject: [PATCH] [modules/docker] Return n/a when docker is not available When the docker python module is not available, return n/a instead of error'ing out. --- README.md | 2 +- bumblebee/modules/docker_ps.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4573fba..194edff 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Test Coverage](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status/badges/coverage.svg)](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status/coverage) [![Issue Count](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status/badges/issue_count.svg)](https://codeclimate.com/github/tobi-wan-kenobi/bumblebee-status) -**Many, many thanks to all contributors! As of now, 32 of the modules are from various contributors (!), and only 16 from myself.** +**Many, many thanks to all contributors! As of now, 33 of the modules are from various contributors (!), and only 16 from myself.** ![Solarized Powerline](https://github.com/tobi-wan-kenobi/bumblebee-status/blob/master/screenshots/themes/powerline-solarized.png) diff --git a/bumblebee/modules/docker_ps.py b/bumblebee/modules/docker_ps.py index 5c1e031..c36c0e7 100644 --- a/bumblebee/modules/docker_ps.py +++ b/bumblebee/modules/docker_ps.py @@ -29,9 +29,11 @@ class Module(bumblebee.engine.Module): self._status = self.status def status(self, _): - cli = docker.DockerClient(base_url='unix://var/run/docker.sock') try: + cli = docker.DockerClient(base_url='unix://var/run/docker.sock') cli.ping() except ConnectionError: return "Daemon off" + except Exception: + return "n/a" return "OK - {}".format(len(cli.containers.list(filters={'status': "running"})))