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