2 from __future__
import print_function
3 import sys,os,commands,re
4 from CommonMethods
import *
7 sourcePath =
"LatestRuns/" 9 sourceDirList = [sourcePath+
"2010A",sourcePath+
"2010B",sourcePath+
"Commissioning10"]
10 destDirList = [
"2010A",
"2010B",
"Commissioning10"]
12 finalDir = path +
"Results/" 14 if not os.path.isdir(path):
15 error =
"WARNING: path directory doesn't exist! Creating it..." 19 if not os.path.isdir(finalDir):
20 error =
"WARNING: final dir directory doesn't exist! Creating it..." 25 for n
in range(0,len(sourceDirList)):
26 sourceDir = sourceDirList[n] +
'/' 27 destDir = path + destDirList[n] +
'/' 29 print(sourceDir +
" doesn't exist!")
31 fileList =
ls(sourceDir)
32 if not os.path.isdir(destDir):
33 error =
"WARNING: destination directory doesn't exist! Creating it..." 36 copiedFiles =
cp(sourceDir,destDir,fileList,
False,
False)
42 for fileName
in copiedFiles:
44 regExp = re.search(
'(\D+)(\d+)_(\d+)_[a-zA-Z0-9]+.txt',fileName)
48 fullFileName = destDir + fileName
51 with open(fullFileName,
'r') as file: 54 if line.find(
"Runnumber") != -1:
55 tmpRun =
int(line.split(
' ')[1])
56 if runNumber != -1
and tmpRun != runNumber:
57 error =
"This file (" + fileName +
") contains more than 1 run number!" 59 newFileName = regExp.group(1) + regExp.group(2) +
"_" +
str(runNumber) +
"_1.txt" 60 with open(finalDir+newFileName,
'a')
as outFile:
61 outFile.writelines(allTxt)
70 print(
"WARNING: I can't match the regular espression for file: " + fileName)
71 runNumber =
int(line.split(
' ')[1])
75 newFileName = regExp.group(1) + regExp.group(2) +
"_" +
str(runNumber) +
"_" + regExp.group(3) +
".txt" 76 with open(finalDir+newFileName,
'a')
as outFile:
77 outFile.writelines(allTxt)
84 if __name__ ==
"__main__":
S & print(S &os, JobReport::InputFile const &f)