-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoHadd_eos.py
73 lines (50 loc) · 1.48 KB
/
doHadd_eos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/python
#
import sys,string,math,os,subprocess,socket
Location="FNAL"
Debug=False
## Debug=True
SUFFIX=".root"
def usage():
""" Usage: python doHadd <Target> <SourceDir>
hadd all files in eos directory <SourceDir> with suffix .root
"""
pass
def GetFiles(Dir):
return
if __name__ == '__main__':
narg=len(sys.argv)
if narg < 3 :
print usage.__doc__
sys.exit(1)
cwd=os.getcwd()
print "\n Machine:", socket.gethostname(),"\tCurrent directory: ",cwd
TARGET=sys.argv[1]
INDIR=sys.argv[2]
os.chdir(INDIR)
dir="."
filelist=os.listdir(dir)
rootlist=[]
for rfile in filelist:
indx=string.find(rfile,SUFFIX)
if indx>-1:
if Location == 'FNAL':
Prepend="root://cmsxrootd.fnal.gov/"
theFile=os.path.join(INDIR,rfile)
theFile=theFile.replace("/eos/uscms",Prepend)
else:
print "Not yet setup for this location"
sys.exit(1)
rootlist.append(theFile)
# print rootlist
infiles=''
for ifile in rootlist:
infiles=infiles + " " + ifile
## print infiles
os.chdir(cwd)
##p = subprocess.Popen(["hadd",target,infiles], shell=False) ## doesn't seem to work anymore
##sts = os.waitpid(p.pid, 0)[1]
myargs=string.join(["hadd",TARGET])
myargs=string.join([myargs,infiles])
print myargs
os.system(myargs)