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 8afad49287
commit 50f86cb969

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
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)
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: