handled exception if the docker deamon does not expose events on the REST-API

This commit is contained in:
Joachim Lusiardi 2015-01-07 11:38:22 +01:00
parent 312e91a940
commit f7713d84a3
1 changed files with 7 additions and 1 deletions

View File

@ -1,6 +1,7 @@
#!/usr/bin/python3.4
import os
import sys
import http.client
import json
import signal
@ -118,7 +119,12 @@ if not os.path.exists(target_path):
pid = get_pid()
conn = http.client.HTTPConnection("localhost:2375")
conn.request("GET", "/events")
try:
conn.request("GET", "/events")
except ConnectionRefusedError:
print('Docker does not expose events on its REST-API. Perhaps it is not running?')
sys.exit(-1)
response = conn.getresponse()
events = ""