From 80e0b3323bddebb31d4bd4d41fc0aff3fadfa32c Mon Sep 17 00:00:00 2001
From: Yan Grange <grange@astron.nl>
Date: Wed, 26 Aug 2020 12:46:29 +0200
Subject: [PATCH] Fixed pathlist to only show needed bits

---
 create_movescript.py   | 6 +++---
 register_movedfiles.py | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/create_movescript.py b/create_movescript.py
index 06f5d51..984aa44 100755
--- a/create_movescript.py
+++ b/create_movescript.py
@@ -10,7 +10,7 @@ def data_parser(filedata, scope='lofar'):
   meta = {} 
   if not len(filedata[-1].strip()):
     filedata.pop()
-  for idx in range(0,len(filedata),18):
+  for idx in range(lsblocklength,len(filedata),lsblocklength): # skip first because that is the dir itself
     fileprops = filedata[idx].strip().split()
     nbytes = int(fileprops[0].strip())
     pth = fileprops[1]
@@ -40,8 +40,8 @@ for frompath in filepaths:
   tosubpath = rdt.path(scope,fname)
   from_address = "/".join([srm_root_host, frompath])
   to_address = "/".join([rucio_rse_rootdir, tosubpath])
-  topaths.append(to_address)
-  move_commands.append("srmmv {src} {tgt}".format(src=from_address, tgt=to_address))
+  topaths.append(tosubpath[len(scope)+1:]) # strip off scope and slash
+  move_commands.append("srmmv {src} {tgt}\n".format(src=from_address, tgt=to_address))
 with open("data_movescript.sh", 'w') as dms:
   dms.writelines(move_commands)
 
diff --git a/register_movedfiles.py b/register_movedfiles.py
index de1711b..673509a 100755
--- a/register_movedfiles.py
+++ b/register_movedfiles.py
@@ -5,7 +5,7 @@ import cPickle as pickle
 # step 4: Add replicas for files using rucio.client.replicaclient the ReplicaClient class (add_replicas)
 with open("datapaths.pck", "rb") as pathfile:
   data_paths = pickle.load(pathfile)
-
+  print(data_paths[2]) 
 
 # step 4: Add dataset for each observation, add the files to the dataset
 
-- 
GitLab