Author: bugman Date: Fri Sep 17 10:07:52 2010 New Revision: 11595 URL: http://svn.gna.org/viewcvs/relax?rev=11595&view=rev Log: Merged revisions 11594 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3 ........ r11594 | bugman | 2010-09-17 10:06:20 +0200 (Fri, 17 Sep 2010) | 3 lines Shifted the debug and pedantic flags into the __main__ namespace for better access from other modules. ........ Modified: branches/bieri_gui/ (props changed) branches/bieri_gui/prompt/interpreter.py branches/bieri_gui/relax branches/bieri_gui/relax_errors.py branches/bieri_gui/relax_warnings.py Propchange: branches/bieri_gui/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Fri Sep 17 10:07:52 2010 @@ -1,1 +1,1 @@ -/1.3:1-11591 +/1.3:1-11594 Modified: branches/bieri_gui/prompt/interpreter.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/prompt/interpreter.py?rev=11595&r1=11594&r2=11595&view=diff ============================================================================== --- branches/bieri_gui/prompt/interpreter.py (original) +++ branches/bieri_gui/prompt/interpreter.py Fri Sep 17 10:07:52 2010 @@ -433,7 +433,7 @@ # Catch ctrl-C. except KeyboardInterrupt: # Throw the error. - if Debug: + if __main__.debug: raise # Be nicer to the user. @@ -452,7 +452,7 @@ # Nice output for the user. else: # Print the scary traceback normally hidden from the user. - if Debug: + if __main__.debug: self.showtraceback() # Print the RelaxError message line. Modified: branches/bieri_gui/relax URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/relax?rev=11595&r1=11594&r2=11595&view=diff ============================================================================== --- branches/bieri_gui/relax (original) +++ branches/bieri_gui/relax Fri Sep 17 10:07:52 2010 @@ -83,10 +83,10 @@ self.pid = getpid() # Debugging flag (default is off). - self.Debug = 0 + __main__.debug = False # Pedantic flag (default is off). - self.Pedantic = 0 + __main__.pedantic = False # Setup the object containing the generic functions. self.generic = generic_fns @@ -94,13 +94,8 @@ # Process the command line arguments and determine the relax mode. mode, log_file, tee_file = self.arguments() - # Place the debugging flag in a number of modules which don't have access to this class's namespace. - relax_errors.Debug = self.Debug - relax_warnings.Debug = self.Debug - interpreter.Debug = self.Debug - - # Set up the pedantic flag. - relax_warnings.Pedantic = self.Pedantic + # Set up the warning system. + relax_warnings.setup() # Show the version number and exit. if mode == 'version': @@ -203,11 +198,11 @@ # Debugging flag. if options.debug: - self.Debug = 1 + __main__.debug = True # Pedantic flag. if options.pedantic: - self.Pedantic = 1 + __main__.pedantic = True # Logging. if options.log: Modified: branches/bieri_gui/relax_errors.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/relax_errors.py?rev=11595&r1=11594&r2=11595&view=diff ============================================================================== --- branches/bieri_gui/relax_errors.py (original) +++ branches/bieri_gui/relax_errors.py Fri Sep 17 10:07:52 2010 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2003-2009 Edward d'Auvergne # +# Copyright (C) 2003-2010 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -25,6 +25,7 @@ # Python module imports. +import __main__ try: from bz2 import BZ2File bz2 = True @@ -36,9 +37,6 @@ import time from types import ClassType - -# Global variables. -Debug = False # Text variables. BIN = 'a binary number (0 or 1)' @@ -102,7 +100,7 @@ """Modify the behaviour of the error system.""" # Save the state if debugging is turned on. - if Debug: + if __main__.debug: save_state() # Modify the error message to include 'RelaxError' at the start. Modified: branches/bieri_gui/relax_warnings.py URL: http://svn.gna.org/viewcvs/relax/branches/bieri_gui/relax_warnings.py?rev=11595&r1=11594&r2=11595&view=diff ============================================================================== --- branches/bieri_gui/relax_warnings.py (original) +++ branches/bieri_gui/relax_warnings.py Fri Sep 17 10:07:52 2010 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2003-2009 Edward d'Auvergne # +# Copyright (C) 2003-2010 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -25,16 +25,12 @@ # Python module imports. +import __main__ +import inspect import warnings -import inspect # relax module imports. from relax_errors import BaseError - - -# Global variables. -Debug = False -Pedantic = False # The warning formatting function. @@ -46,7 +42,7 @@ message = "RelaxWarning: %s\n" % message # Print stack-trace in debug mode. - if Debug: + if __main__.debug: tb = "" for frame in inspect.stack()[4:]: file = frame[1] @@ -65,6 +61,20 @@ # Return the warning message. return message + + +def setup(): + """Set up the warning system.""" + + # Format warning messages. + warnings.formatwarning = format + + # Set warning filters. + if __main__.pedantic: + warnings.filterwarnings('error', category=BaseWarning) + else: + warnings.filterwarnings('always', category=BaseWarning) + # Base class for all warnings. @@ -129,16 +139,3 @@ class RelaxDeselectWarning(BaseWarning): def __init__(self, spin_id, reason): self.text = "The spin '%s' has been deselected because of %s." % (spin_id, reason) - - - -# Format warning messages. -warnings.formatwarning = format - -# Set warning filters. -if Pedantic: - warnings.filterwarnings('error', category=BaseWarning) -else: - warnings.filterwarnings('always', category=BaseWarning) - -