ATLAS Offline Software
InnerDetector
InDetCalibAlgs
SCT_CalibAlgs
scripts
getCastorRun.py
Go to the documentation of this file.
1
#!/afs/cern.ch/sw/lcg/external/Python/2.6.5/i686-slc5-gcc43-opt/bin/python
2
3
# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
4
5
import
os, sys, re
6
import
subprocess
7
8
'''set up the environment '''
9
def
setenv
():
10
os.environ[
"STAGE_SVCCLASS"
]=
"atlcal"
11
12
def
execute
(cmd,args=[]):
13
argList=[cmd]
14
argList.extend(args)
15
myobj=
None
16
try
:
17
myobj=subprocess.Popen(argList,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
18
s,e=myobj.communicate()
19
return
s,e
20
except
:
21
print
e
22
return
s,e
23
24
def
extractFilename
(dirLine):
25
#matchString="[drwx-]10\s+\d+\s+\d+\s+zp\s+\d+\s+[A-Za-z]3\s+\d+(.+)"
26
items=dirLine.split(
' '
)
27
return
items[-1]
28
29
def
rfdir
(fpath):
30
cmd=
"/usr/bin/rfdir"
31
args=[fpath]
32
listing, errs=
execute
(cmd,args)
33
fileList=[
extractFilename
(line)
for
line
in
listing.split(
"\n"
)
if
line!=
""
]
34
return
fileList,errs
35
36
def
composeSctPath
(rootDir,runStr):
37
d=
"/"
38
return
rootDir+d+runStr+d+
"calibration_SCTNoise"
39
40
def
availableFiles
():
41
setenv
()
42
lastInList=-1
43
rootDir=
"/castor/cern.ch/grid/atlas/DAQ/2010"
44
listing,errs=
rfdir
(rootDir)
45
runNames=listing
46
#take the last run
47
runNumberStr=runNames[lastInList]
48
sctNoiseDir=
composeSctPath
(rootDir,runNumberStr)
49
listing,errs=
rfdir
(sctNoiseDir)
50
return
sctNoiseDir, [
extractFilename
(listingLine)
for
listingLine
in
listing]
51
52
def
lastAvailableFile
():
53
lastInList=-1
54
dirPath,fileList=
availableFiles
()
55
return
dirPath+
"/"
+fileList[lastInList]
56
57
def
main
():
58
print
lastAvailableFile
()
59
return
0
60
61
if
__name__ ==
"__main__"
:
62
sys.exit(
main
())
63
64
65
getCastorRun.execute
def execute(cmd, args=[])
Definition:
getCastorRun.py:12
getCastorRun.availableFiles
def availableFiles()
Definition:
getCastorRun.py:40
getCastorRun.composeSctPath
def composeSctPath(rootDir, runStr)
Definition:
getCastorRun.py:36
getCastorRun.lastAvailableFile
def lastAvailableFile()
Definition:
getCastorRun.py:52
getCastorRun.rfdir
def rfdir(fpath)
Definition:
getCastorRun.py:29
getCastorRun.setenv
def setenv()
Definition:
getCastorRun.py:9
getCastorRun.extractFilename
def extractFilename(dirLine)
Definition:
getCastorRun.py:24
getCastorRun.main
def main()
Definition:
getCastorRun.py:57
Generated on Thu Nov 7 2024 21:15:48 for ATLAS Offline Software by
1.8.18