Skip to content

Commit 0eb6a0a

Browse files
committed
Updated script, now names tmp and output files based upon initial DID input. Checks on input DID added.
1 parent 5796c41 commit 0eb6a0a

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

files/DIDlist_Parse.sh

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,40 @@ if [[ $DID_Check == "" ]]; then
2525
echo "DID provided is blank! Please provide the DID for a dataset!"
2626
exit 2
2727
fi
28-
touch "DIDlist_Parse_tmp"
29-
rucio did list ${Scope}:${DID} > DIDlist_Parse_tmp
28+
Path=$(pwd)
29+
DID_Edit=$(echo "${DID}" | sed -r 's/\//_/g') # Edit the DID string, change / to _
30+
DID_Edit=${DID_Edit:1} # Remove the leading _
31+
tmp_file="${Path}/${DID_Edit}_DIDlist_tmp" # Name a tmp file based upon DID
32+
touch ${tmp_file} # Create file
33+
rucio did list ${Scope}:${DID} > $tmp_file # Dump info on DID to file
3034
# Check DID is a dataset
31-
if ! grep -q DATASET DIDlist_Parse_tmp; then
35+
if ! grep -q DATASET $tmp_file; then
3236
echo "DID is not a dataset! Please provide the DID for a dataset!"
3337
exit 3
3438
fi
3539

3640
# Checks passed, now process the file
37-
rucio did content list --short ${Scope}:${DID} > DIDlist_Parse_tmp # Dump list of files in dataset to a file
38-
touch "DID_Pathlist" # Open the file which will contain the path lst
39-
NLines=$(wc --lines < tmp) # Check number of files to process in total
41+
rucio did content list --short ${Scope}:${DID} > $tmp_file # Dump list of files in dataset to a file
42+
PathListFile="${Path}/${DID_Edit}_DID_Pathlist"
43+
# Need to switch this to name the DID pathlist nicely
44+
touch "${PathListFile}" # Open the file which will contain the path list
45+
NLines=$(wc --lines < $tmp_file) # Check number of files to process in total
4046
NLinesRed=$(( ((${NLines%.*}+5)/10)*10 )) # Round to nearest value of 10 to make the progress counter simpler
4147

42-
echo "Processing ${NLines} files in dataset ${Scope}:${DID}$ and creating file with list of paths."
48+
echo "Processing ${NLines} files in dataset ${Scope}:${DID}$ and creating file with list of paths - ${PathListFile}."
4349
i=0
4450
while IFS='' read -r line || [[ -n "$line" ]]; do
45-
rucio replica list file --protocols root --pfns --rses isopenaccess $line >> DID_Pathlist
51+
rucio replica list file --protocols root --pfns --rses isopenaccess $line >> ${PathListFile}
4652
i=$(( $i + 1 ))
4753
if [[ $(( $i % $(( ${NLinesRed}/10 )) )) == 0 ]]; then # Go to the Microsoft school of progress tracking (aka, lying) and calculate progress
4854
Prog=$(printf %.0f "$((10**2 * ${i}/${NLinesRed}))e-0")
4955
echo "${Prog} % of file list processed"
5056
fi
51-
done < "DIDlist_Parse_tmp"
57+
done < $tmp_file
5258
echo "Parsed provided DID - $DID"
53-
echo "All files locations within this dataset have been printed to DID_Pathlist" # Need to automate this in future such that the file is named sensibly
59+
echo "All files locations within this dataset have been printed to ${PathListFile}" # Need to automate this in future such that the file is named sensibly
60+
sleep 3
5461

55-
rm DIDlist_Parse_tmp # Delete the tmp file
62+
rm $tmp_file # Delete the tmp file
5663

5764
exit 4

0 commit comments

Comments
 (0)