From 264fcdc59f73e67ea5ff026ef51fb1e416ced525 Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Tue, 29 Jun 2021 10:07:09 +0200
Subject: [PATCH] Move rmtree after processing of arguments

The script may abort because of wrong arguments. It is better not to
have touched anything in that case.
---
 Inst_eddies/inst_eddies_in.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Inst_eddies/inst_eddies_in.py b/Inst_eddies/inst_eddies_in.py
index 7a269db9..74b9edb9 100755
--- a/Inst_eddies/inst_eddies_in.py
+++ b/Inst_eddies/inst_eddies_in.py
@@ -33,10 +33,6 @@ inst_eddies_exe = "@CMAKE_CURRENT_BINARY_DIR@/inst_eddies"
 if not os.access(inst_eddies_exe, os.X_OK):
     sys.exit(inst_eddies_exe + " not found or not executable")
 
-for orient in ["cyclo", "anti"]:
-    if os.access(f"SHPC_{orient}_all_dates", os.F_OK):
-        shutil.rmtree(f"SHPC_{orient}_all_dates")
-        
 dirname, basename = path.split(args.first_file)
 my_date = datetime.datetime.strptime(basename, args.template).date()
 nc_file = args.first_file
@@ -47,6 +43,10 @@ if args.last_date:
 else:
     last_date = my_date
 
+for orient in ["cyclo", "anti"]:
+    if os.access(f"SHPC_{orient}_all_dates", os.F_OK):
+        shutil.rmtree(f"SHPC_{orient}_all_dates")
+        
 while True:
     print("inst_eddies.py: Date:", my_date)
     
-- 
GitLab