[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.
This commit is contained in:
parent
f7d80d8f27
commit
a579f32879
2 changed files with 4 additions and 2 deletions
|
@ -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)
|
[![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)
|
[![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)
|
![Solarized Powerline](https://github.com/tobi-wan-kenobi/bumblebee-status/blob/master/screenshots/themes/powerline-solarized.png)
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,11 @@ class Module(bumblebee.engine.Module):
|
||||||
self._status = self.status
|
self._status = self.status
|
||||||
|
|
||||||
def status(self, _):
|
def status(self, _):
|
||||||
cli = docker.DockerClient(base_url='unix://var/run/docker.sock')
|
|
||||||
try:
|
try:
|
||||||
|
cli = docker.DockerClient(base_url='unix://var/run/docker.sock')
|
||||||
cli.ping()
|
cli.ping()
|
||||||
except ConnectionError:
|
except ConnectionError:
|
||||||
return "Daemon off"
|
return "Daemon off"
|
||||||
|
except Exception:
|
||||||
|
return "n/a"
|
||||||
return "OK - {}".format(len(cli.containers.list(filters={'status': "running"})))
|
return "OK - {}".format(len(cli.containers.list(filters={'status': "running"})))
|
||||||
|
|
Loading…
Reference in a new issue