Definition at line 5 of file copyAndRename.py.
References SimDataFormats::CaloAnalysis.cp, beamvalidation.exit(), createfilelist.int, eostools.ls(), edm.print(), and str.
7 error =
"Usage: copyAndRename fromDir toDir" 9 sourceDir = sys.argv[1] +
'/' 10 destDir = sys.argv[2] +
'/' 12 fileList =
ls(sourceDir,
".txt")
13 if not os.path.isdir(destDir):
14 error =
"WARNING: destination directory doesn't exist! Creating it..." 17 copiedFiles =
cp(sourceDir,destDir,fileList)
19 if len(copiedFiles) != len(fileList):
20 error =
"ERROR: I couldn't copy all files from castor" 23 for fileName
in fileList:
24 fullFileName = destDir + fileName
26 with open(fullFileName,
'r') as file: 28 if line.find(
"Runnumber") != -1:
29 tmpRun =
int(line.split(
' ')[1])
30 if runNumber != -1
and tmpRun != runNumber:
31 error =
"This file (" + fileName +
") contains more than 1 run number! I don't know how to deal with it!" 33 runNumber =
int(line.split(
' ')[1])
35 newFileName = fileName.replace(
"1_.txt",
str(runNumber)+
"_1_.txt")
36 if fileName != newFileName:
37 aCmd =
"mv " + destDir + fileName +
" " + destDir + newFileName
39 output = commands.getstatusoutput(aCmd)
43 print(
"WARNING couldn't find keyword None in file " + fileName)
S & print(S &os, JobReport::InputFile const &f)