Commit 84267e39 authored by Alexandre's avatar Alexandre

Do not exit on error in check loop

parent 57915ea4
......@@ -619,8 +619,9 @@ if opts.verbose and opts.check:
print("%d IP found : %s" % (len(ip_set), ', '.join(ip_set)))
ok = True
i = 1 # ip counter
i = 0 # ip counter
for ip in ip_set:
i += 1
if opts.dot and opts.vhostname is not None:
extracheck = opts.vhostname
else:
......@@ -640,12 +641,20 @@ for ip in ip_set:
multistreams=opts.multistreams)
except TimeoutError:
error("timeout")
ok = False
continue
except ConnectionRefusedError:
error("Connection to server refused")
ok = False
continue
except ValueError:
error("\"%s\" not a name or an IP address" % url)
ok = False
continue
except socket.gaierror:
error("Could not resolve \"%s\"" % url)
ok = False
continue
except homer.ConnectionDOTException as e:
print(e, file=sys.stderr)
err = "Could not connect to \"%s\"" % url
......@@ -654,27 +663,35 @@ for ip in ip_set:
elif ip is not None:
err += " on %s" % ip
error(err)
ok = False
continue
except (homer.ConnectionException, homer.DOHException) as e:
error(e)
ok = False
continue
if conn.dot and not conn.success:
ok = False
continue
if opts.ifile is not None:
input = open(opts.ifile)
if not opts.check:
ok = run_default(name, conn, opts)
else:
ok = run_check(conn) and ok # need to run run_check first
if opts.ifile is not None:
input.close()
conn.end()
i += 1
conn.end()
if ok:
if opts.check or opts.pipelining:
print('OK')
sys.exit(0)
else:
print('KO')
if opts.check:
print('KO')
sys.exit(1)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment