8 sourcePath =
"LatestRuns/"
10 sourceDirList = [sourcePath+
"2010A",sourcePath+
"2010B",sourcePath+
"Commissioning10"]
11 destDirList = [
"2010A",
"2010B",
"Commissioning10"]
13 finalDir = path +
"Results/"
15 if not os.path.isdir(path):
16 error =
"WARNING: path directory doesn't exist! Creating it..."
20 if not os.path.isdir(finalDir):
21 error =
"WARNING: final dir directory doesn't exist! Creating it..."
26 for n
in range(0,len(sourceDirList)):
27 sourceDir = sourceDirList[n] +
'/'
28 destDir = path + destDirList[n] +
'/'
30 print(sourceDir +
" doesn't exist!")
32 fileList =
ls(sourceDir)
33 if not os.path.isdir(destDir):
34 error =
"WARNING: destination directory doesn't exist! Creating it..."
37 copiedFiles =
cp(sourceDir,destDir,fileList,
False,
False)
43 for fileName
in copiedFiles:
45 regExp = re.search(
'(\D+)(\d+)_(\d+)_[a-zA-Z0-9]+.txt',fileName)
49 fullFileName = destDir + fileName
52 with open(fullFileName,
'r')
as file:
55 if line.find(
"Runnumber") != -1:
56 tmpRun =
int(line.split(
' ')[1])
57 if runNumber != -1
and tmpRun != runNumber:
58 error =
"This file (" + fileName +
") contains more than 1 run number!"
60 newFileName = regExp.group(1) + regExp.group(2) +
"_" +
str(runNumber) +
"_1.txt"
61 with open(finalDir+newFileName,
'a')
as outFile:
62 outFile.writelines(allTxt)
71 print(
"WARNING: I can't match the regular espression for file: " + fileName)
72 runNumber =
int(line.split(
' ')[1])
76 newFileName = regExp.group(1) + regExp.group(2) +
"_" +
str(runNumber) +
"_" + regExp.group(3) +
".txt"
77 with open(finalDir+newFileName,
'a')
as outFile:
78 outFile.writelines(allTxt)