Author: bugman Date: Fri Aug 5 15:01:19 2011 New Revision: 14179 URL: http://svn.gna.org/viewcvs/relax?rev=14179&view=rev Log: The dauvergne_protocol is now more robust if the program is interrupted and restarted later. The opt/results.bz2 file is now searched for, and if not the round is assumed incomplete. Modified: 1.3/auto_analyses/dauvergne_protocol.py Modified: 1.3/auto_analyses/dauvergne_protocol.py URL: http://svn.gna.org/viewcvs/relax/1.3/auto_analyses/dauvergne_protocol.py?rev=14179&r1=14178&r2=14179&view=diff ============================================================================== --- 1.3/auto_analyses/dauvergne_protocol.py (original) +++ 1.3/auto_analyses/dauvergne_protocol.py Fri Aug 5 15:01:19 2011 @@ -21,7 +21,7 @@ ############################################################################### # Python module imports. -from os import getcwd, listdir, sep +from os import F_OK, access, getcwd, listdir, sep from re import search from string import lower @@ -488,13 +488,7 @@ # Get a list of all files in the directory model. If no directory exists, set the round to 'init' or 0. try: - # Files are in same directory / no directory specified - if self.save_dir =='': - dir_list = listdir(self.save_dir+sep+model) - - # Directory is specified - else: - dir_list = listdir(self.save_dir+model) + dir_list = listdir(self.save_dir+sep+model) except: return 0 @@ -517,12 +511,35 @@ pass numbers.sort() - # No directories begining with 'round_' exist, set the round to 1. + # No directories beginning with 'round_' exist, set the round to 1. if not len(numbers): return 1 - # Determine the number for the next round (add 1 to the highest number). - return numbers[-1] + 1 + # The highest number. + max_round = numbers[-1] + + # Check that the opt/results file exists for the round (working backwards). + for i in range(max_round, -1, -1): + # Assume the round is complete. + complete_round = i + + # The file root. + file_root = self.results_dir + sep + model + sep + "round_%i" %i + sep + 'results' + + # Stop looping when the opt/results file is found. + if access(file_root + '.bz2', F_OK): + break + if access(file_root + '.gz', F_OK): + break + if access(file_root, F_OK): + break + + # No round, so assume the initial state. + if complete_round == 0: + return 0 + + # Determine the number for the next round (add 1 to the highest completed round). + return complete_round + 1 def execute(self):