Hi Everyone, I hope not to offend you with too many question.. I've been lurking a long time. I'm not keen on keeping e-mails or data stored in the public space so this is my first post to the group.
That being said, I'm keen on refining my skills, I hope that I can prove that I've move on beyond the: check the tut, read the faq.. Now as it's out of the way I hope that my questions can be sited as examples for others breaking the procedural barrier. I've seen examples using reduce, map and lamba that cause me to emit a internal "WTFIZDISHI?" _____________________________ With out any further adiou... IsMyKodeHotOrNot.... and how can I improve it... hopefully it will help me with part two... I'm sure anyone with 2 mins and solid skill of python can ballpark this one... _____________________________ #/usr/bin/enviro python #Purpose - a dropped in useracct/pass file is on a new server to build a cluster... Alas there are no home #directories.. Let me rip through the passfile, grab the correct field (or build it) and use it to make the directory! import os, sys, string, copy, getopt, linecache from traceback import format_exception #The file we read in... fileHandle = "/etc/passwd" srcFile = open(fileHandle,'r') srcList = srcFile.readlines() #yah, a for loop that "iterates" through the file of "lines" for i in srcList: strUsr = string.split(i,":") theUsr = strUsr[0] usrHome = "/expirt/home/",theUsr,"/" usrHome = ''.join(usrHome) print "printing usrHome:",usrHome print "is it a dir?: ", os.path.isdir(usrHome) # try to test if it's a dir... for some reason this mis-behaves... maybe I'm not thinking about it correctly.. if os.path.isdir(usrHome) != 'False': print "User Home dir doesn't exist creating." try: os.makedirs('usrHome' ) except Exception, e: print e print "usrHome is: ",usrHome print "theUsr is: ",theUsr os.system('/usr/bin/chmod 750 ' + usrHome) os.system('/usr/bin/chown ' + theUsr + ' ' + usrHome) #OMG, there is directory that happens to already exist! well, due diligence and love for the queen dictates we #provide "due dilligence", (e.g. wipe our asses properly) else: print "User Home dir exist, checking and fixing permissions." print "usrHome is: ",usrHome print "theUsr is: ",theUsr os.system('/usr/bin/chmod 750 ' + usrHome) os.system('/usr/bin/chown ' + theUsr + ' ' + usrHome) #I know that I can't optimize the line below further... or... can I? sys.exit("Thanks for using pyDirFixr...") -- http://mail.python.org/mailman/listinfo/python-list