Author: bugman
Date: Wed Oct 15 11:38:09 2014
New Revision: 26283

URL: http://svn.gna.org/viewcvs/relax?rev=26283&view=rev
Log:
Added more checks to the determine_rnd() of the dauvergne_protocol model-free 
auto-analysis.

This is to try to catch bizarre situations such as bug #22730 
(https://gna.org/bugs/?22730),
model-free auto-analysis - relax stops and quits at the polate step.

The following additional fatal conditions are now checked for:  A file with the 
same name as the
base model directory already exists;  The base model directory is not readable; 
 The base model
directory is not writable.  The last two could be caused by file system 
corruptions.  In addition,
the presence of the base model directory is checked for using os.path.isdir() 
rather than catching
errors coming out of the os.listdir() function.  These changes should make the 
analysis more robust
in the presence of 'strangeness'.


Modified:
    trunk/auto_analyses/dauvergne_protocol.py

Modified: trunk/auto_analyses/dauvergne_protocol.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/auto_analyses/dauvergne_protocol.py?rev=26283&r1=26282&r2=26283&view=diff
==============================================================================
--- trunk/auto_analyses/dauvergne_protocol.py   (original)
+++ trunk/auto_analyses/dauvergne_protocol.py   Wed Oct 15 11:38:09 2014
@@ -21,7 +21,8 @@
 
 # Python module imports.
 from math import pi
-from os import F_OK, access, getcwd, listdir, sep
+from os import F_OK, R_OK, W_OK, access, getcwd, listdir, sep
+from os.path import isdir
 from re import search
 from time import sleep
 
@@ -494,11 +495,25 @@
     def determine_rnd(self, model=None):
         """Function for returning the name of next round of optimisation."""
 
-        # Get a list of all files in the directory model.  If no directory 
exists, set the round to 'init' or 0.
-        try:
-            dir_list = listdir(self.results_dir+sep+model)
-        except:
+        # The base model directory.
+        base_dir = self.results_dir+sep+model
+
+        # Catch if a file exists with the name of the directory.
+        if not isdir(base_dir) and access(base_dir, F_OK):
+            raise RelaxError("The base model directory '%s' is not usable as a 
file with the same name already exists." % base_dir)
+
+        # If no directory exists, set the round to 'init' or 0.
+        if not isdir(base_dir):
             return 0
+
+        # Is the directory readable and writable.
+        if not access(base_dir, R_OK):
+            raise RelaxError("The base model directory '%s' is not readable." 
% base_dir)
+        if not access(base_dir, W_OK):
+            raise RelaxError("The base model directory '%s' is not writable." 
% base_dir)
+
+        # Get a list of all files in the directory model.
+        dir_list = listdir(base_dir)
 
         # Set the round to 'init' or 0 if there is no directory called 'init'.
         if 'init' not in dir_list:
@@ -532,7 +547,7 @@
             complete_round = i
 
             # The file root.
-            file_root = self.results_dir + sep + model + sep + "round_%i" % i 
+ sep + 'opt' + sep + 'results'
+            file_root = base_dir + sep + "round_%i" % i + sep + 'opt' + sep + 
'results'
 
             # Stop looping when the opt/results file is found.
             if access(file_root + '.bz2', F_OK):


_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-commits mailing list
[email protected]

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits

Reply via email to