Commit b1a9b282 authored by Jonathan Michalon's avatar Jonathan Michalon

Merge branch 'no-ipy' of http://gitlab.netlib.re/b4n/picomon into b4n/picomon-no-ipy

Conflicts:
	picomon.py
parents c010b729 6e2a98b3
......@@ -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`.
import concurrent.futures
from time import sleep
from IPy import IP
from sys import hexversion as sys_hexversion
......@@ -14,7 +13,7 @@ else:
import subprocess
from subprocess import PIPE
class TimeoutExpired(subprocess.SubprocessError):
class TimeoutExpired(subprocess.CalledProcessError):
def __init__(self, args, timeout=None, output=None):
self.cmd, self.timeout, self.output = args, timeout, output
......@@ -61,6 +60,10 @@ else:
return self._out, self._err
def ip_version(addr):
return 6 if ':' in addr else 4
class Check(object):
def __init__(self, **options):
self._options = options
......@@ -108,7 +111,7 @@ class Check(object):
return p.returncode == 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