1#!/usr/bin/env python3 2 3import glob, sys, os, optparse, shutil, subprocess 4import inspect 5currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) 6sys.path.insert(0,currentdir) 7 8""" 9Simple little script meant to normalize the outputs as 10things are converted over to new test system 11Meant to be deleted after conversion 12""" 13 14def mvfiles(directory): 15 for ofile in glob.glob(directory+"/*.out"): 16 rootdir=os.path.dirname(ofile) 17 base=os.path.splitext(os.path.basename(ofile))[0] 18 if not "_" in base: 19 newname=os.path.join(rootdir,base+"_1.out") 20 subprocess.call("git mv "+ofile+" "+newname,shell=True) 21 22 return 23 24def main(): 25 parser = optparse.OptionParser(usage="%prog [options]") 26 parser.add_option('-d', '--directory', dest='directory', 27 help='Directory containing results of PETSc test system', 28 default='output') 29 options, args = parser.parse_args() 30 31 # Process arguments 32 if len(args) > 0: 33 parser.print_usage() 34 return 35 36 directory=options.directory 37 if not os.path.isdir(directory): 38 print(directory+' is not a directory') 39 return 40 41 mvfiles(directory) 42 43 44if __name__ == "__main__": 45 main() 46