Author: bugman Date: Tue Jan 27 18:49:07 2009 New Revision: 8684 URL: http://svn.gna.org/viewcvs/relax?rev=8684&view=rev Log: Merged revisions 8683 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3 ........ r8683 | bugman | 2009-01-27 18:48:32 +0100 (Tue, 27 Jan 2009) | 6 lines Improvements to the relax_errors module. The module function save_state() can now function if this module is used by something other than relax. The saved state is also BZip compressed if the bz2 module exists. ........ Modified: branches/ave_noe/ (props changed) branches/ave_noe/relax_errors.py Propchange: branches/ave_noe/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Tue Jan 27 18:49:07 2009 @@ -1,1 +1,1 @@ -/1.3:1-8681 +/1.3:1-8683 Modified: branches/ave_noe/relax_errors.py URL: http://svn.gna.org/viewcvs/relax/branches/ave_noe/relax_errors.py?rev=8684&r1=8683&r2=8684&view=diff ============================================================================== --- branches/ave_noe/relax_errors.py (original) +++ branches/ave_noe/relax_errors.py Tue Jan 27 18:49:07 2009 @@ -25,6 +25,11 @@ # Python module imports. +try: + from bz2 import BZ2File + bz2 = True +except ImportError: + bz2 = False from cPickle import dump from re import match import time @@ -38,14 +43,22 @@ """Save the program state, for debugging purposes.""" # relax data store singleton import. Must be done here! - from data import Relax_data_store; ds = Relax_data_store() + try: + from data import Relax_data_store; ds = Relax_data_store() + + # Ok, this is not relax so don't do anything! + except ImportError: + return # Append the date and time to the save file. now = time.localtime() file_name = "relax_state_%i%02i%02i_%02i%02i%02i" % (now[0], now[2], now[1], now[3], now[4], now[5]) # Open the file for writing. - file = open(file_name, 'w') + if bz2: + file = BZ2File(file_name+'.bz2', 'w') + else: + file = open(file_name, 'w') # Pickle the data class and write it to file dump(ds, file, 1)