CMS 3D CMS Logo

Functions
fileCollector2 Namespace Reference

Functions

def convert (infile, ofile)
 
def filecheck (rootfile)
 
def isFileOpen (fName)
 
def logme (msg, args)
 
def processSiStrip (fName, finalTfile)
 
def uploadFile (fName, subsystem, run)
 

Function Documentation

def fileCollector2.convert (   infile,
  ofile 
)

Definition at line 71 of file fileCollector2.py.

Referenced by processSiStrip().

71 def convert(infile, ofile):
72  cmd = EXEDIR + '/convert.sh ' + infile + ' ' +ofile
73  os.system(cmd)
74 
def convert(infile, ofile)
def fileCollector2.filecheck (   rootfile)

Definition at line 29 of file fileCollector2.py.

References logme(), and split.

Referenced by processSiStrip().

29 def filecheck(rootfile):
30  cmd = EXEDIR + '/filechk.sh ' + rootfile
31  a = os.popen(cmd).read().split()
32  tag=a.pop()
33  if tag == '(int)(-1)':
34  logme("ERROR: File %s corrupted (isZombi)", rootfile)
35  return False
36  elif tag == '(int)0':
37  logme("ERROR: File %s is incomplete", rootfile)
38  return False
39  elif tag == '(int)1':
40  return True
41  else:
42  return False
43 
def logme(msg, args)
def filecheck(rootfile)
double split
Definition: MVATrainer.cc:139
def fileCollector2.isFileOpen (   fName)

Definition at line 44 of file fileCollector2.py.

Referenced by processSiStrip().

44 def isFileOpen(fName):
45  fName = os.path.realpath(fName)
46  pids=os.listdir('/proc')
47  for pid in sorted(pids):
48  try:
49  if not pid.isdigit():
50  continue
51 
52  if os.stat(os.path.join('/proc',pid)).st_uid != os.getuid():
53  continue
54 
55  uid = os.stat(os.path.join('/proc',pid)).st_uid
56  fd_dir=os.path.join('/proc', pid, 'fd')
57  if os.stat(fd_dir).st_uid != os.getuid():
58  continue
59 
60  for f in os.listdir(fd_dir):
61  fdName = os.path.join(fd_dir, f)
62  if os.path.islink(fdName) :
63  link=os.readlink(fdName)
64  if link == fName:
65  return True
66  except:
67  continue
68 
69  return False
70 
def isFileOpen(fName)
def fileCollector2.logme (   msg,
  args 
)

Definition at line 25 of file fileCollector2.py.

References edm.print().

Referenced by filecheck(), processSiStrip(), and uploadFile().

25 def logme(msg, *args):
26  procid = "[%s/%d]" % (__file__.rsplit("/", 1)[-1], os.getpid())
27  print(datetime.now(), procid, msg % args)
28 
def logme(msg, args)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def fileCollector2.processSiStrip (   fName,
  finalTfile 
)

Definition at line 123 of file fileCollector2.py.

References mps_setup.append, convert(), filecheck(), createfilelist.int, isFileOpen(), logme(), jetUpdater_cfi.sort, and uploadFile().

123 def processSiStrip(fName,finalTfile):
124  dqmfile = fName
125  if "Playback" in fName and "SiStrip" == NEW[rFile]["subSystem"]:
126  dqmfile = fName.replace('Playback','DQM')
127  convert(fName,dqmfile)
128  if not os.path.exists(dqmfile):
129  logme("ERROR: Problem converting %s skiping" % Tfile)
130  shutil.move(fName,finalTfile+"_d")
131  return (dqmfile,False)
132 
133  os.rename(fName,finalTfile.replace('Playback','Playback_full'))
134 
135  return (dqmfile,True)
136 
def processSiStrip(fName, finalTfile)
def logme(msg, args)
def convert(infile, ofile)
def fileCollector2.uploadFile (   fName,
  subsystem,
  run 
)

Definition at line 75 of file fileCollector2.py.

References FrontierConditions_GlobalTag_cff.file, and logme().

Referenced by processSiStrip().

75 def uploadFile(fName, subsystem, run):
76  hname = os.getenv("HOSTNAME")
77  seed=hname.replace("-","t")[-6:]
78  finalTMPfile="%s/DQM_V0001_%s_R%s.root.%s" % (TMP_DROPBOX,subsystem,run,seed)
79  if os.path.exists(finalTMPfile):
80  os.remove(finalTMPfile)
81 
82  md5Digest=md5(file(fName).read())
83  originStr="md5:%s %d %s" % (md5Digest.hexdigest(),os.stat(fName).st_size,fName)
84  originTMPFile="%s.origin" % finalTMPfile
85  originFile=open(originTMPFile,"w")
86  originFile.write(originStr)
87  originFile.close()
88  shutil.copy(fName,finalTMPfile)
89  if not os.path.exists(finalTMPfile) or not os.stat(finalTMPfile).st_size == os.stat(fName).st_size:
90  return False
91 
92  version=1
93  lFile=open("%s/lock" % TMP_DROPBOX ,"a")
94  lockf(lFile,LOCK_EX)
95  for vdir,vsubdir,vfiles in os.walk(DROPBOX):
96  if 'DQM_V0001_%s_R%s.root' % (subsystem,run) not in vfiles:
97  continue
98 
99  version += 1
100 
101  if not os.path.exists("%s/%04d" % (DROPBOX,version)):
102  os.makedirs("%s/%04d" % (DROPBOX,version))
103  os.chmod("%s/%04d" % (DROPBOX,version),2775)
104 
105  finalfile="%s/%04d/DQM_V0001_%s_R%s.root" % (DROPBOX,version,subsystem,run)
106  originFileName="%s.origin" % finalfile
107  try:
108  os.rename(finalTMPfile,finalfile)
109  os.rename(originTMPFile,originFileName)
110  os.chmod(finalfile,stat.S_IREAD|stat.S_IRGRP|stat.S_IROTH| stat.S_IWRITE|stat.S_IWGRP|stat.S_IWOTH)
111  os.chmod(originFileName,stat.S_IREAD|stat.S_IRGRP|stat.S_IROTH| stat.S_IWRITE|stat.S_IWGRP|stat.S_IWOTH)
112  except:
113  lockf(lFile,LOCK_UN)
114  lFile.close()
115  logme("ERROR: File %s upload failed to the DROPBOX" % fName)
116  return False
117 
118  logme("INFO: File %s has been successfully sent to the DROPBOX" % fName)
119  lockf(lFile,LOCK_UN)
120  lFile.close()
121  return True
122 
def logme(msg, args)
def uploadFile(fName, subsystem, run)