Added function that can find out which IP address interfaces on a computer has.
This commit is contained in:
parent
452ec2c18a
commit
5d76d453a5
@ -3,6 +3,7 @@ import time
|
||||
import traceback
|
||||
import requests
|
||||
import sys
|
||||
import socket
|
||||
|
||||
from subprocess import Popen, PIPE
|
||||
from saml2test.check import CRITICAL
|
||||
@ -32,45 +33,6 @@ class OperationError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
# class Trace(object):
|
||||
# def __init__(self):
|
||||
# self.trace = []
|
||||
# self.start = time.time()
|
||||
#
|
||||
# def request(self, msg):
|
||||
# delta = time.time() - self.start
|
||||
# self.trace.append("%f --> %s" % (delta, msg))
|
||||
#
|
||||
# def reply(self, msg):
|
||||
# delta = time.time() - self.start
|
||||
# self.trace.append("%f <-- %s" % (delta, msg))
|
||||
#
|
||||
# def info(self, msg, who="saml2client"):
|
||||
# delta = time.time() - self.start
|
||||
# self.trace.append("%f - INFO - [%s] %s" % (delta, who, msg))
|
||||
#
|
||||
# def error(self, msg, who="saml2client"):
|
||||
# delta = time.time() - self.start
|
||||
# self.trace.append("%f - ERROR - [%s] %s" % (delta, who, msg))
|
||||
#
|
||||
# def warning(self, msg, who="saml2client"):
|
||||
# delta = time.time() - self.start
|
||||
# self.trace.append("%f - WARNING - [%s] %s" % (delta, who, msg))
|
||||
#
|
||||
# def __str__(self):
|
||||
# return "\n". join([t.encode("utf-8") for t in self.trace])
|
||||
#
|
||||
# def clear(self):
|
||||
# self.trace = []
|
||||
#
|
||||
# def __getitem__(self, item):
|
||||
# return self.trace[item]
|
||||
#
|
||||
# def next(self):
|
||||
# for line in self.trace:
|
||||
# yield line
|
||||
|
||||
|
||||
class ContextFilter(logging.Filter):
|
||||
"""
|
||||
This is a filter which injects time laps information into the log.
|
||||
@ -128,3 +90,8 @@ def exception_trace(tag, exc, log=None):
|
||||
_exc = "Exception: %s" % exc.message.encode("utf-8", "replace")
|
||||
|
||||
return {"status": CRITICAL, "message": _exc, "content": "".join(message)}
|
||||
|
||||
|
||||
def ip_addresses():
|
||||
return [ip for ip in socket.gethostbyname_ex(socket.gethostname())[2]
|
||||
if not ip.startswith("127.")]
|
Loading…
Reference in New Issue
Block a user