Commit 6e2a98b3 authored by Colomban Wendling's avatar Colomban Wendling

Drop unnecessary dependency on IPy

IPy is only used to get the version of an IP (4 or 6), but the IPs come
from reasonably trustable sources and if incorrect would at worse make
the test fail -- which is valid behavior.

So, no need for a real library to distinguish them, do a naive check
based on the presence of version-specific delimiters.
parent 75eba0ac
......@@ -7,6 +7,5 @@ Dependencies
Written in Python, it needs at least python 3.2 for the ThreadPools.
It also depends on `ipy`, a module for managing IP addresses.
On debian Wheezy the packages are `python3` and `python3-ipy`.
On debian Wheezy the package is `python3`.
from subprocess import Popen, PIPE
import concurrent.futures
from time import sleep
from IPy import IP
def ip_version(addr):
return 6 if ':' in addr else 4
class Check(object):
......@@ -52,7 +55,7 @@ class Check(object):
return ret == 0
def exec_by_ip_family(self, addr, v4command, v6command):
ipv = IP(addr).version()
ipv = ip_version(addr)
if ipv == 4:
return self.exec_with_timeout(v4command)
if ipv == 6:
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