def getConfig(ttime=datetime.datetime.now().strftime("%Y-%m-%d"),
thour=datetime.datetime.now().strftime("%H")):
config ={}
rp={"@Y":ttime.split('-')[0], "@M":ttime.split('-')[1], "@D":ttime.split('-')[2], "@H":thour, } for root, dirs, files in os.walk(config_path): for file in files : try:
ft ='.conf' if ft in file and file.index(ft)>0 and len(file)-len(ft)== file.index(ft):
configObj = ConfigParser.RawConfigParser()
configObj.optionxform=str
configObj.read(root+'/'+file) for sc in configObj.sections(): if config.has_key( sc ):print" Conflict - "+sc
config[ sc ]={} for k,v in configObj.items(sc): for rk in rp.keys():
v=v.replace(rk,rp[rk])
config[ sc ][ k ]= v except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
traceback.print_exception(exceptionType, exceptionValue, exceptionTraceback,limit=2) return config