137 msg = logging.getLogger(
'EventUtils' )
138 """Preparing the list of files for CastorScript to transfer to EOS
140 CastorScript is configured to look for *.zip and *.online.pool.root files to transfer.
141 This function count the number of CastorScript bookkeeping files *.COPIED
142 and compare with the number of original data files *.zip and *.online.pool.root to obtain the transfer status.
143 If all transfer has been completed, get the most recent event from eventlist and add it to the transferlist.
144 Zip the corresponding xml file or rename the corresponding pool.root file to trigger the transfer.
146 eventlist: list of events that can be transferred
147 pair: True to transfer atlantis-vp1 pairs. False to transfer atlantis file only.
148 timeinterval: time interval between two events in the transfer list (in seconds).
150 msg.verbose(
'%s begin prepare files for transfer', time.ctime(time.time()))
151 transferlist =
getEventlist(directory, checkpair=pair, remove=
False, patternAtlantis=
'.zip', patternVP1=
'.online.pool.root')
152 if len(transferlist)>0
and eventlist[-1][0] == transferlist[-1][0]
and eventlist[-1][1] == transferlist[-1][1]:
153 msg.debug(
"Last event already in transfer list. No new event to transfer.")
157 matchAtlantis = glob.glob(f
"{directory}/*.zip")
158 copiedAtlantis = glob.glob(f
"{directory}/*.zip.COPIED")
159 matchVP1 = glob.glob(f
"{directory}/*.online.pool.root")
160 copiedVP1 = glob.glob(f
"{directory}/*.online.pool.root.COPIED")
162 if len(matchAtlantis)>len(copiedAtlantis)
or len(matchVP1)>len(copiedVP1):
163 msg.debug(
"There are files in transfer. Do not attemp to add new event to the transfer list.")
166 elif len(transferlist)>0:
168 age = time.time() - os.path.getmtime(f
'{directory}/{transferlist[-1][2]}')
169 if age < timeinterval:
170 msg.debug(
"Wait for %ds before adding new events to the transfer queue. Last event in the queue was added %ds ago.", timeinterval, age)
172 except OSError
as err:
173 msg.warning(
"Failed to check the timestamp of %s. %s", transferlist[-1][2], err)
177 run, event, atlantis, vp1 = eventlist[-1]
180 msg.debug(
'%s going to zip file %s', time.ctime(time.time()), atlantis)
185 msg.debug(
'%s going to rename ESD file %s', time.ctime(time.time()), vp1)
189 msg.verbose(
'%s end prepare files for transfer', time.ctime(time.time()))