From 9685491307543cb832f4f3a299c220ca89ce61c3 Mon Sep 17 00:00:00 2001 From: Marcus Stoegbauer Date: Thu, 10 Jan 2013 23:35:09 +0000 Subject: [PATCH] Initiale Version --- .ignore | 0 checks.py | 49 +++++++++++++++++++++++++++++++++++++++ userconfig.py | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 .ignore create mode 100644 checks.py create mode 100755 userconfig.py diff --git a/.ignore b/.ignore new file mode 100644 index 0000000..e69de29 diff --git a/checks.py b/checks.py new file mode 100644 index 0000000..a640e7f --- /dev/null +++ b/checks.py @@ -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 \ No newline at end of file diff --git a/userconfig.py b/userconfig.py new file mode 100755 index 0000000..6a69030 --- /dev/null +++ b/userconfig.py @@ -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() +