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 70 of file fileCollector2.py.

Referenced by processSiStrip().

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

Definition at line 28 of file fileCollector2.py.

References logme(), and split.

Referenced by processSiStrip().

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

Definition at line 43 of file fileCollector2.py.

Referenced by processSiStrip().

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

Definition at line 24 of file fileCollector2.py.

References edm.print().

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

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

Definition at line 122 of file fileCollector2.py.

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

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

Definition at line 74 of file fileCollector2.py.

References FrontierConditions_GlobalTag_cff.file, and logme().

Referenced by processSiStrip().

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