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

Referenced by processSiStrip().

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

Definition at line 27 of file fileCollector2.py.

References logme(), and split.

Referenced by processSiStrip().

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

Definition at line 42 of file fileCollector2.py.

Referenced by processSiStrip().

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

Definition at line 23 of file fileCollector2.py.

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

23 def logme(msg, *args):
24  procid = "[%s/%d]" % (__file__.rsplit("/", 1)[-1], os.getpid())
25  print datetime.now(), procid, msg % args
26 
def logme(msg, args)
def fileCollector2.processSiStrip (   fName,
  finalTfile 
)

Definition at line 121 of file fileCollector2.py.

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

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

Definition at line 73 of file fileCollector2.py.

References FrontierConditions_GlobalTag_cff.file, and logme().

Referenced by processSiStrip().

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