CMS 3D CMS Logo

Functions | Variables
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)
 

Variables

 cmp
 
 COLLECTING_DIR
 
 COLLECTOR_WAIT_TIME
 
 converted
 
 DROPBOX
 
 EXEDIR
 
 f
 
 finalTdir
 
 finalTfile
 
 fList
 
 fMatch
 
 fName
 
 fToUpload
 
 KEEP
 
 LAST_FILE_UPLOADED
 
 LAST_SEEN_RUN
 
 NEW
 ENDLESS LOOP WITH SLEEP. More...
 
 RETRIES
 
 reverse
 
 run
 
 runnr
 
 stdout
 
 STOP_FILE
 
 subsystem
 
 T_FILE_DONE_DIR
 
 TAGS
 
 TMP_DROPBOX
 
 tmpF
 
 tmpFName
 
 transferred
 
 WAIT_TIME_FILE_PT
 

Function Documentation

◆ convert()

def fileCollector2.convert (   infile,
  ofile 
)

Definition at line 71 of file fileCollector2.py.

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

◆ filecheck()

def fileCollector2.filecheck (   rootfile)

Definition at line 29 of file fileCollector2.py.

References logme(), fileinputsource_cfi.read, and submitPVValidationJobs.split().

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)

◆ isFileOpen()

def fileCollector2.isFileOpen (   fName)

Definition at line 44 of file fileCollector2.py.

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)

◆ logme()

def fileCollector2.logme (   msg,
  args 
)

Definition at line 25 of file fileCollector2.py.

References 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)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

◆ processSiStrip()

def fileCollector2.processSiStrip (   fName,
  finalTfile 
)

Definition at line 123 of file fileCollector2.py.

References logme().

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)

◆ uploadFile()

def fileCollector2.uploadFile (   fName,
  subsystem,
  run 
)

Definition at line 75 of file fileCollector2.py.

References geometryDiff.file, logme(), and fileinputsource_cfi.read.

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)

Variable Documentation

◆ cmp

fileCollector2.cmp

Definition at line 251 of file fileCollector2.py.

◆ COLLECTING_DIR

fileCollector2.COLLECTING_DIR

Definition at line 11 of file fileCollector2.py.

◆ COLLECTOR_WAIT_TIME

fileCollector2.COLLECTOR_WAIT_TIME

Definition at line 16 of file fileCollector2.py.

◆ converted

fileCollector2.converted

◆ DROPBOX

fileCollector2.DROPBOX

Definition at line 13 of file fileCollector2.py.

◆ EXEDIR

fileCollector2.EXEDIR

Definition at line 15 of file fileCollector2.py.

◆ f

fileCollector2.f

Definition at line 161 of file fileCollector2.py.

◆ finalTdir

fileCollector2.finalTdir

Definition at line 195 of file fileCollector2.py.

◆ finalTfile

fileCollector2.finalTfile

Definition at line 202 of file fileCollector2.py.

◆ fList

fileCollector2.fList

◆ fMatch

fileCollector2.fMatch

Definition at line 157 of file fileCollector2.py.

◆ fName

fileCollector2.fName

◆ fToUpload

fileCollector2.fToUpload

Definition at line 211 of file fileCollector2.py.

◆ KEEP

fileCollector2.KEEP

Definition at line 19 of file fileCollector2.py.

◆ LAST_FILE_UPLOADED

fileCollector2.LAST_FILE_UPLOADED

Definition at line 140 of file fileCollector2.py.

◆ LAST_SEEN_RUN

fileCollector2.LAST_SEEN_RUN

Definition at line 139 of file fileCollector2.py.

◆ NEW

fileCollector2.NEW

ENDLESS LOOP WITH SLEEP.

Definition at line 138 of file fileCollector2.py.

◆ RETRIES

fileCollector2.RETRIES

Definition at line 20 of file fileCollector2.py.

◆ reverse

fileCollector2.reverse

Definition at line 151 of file fileCollector2.py.

◆ run

fileCollector2.run

Definition at line 193 of file fileCollector2.py.

◆ runnr

fileCollector2.runnr

Definition at line 159 of file fileCollector2.py.

◆ stdout

fileCollector2.stdout

Definition at line 22 of file fileCollector2.py.

◆ STOP_FILE

fileCollector2.STOP_FILE

Definition at line 21 of file fileCollector2.py.

◆ subsystem

fileCollector2.subsystem

Definition at line 160 of file fileCollector2.py.

◆ T_FILE_DONE_DIR

fileCollector2.T_FILE_DONE_DIR

Definition at line 12 of file fileCollector2.py.

◆ TAGS

fileCollector2.TAGS

Definition at line 151 of file fileCollector2.py.

◆ TMP_DROPBOX

fileCollector2.TMP_DROPBOX

Definition at line 18 of file fileCollector2.py.

◆ tmpF

fileCollector2.tmpF

Definition at line 288 of file fileCollector2.py.

◆ tmpFName

fileCollector2.tmpFName

Definition at line 275 of file fileCollector2.py.

◆ transferred

fileCollector2.transferred

Definition at line 192 of file fileCollector2.py.

◆ WAIT_TIME_FILE_PT

fileCollector2.WAIT_TIME_FILE_PT

Definition at line 17 of file fileCollector2.py.