rewrite to python3

This commit is contained in:
2019-06-12 23:32:05 +02:00
parent 32aa6ff7d2
commit 2114d9a77d
10 changed files with 477 additions and 524 deletions

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# encoding: utf-8
#
# $Id$
@@ -11,68 +11,60 @@ Created by Marcus Stoegbauer on 2013-01-10.
Copyright (c) 2013 __MyCompanyName__. All rights reserved.
"""
import sys
import os
import platform
class checks(object):
def __init__(self):
pass
# def __init__
def getShortHostname(self):
"""docstring for getShortHostname"""
hostname = platform.node()
if hostname.count("."):
hostname = hostname.split(".")[0]
return hostname
# def getShortHostname
def __classesForHost__(self):
"""docstring for __classesForHost"""
classes = []
for c in dir(self):
if c.startswith("__"):
continue
# if __
ret = getattr(self, c)()
if len(ret) == 3:
classes.append(ret)
# for c
return map(lambda k: (k[1],k[2]), sorted(classes, key=lambda k: k[0]))
# def __classesForHost__
def header(self):
"""docstring for header"""
return (0, "", "header")
# def header
def footer(self):
"""docstring for footer"""
return (1000, "", "footer")
def all(self):
"""docstring for all"""
return (998, "", "all")
# def all
def arch(self):
"""docstring for arch"""
return(800, "Arch", platform.system())
# def arch
def hostname(self):
"""docstring for hostname"""
hostname = self.getShortHostname()
return(10, "Host", hostname)
# def hostname
def app(self):
"""docstring for app"""
hostname = self.getShortHostname()
if (hostname == "glitters"):
return(500, "", "rancid_hosts")
else:
return ()
# def app
# def checks
class Checks(object):
def __init__(self):
pass
def get_short_hostname(self):
"""docstring for getShortHostname"""
hostname = platform.node()
if hostname.count("."):
hostname = hostname.split(".")[0]
return hostname
# def getShortHostname
def __classes_for_host__(self):
"""docstring for __classesForHost"""
classes = []
for c in dir(self):
if c.startswith("__"):
continue
ret = getattr(self, c)()
if len(ret) == 3:
classes.append(ret)
return map(lambda k: (k[1], k[2]), sorted(classes, key=lambda k: k[0]))
def header(self):
"""docstring for header"""
return (0, "", "header")
def footer(self):
"""docstring for footer"""
return (1000, "", "footer")
def all(self):
"""docstring for all"""
return (998, "", "all")
def arch(self):
"""docstring for arch"""
return (800, "Arch", platform.system())
def hostname(self):
"""docstring for hostname"""
hostname = self.get_short_hostname()
return (10, "Host", hostname)
def app(self):
"""docstring for app"""
hostname = self.get_short_hostname()
if hostname == "glitters":
return (500, "", "rancid_hosts")
else:
return ()
# def app
# def checks