def saveRealm(fi): if not defaults.get("set",False): setDefaults() lines = [] if fi is None or fi == "": fi = "default" print "Saving realm %s"% fi fi = "realms/%s.rlm"% fi line = getline(fi,1) comp = {} matchlike = config.get("matchlike",False) if "likerealm" in line: values = [a.strip() for a in line.split('=')] comp = loadRealm("realms/%s.rlm"% values[1]) lines.append(line) write = False for key in config.keys(): if key in rlmkeys and config[key] != defaults.get(key): write = False if matchlike == 2: write = True elif matchlike == 1 and config.get(key) != comp.get(key): write = True elif matchlike == 0 and key in rlmsavekeys: write = True if write: lines.append("%s = %s\n" % (key,config[key])) try: f = open(os.path.abspath(fi), 'w') if config['debug'] > 0: printPretty(lines) f.writelines(lines) except IOError as e: print " Could not write configuration file: %s" % e finally: f.close()
def showConfig(): print "Config:\n-------" for key in config.keys(): value = config[key] if value == str(value): value = "\'%s\'" % value printPretty("'%s':\t%s" % (key,value),stack=False) print "-------"
def saveConfig(fn): if not defaults.get("set",False): setDefaults() lines = [] for key in config.keys(): if (key in cfgkeys or config['rlmincfg']) and config[key] != defaults.get(key): lines.append("%s = %s\n" % (key,config[key])) if config['debug'] > 0: print lines try: f = open(os.path.abspath(fn), 'w') f.writelines(lines) f.close() except IOError as e: print " Could not write configuration file: %s" % e