Initiale Version

This commit is contained in:
Marcus Stoegbauer 2013-01-10 23:35:09 +00:00
commit 9685491307
3 changed files with 112 additions and 0 deletions

0
.ignore Normal file
View File

49
checks.py Normal file
View File

@ -0,0 +1,49 @@
#!/usr/bin/env python
# encoding: utf-8
"""
checks.py
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 __classesForHost__(self):
"""docstring for __classesForHost"""
classes = []
for c in dir(self):
if c.startswith("__"):
continue
# if __
ret = getattr(self, c)()
classes.append(ret)
# for c
return map(lambda k: (k[1],k[2]), sorted(classes, key=lambda k: k[0]))
# def __classesForHost__
def all(self):
"""docstring for all"""
return (999, "", "all")
# def all
def arch(self):
"""docstring for arch"""
return(800, "ARCH", platform.system())
# def arch
def hostname(self):
"""docstring for hostname"""
hostname = platform.node()
if hostname.count("."):
hostname = hostname.split(".")[0]
return(10, "Host", hostname)
# def hostname
# def checks

63
userconfig.py Executable file
View File

@ -0,0 +1,63 @@
#!/usr/bin/env python
# encoding: utf-8
#
# $Id$
# $URL$
"""
userconfig.py
Created by Marcus Stoegbauer on 2013-01-10.
Copyright (c) 2013 __MyCompanyName__. All rights reserved.
"""
import sys
import os
from checks import checks
classchecks = checks()
configdir = "../"
hostclasses = classchecks.__classesForHost__()
def work(directory):
"""docstring for work"""
if not os.path.isfile(directory+"/DEST"):
return
# if not DEST
dirs = os.listdir(directory)
dirs.remove("DEST")
for h in hostclasses:
if h[0] != "":
classdir = directory+"/"+h[0]+"_"+h[1]
else:
classdir = directory+"/"+h[1]
# if all
if os.path.isdir(classdir):
print "Directory",classdir,"exists."
# if classdir
# for hostclasses
return
# def work
def main():
print "Classes for host:",hostclasses
for d in os.listdir(configdir):
name = configdir+d
if not os.path.isdir(name):
continue
elif d.startswith(".svn"):
continue
elif os.path.isfile(name+"/.ignore"):
continue
else:
work(name)
# if
# for d
# def main
if __name__ == '__main__':
main()