From 6ce2ddeb4999d0d94b09643ca5f8e0f72a04ca17 Mon Sep 17 00:00:00 2001
From: Robert Izzard <r.izzard@surrey.ac.uk>
Date: Tue, 9 Nov 2021 10:07:38 +0000
Subject: [PATCH] better report when slurm_dir isn't empty on new run

---
 binarycpython/utils/grid.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/binarycpython/utils/grid.py b/binarycpython/utils/grid.py
index 524d63743..3bb91d280 100644
--- a/binarycpython/utils/grid.py
+++ b/binarycpython/utils/grid.py
@@ -5011,8 +5011,12 @@ eccentricity3=0
         # make the directories: we do not allow these to already exist
         # as the slurm directory should be a fresh location for each set of jobs
         for dir in dirs:
-            pathlib.Path(self.slurmpath(dir)).mkdir(exist_ok=False,
-                                                    parents=True)
+            try:
+                pathlib.Path(self.slurmpath(dir)).mkdir(exist_ok=False,
+                                                        parents=True)
+            except:
+                print("Tried to make the directory {dir} but it already exists. When you launch a set of binary_c jobs on Slurm, you need to set your slurm_dir to be a fresh directory with no contents.")
+                sys.exit()
 
         # check that they have been made and exist: we need this
         # because on network mounts (NFS) there's often a delay between the mkdir
-- 
GitLab