Manage if Docker-py not found

This commit is contained in:
Nicolargo 2015-01-04 21:17:41 +01:00 committed by Alessio Sergi
parent 71f14b8cb6
commit 41805c6bec

View File

@ -61,11 +61,15 @@ class Plugin(GlancesPlugin):
def connect(self, version=None):
"""Connect to the Docker server"""
# Init connection to the Docker API
try:
if version is None:
ret = docker.Client(base_url='unix://var/run/docker.sock')
else:
ret = docker.Client(base_url='unix://var/run/docker.sock',
version=version)
except NameError:
# docker lib not found
return None
try:
ret.version()
except requests.exceptions.ConnectionError as e: