diff --git a/userconfig.py b/userconfig.py index 44cac2e..d11d60e 100755 --- a/userconfig.py +++ b/userconfig.py @@ -67,19 +67,19 @@ def workdir(directory): debug.debug("===============================", 1) # skip directory if no CONFIGFILE present - if not os.path.isfile(directory+"/"+cfg.get("Main", "CONFIGFILE")): - debug.debug("No %s in %s, skipping." % (cfg.get("Main", "CONFIGFILE"), directory), 1) + if not os.path.isfile(directory+"/"+cfg.get("Main", "configfile")): + debug.debug("No %s in %s, skipping." % (cfg.get("Main", "configfile"), directory), 1) return ({},None) # if not DEST # get config file for directory - dirConfig = Tools.getConfig(directory+"/"+cfg.get("Main", "CONFIGFILE")) + dirConfig = Tools.getConfig(directory+"/"+cfg.get("Main", "configfile")) if not dirConfig: - debug.debug("Cannot read %s in %s, skipping." % (cfg.get("Main", "CONFIGFILE"), directory), 1) + debug.debug("Cannot read %s in %s, skipping." % (cfg.get("Main", "configfile"), directory), 1) return ({},None) # if not dirConfig - destdir = dirConfig.get("Main","DEST") + destdir = dirConfig.get("Main","dest") # destfiles is a dict of all files that will be created from the classes config # key is the destination filename, values are all classes filenames that are used to # build the file @@ -121,7 +121,7 @@ def buildFile(classfiles, destfile, commentstring): returns the name of tempfile""" content = [] if commentstring != "": - content.append(commentstring + " " + cfg.get("Main","STAMP") + " " + time.strftime("%+") + "\n") + content.append(commentstring + " " + cfg.get("Main","stamp") + " " + time.strftime("%+") + "\n") # if commentstring not empty for f in classfiles: @@ -130,8 +130,8 @@ def buildFile(classfiles, destfile, commentstring): fp.close() if commentstring == "": # look for stamp in content, replace with real stamp - if re.search(re.escape(cfg.get("Main","STAMPREPLACE")), filecontent): - filecontent = re.sub(re.escape(cfg.get("Main","STAMPREPLACE")), cfg.get("Main","STAMP"), filecontent) + if re.search(re.escape(cfg.get("Main","stampreplace")), filecontent): + filecontent = re.sub(re.escape(cfg.get("Main","stampreplace")), cfg.get("Main","stamp"), filecontent) # if search # if commentstring empty content.append(filecontent) @@ -227,7 +227,7 @@ def main(): cfg.setfilename(configfile) debug.debug("Classes for host: %s" % hostclasses) - configdir = cfg.get("Main", "CONFIGDIR") + configdir = cfg.get("Main", "configdir") for d in os.listdir(configdir): destfiles = {} name = configdir+d diff --git a/userconfig/Tools.py b/userconfig/Tools.py index 9f1b409..39ceb45 100644 --- a/userconfig/Tools.py +++ b/userconfig/Tools.py @@ -49,6 +49,7 @@ def error(out): def getConfig(filename): """reads filename as config, checks for DEST parameter and returns cfgfile object""" + ret = None try: ret = cfgfile.Conf(filename) except: @@ -57,19 +58,19 @@ def getConfig(filename): # try # check for DEST parameter - if not ret.check("Main", "DEST"): + if not ret.check("Main", "dest"): error("No DEST in config file %s" % filename) return False # if no DEST # replace $HOME with real home directory - if ret.get("Main", "DEST") == "$HOME": - ret.set("Main", "DEST", os.environ['HOME']) + if ret.get("Main", "dest") == "$HOME": + ret.set("Main", "dest", os.environ['HOME']) # if $HOME # make sure DEST ends with / - if not ret.get("Main", "DEST").endswith("/"): - ret.set("Main", "DEST", ret.get("Main", "DEST")+"/") + if not ret.get("Main", "dest").endswith("/"): + ret.set("Main", "dest", ret.get("Main", "dest")+"/") # if not / return ret @@ -123,7 +124,7 @@ def userConfigGenerated(filename, cfg): return False # if not filename - if not cfg.check("Main","STAMP"): + if not cfg.check("Main","stamp"): # no STAMP in userconfig.cfg, so no way to check if file was generated by userconfig return False # no STAMP @@ -131,7 +132,7 @@ def userConfigGenerated(filename, cfg): fp = open(filename, "r") for line in fp: - if re.search(re.escape(cfg.get("Main","STAMP")), line): + if re.search(re.escape(cfg.get("Main","stamp")), line): return True # if search # for line