Skip to content

Commit 49256cd

Browse files
committed
update some macros and scripts
1 parent f0296df commit 49256cd

File tree

4 files changed

+342
-108
lines changed

4 files changed

+342
-108
lines changed

CernBatch/toBatch.sh

+2-11
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,9 @@ eval `scramv1 runtime -sh`
5454
#echo
5555
#cat $cfg
5656
#echo --------------- End of Configuation File ---------------------------
57-
## cd -
57+
cd -
5858
echo "Current directory $PWD"
59-
# echo cmsRun $cfg globalTag=GR_E_V43::All
60-
# cmsRun $cfg globalTag=GR_E_V43::All
61-
cmsRun $cfg
62-
## root -b -q run.C
59+
cmsRun -p $cfg
6360
echo ""
6461
echo "Directory listing:"
6562
ls -xs
@@ -73,12 +70,6 @@ then
7370
rfcp $file ${outputCastorDir}
7471
rm $file
7572
done
76-
## else
77-
## for file in *.root
78-
## do
79-
## cp $file $PWD
80-
## rm $file
81-
## done
8273
fi
8374

8475
echo

listEOSdir.py

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/usr/bin/python
2+
#
3+
4+
import sys,string,math,os,subprocess,socket
5+
6+
EOS = "/afs/cern.ch/project/eos/installation/0.3.84-aquamarine/bin/eos.select"
7+
8+
Debug=False
9+
# Debug=True
10+
11+
def listFiles(inDir):
12+
13+
dirs=[]
14+
files=getFiles(EOS,"ls",inDir)
15+
for ifile in files:
16+
theFile=os.path.join(inDir,ifile)
17+
isDir=getFileType(EOS,"stat",theFile)
18+
if isDir:
19+
print "d: ",theFile
20+
dirs.append(theFile)
21+
else:
22+
pass
23+
# print "x: ",theFile
24+
return dirs
25+
26+
def runPopen(command,subcommand,inDir):
27+
p1 = subprocess.Popen([command, subcommand, inDir], shell=False, stdout=subprocess.PIPE)
28+
(stdout, stderr)=p1.communicate()
29+
if stderr is not None:
30+
print "Trouble executing the srmls command"
31+
sys.exit(1)
32+
33+
## if Debug:
34+
## print "Raw output"
35+
## print stdout
36+
## print "Done\n"
37+
38+
return (stdout,stderr)
39+
40+
def getFiles(eos,command,inDir):
41+
42+
(stdout, stderr)=runPopen(eos,command,inDir)
43+
44+
tmpfiles=stdout.split('\n')
45+
files=[]
46+
for tfile in tmpfiles:
47+
if len(tfile)>0:
48+
files.append(tfile)
49+
50+
if Debug:
51+
print "\n Number of files in Directory: ",len(files),"\n"
52+
print files
53+
54+
return files
55+
56+
def getFileType(eos,command,inDir):
57+
58+
isDir=False
59+
60+
(stdout, stderr)=runPopen(eos,command,inDir)
61+
output=stdout.split(' ')
62+
# if Debug: print len(output),output
63+
64+
if output[4].find("directory")>-1 and output[3].find("failed")==-1 and output[3].find("log")==-1:
65+
if Debug: print len(output),output
66+
isDir=True
67+
68+
return isDir
69+
70+
if __name__ == '__main__':
71+
72+
narg=len(sys.argv)
73+
if narg != 2:
74+
print "Please specify EOS directory"
75+
sys.exit(1)
76+
77+
inDir=sys.argv[1]
78+
print inDir
79+
80+
while True:
81+
dirs=listFiles(inDir)
82+
## print dirs
83+
if len(dirs)==0:
84+
break
85+
else:
86+
inDir=os.path.join(inDir,dirs[0])
87+

0 commit comments

Comments
 (0)