9 sourcePath =
"LatestRuns/"
11 sourceDirList = [sourcePath+
"2010A",sourcePath+
"2010B",sourcePath+
"Commissioning10"]
12 destDirList = [
"2010A",
"2010B",
"Commissioning10"]
14 finalDir = path +
"Results/"
16 if not os.path.isdir(path):
17 error =
"WARNING: path directory doesn't exist! Creating it..."
21 if not os.path.isdir(finalDir):
22 error =
"WARNING: final dir directory doesn't exist! Creating it..."
27 for n
in range(0,len(sourceDirList)):
28 sourceDir = sourceDirList[n] +
'/'
29 destDir = path + destDirList[n] +
'/'
31 print(sourceDir +
" doesn't exist!")
33 fileList =
ls(sourceDir)
34 if not os.path.isdir(destDir):
35 error =
"WARNING: destination directory doesn't exist! Creating it..."
38 copiedFiles =
cp(sourceDir,destDir,fileList,
False,
False)
44 for fileName
in copiedFiles:
46 regExp = re.search(
'(\D+)(\d+)_(\d+)_[a-zA-Z0-9]+.txt',fileName)
50 fullFileName = destDir + fileName
53 with open(fullFileName,
'r') as file:
56 if line.find(
"Runnumber") != -1:
57 tmpRun = int(line.split(
' ')[1])
58 if runNumber != -1
and tmpRun != runNumber:
59 error =
"This file (" + fileName +
") contains more than 1 run number!"
61 newFileName = regExp.group(1) + regExp.group(2) +
"_" +
str(runNumber) +
"_1.txt"
62 with open(finalDir+newFileName,
'a')
as outFile:
63 outFile.writelines(allTxt)
72 print(
"WARNING: I can't match the regular espression for file: " + fileName)
73 runNumber = int(line.split(
' ')[1])
77 newFileName = regExp.group(1) + regExp.group(2) +
"_" +
str(runNumber) +
"_" + regExp.group(3) +
".txt"
78 with open(finalDir+newFileName,
'a')
as outFile:
79 outFile.writelines(allTxt)