From 6a33a0abab3484686891f2cdfe5049176f1416f6 Mon Sep 17 00:00:00 2001 From: Daniel Morcuende Date: Wed, 31 Mar 2021 00:59:34 +0200 Subject: [PATCH] check if dl1 file is symlink before removing --- osa/utils/register.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/osa/utils/register.py b/osa/utils/register.py index 6849381..63180fc 100644 --- a/osa/utils/register.py +++ b/osa/utils/register.py @@ -52,8 +52,13 @@ def register_files(type, run_str, inputdir, prefix, suffix, outputdir): file_basename = os.path.basename(inputf) dl1_filepath = os.path.join(options.directory, file_basename) # Remove the original DL1 files pre DL1ab stage and keep only symlinks - os.remove(dl1_filepath) - os.symlink(outputf, dl1_filepath) + if os.path.isfile(dl1_filepath) and not os.path.islink(dl1_filepath): + os.remove(dl1_filepath) + if os.path.islink(dl1_filepath): + # Link already produced + pass + else: + os.symlink(outputf, dl1_filepath) if prefix == "muons_LST-1" and suffix == ".fits": os.symlink(outputf, inputf) -- GitLab