make_clean.py.html | |
Source file: make_clean.py | |
Directory: /home/rjl/git/rjleveque/clawpack-4.x/python | |
Converted: Sun May 15 2011 at 19:16:12 using clawcode2html | |
This documentation file will not reflect any later changes in the source file. |
""" Performs 'make clean' in each subdirectory of the specified directory. """ import os,sys,glob def make_clean(rootdir): if rootdir==[]: # if called from command line with no argument clawdir = os.path.expandvars('$CLAW') rootdir = clawdir else: # called with an argument, try to use this for rootdir: rootdir = rootdir[0] rootdir = os.path.abspath(rootdir) print "Will execute 'make clean' in every subdirectory of " print " ", rootdir ans = raw_input("Ok? ") if ans.lower() not in ['y','yes']: print "Aborting." sys.exit() os.chdir(rootdir) for (dirpath, subdirs, files) in os.walk('.'): currentdir = os.path.abspath(os.getcwd()) os.chdir(os.path.abspath(dirpath)) if os.path.isfile('Makefile'): print 'In directory ',dirpath try: os.system('make clean') except: pass os.chdir(currentdir) if __name__=='__main__': make_clean(sys.argv[1:])