Skip to content
Snippets Groups Projects
Commit d33807c2 authored by Yan Grange's avatar Yan Grange :wave:
Browse files

SDC-45: Adding path hashing step

parent 79182df1
No related branches found
No related tags found
No related merge requests found
# INPUT: srmls of source dir #!/usr/bin/env python
import os
from rucio.rse.protocols import protocol
def data_parser(filedata, scope='lofar'):
datafiles = list()
filepaths = list()
lsblocklength = 18
meta = {}
if not len(filedata[-1].strip()):
filedata.pop()
for idx in range(0,len(filedata),18):
fileprops = filedata[idx].strip().split()
nbytes = int(fileprops[0].strip())
pth = fileprops[1]
name = os.path.basename(pth)
checkline = filedata[idx+6]
checksum = checkline.split(":")[1].strip()
datafiles.append({'name':name, 'bytes': nbytes, 'adler32':checksum, 'meta':meta})
filepaths.append(pth)
return filepaths, datafiles
# INPUT: srmls of source dir
# step 1: read filenames from file # step 1: read filenames from file
with open("source_data_list.dat") as sdl:
source_data = sdl.readlines()
filepaths, filelist_data = data_parser(source_data)
# step 2: compute directory hashes # step 2: compute directory hashes
scope = 'lofar'
rdt = protocol.RSEDeterministicTranslation()
for frompath in filepaths:
fname = os.path.basename(frompath)
tosubpath = rdt.path(scope,fname)
print(frompath, tosubpath)
# step 3: move data to directories # step 3: move data to directories
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment