mailr12101 - in /1.3: prompt/interpreter.py relax relax_errors.py relax_warnings.py status.py test_suite/test_suite_runner.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on January 03, 2011 - 21:19:
Author: bugman
Date: Mon Jan  3 21:19:24 2011
New Revision: 12101

URL: http://svn.gna.org/viewcvs/relax?rev=12101&view=rev
Log:
Shifted the global relax debug flag from __main__.debug to the relax status 
singleton.

This allows the flag to be defined even when imported from outside of relax.  
Also the pedantic flag
is now being directly passed into the relax warning system and hence has been 
shifted out of
__main__.


Modified:
    1.3/prompt/interpreter.py
    1.3/relax
    1.3/relax_errors.py
    1.3/relax_warnings.py
    1.3/status.py
    1.3/test_suite/test_suite_runner.py

Modified: 1.3/prompt/interpreter.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/prompt/interpreter.py?rev=12101&r1=12100&r2=12101&view=diff
==============================================================================
--- 1.3/prompt/interpreter.py (original)
+++ 1.3/prompt/interpreter.py Mon Jan  3 21:19:24 2011
@@ -27,7 +27,6 @@
 import dep_check
 
 # Python module imports.
-import __main__
 from code import InteractiveConsole, softspace
 from os import F_OK, access, chdir, getcwd, path
 import platform
@@ -486,7 +485,7 @@
         status.exec_lock.release()
 
         # Throw the error.
-        if __main__.debug:
+        if Status().debug:
             raise
 
         # Be nicer to the user.
@@ -508,7 +507,7 @@
         # Nice output for the user.
         else:
             # Print the scary traceback normally hidden from the user.
-            if __main__.debug:
+            if Status().debug:
                 self.showtraceback()
 
             # Print the RelaxError message line.

Modified: 1.3/relax
URL: 
http://svn.gna.org/viewcvs/relax/1.3/relax?rev=12101&r1=12100&r2=12101&view=diff
==============================================================================
--- 1.3/relax (original)
+++ 1.3/relax Mon Jan  3 21:19:24 2011
@@ -81,11 +81,9 @@
         # Get and store the PID of this process.
         self.pid = getpid()
 
-        # Debugging flag (default is off).
-        __main__.debug = False
-
-        # Pedantic flag (default is off).
-        __main__.pedantic = False
+        # Initialise the status singleton.
+        self.status = Status()
+        self.status.setup()
 
         # Setup the object containing the generic functions.
         self.generic = generic_fns
@@ -94,11 +92,7 @@
         mode, log_file, tee_file = self.arguments()
 
         # Set up the warning system.
-        relax_warnings.setup()
-
-        # Initialise the status singleton.
-        status = Status()
-        status.setup()
+        relax_warnings.setup(self.pedantic)
 
         # Show the version number and exit.
         if mode == 'version':
@@ -184,11 +178,12 @@
 
         # Debugging flag.
         if options.debug:
-            __main__.debug = True
+            self.status.debug = True
 
         # Pedantic flag.
+        self.pedantic = False
         if options.pedantic:
-            __main__.pedantic = True
+            self.pedantic = True
 
         # Logging.
         if options.log:

Modified: 1.3/relax_errors.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/relax_errors.py?rev=12101&r1=12100&r2=12101&view=diff
==============================================================================
--- 1.3/relax_errors.py (original)
+++ 1.3/relax_errors.py Mon Jan  3 21:19:24 2011
@@ -25,7 +25,6 @@
 
 
 # Python module imports.
-import __main__
 try:
     from bz2 import BZ2File
     bz2 = True
@@ -36,6 +35,9 @@
 from sys import stderr
 import time
 from types import ClassType
+
+# relax module imports
+from status import Status
 
 
 # Text variables.
@@ -100,7 +102,7 @@
         """Modify the behaviour of the error system."""
 
         # Save the state if debugging is turned on.
-        if __main__.debug:
+        if Status().debug:
             save_state()
 
         # Modify the error message to include 'RelaxError' at the start.

Modified: 1.3/relax_warnings.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/relax_warnings.py?rev=12101&r1=12100&r2=12101&view=diff
==============================================================================
--- 1.3/relax_warnings.py (original)
+++ 1.3/relax_warnings.py Mon Jan  3 21:19:24 2011
@@ -25,12 +25,12 @@
 
 
 # Python module imports.
-import __main__
 import inspect
 import warnings
 
 # relax module imports.
 from relax_errors import BaseError
+from status import Status
 
 
 # The warning formatting function.
@@ -42,7 +42,7 @@
     message = "RelaxWarning: %s\n" % message
 
     # Print stack-trace in debug mode.
-    if __main__.debug:
+    if Status().debug:
         tb = ""
         for frame in inspect.stack()[4:]:
             file = frame[1]
@@ -63,14 +63,14 @@
     return message
 
 
-def setup():
+def setup(pedantic=False):
     """Set up the warning system."""
 
     # Format warning messages.
     warnings.formatwarning = format
 
     # Set warning filters.
-    if __main__.pedantic:
+    if pedantic:
         warnings.filterwarnings('error', category=BaseWarning)
     else:
         warnings.filterwarnings('always', category=BaseWarning)

Modified: 1.3/status.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/status.py?rev=12101&r1=12100&r2=12101&view=diff
==============================================================================
--- 1.3/status.py (original)
+++ 1.3/status.py Mon Jan  3 21:19:24 2011
@@ -24,12 +24,8 @@
 """Module containing the status singleton object."""
 
 # Python module imports.
-import __main__
 from re import search
 from threading import Lock
-
-# relax module imports.
-from relax_errors import RelaxError
 
 
 class Status(object):
@@ -50,8 +46,11 @@
         return self._instance
 
 
-    def setup(self):
+    def setup(self, debug=False):
         """Initialise all the status data structures."""
+
+        # Store the args.
+        self.debug = debug
 
         # Execution lock object.
         self.exec_lock = Exec_lock()
@@ -78,8 +77,11 @@
 class Exec_lock:
     """A type of locking object for locking execution of relax."""
 
-    def __init__(self):
+    def __init__(self, debug=False):
         """Set up the lock-like object."""
+
+        # Store the arg.
+        self.debug = debug
 
         # Init a threading.Lock object.
         self._lock = Lock()
@@ -94,7 +96,7 @@
         self._auto_from_script = False
 
         # Debugging.
-        if __main__.debug:
+        if self.debug:
             self.log = open('lock.log', 'w')
 
 
@@ -111,7 +113,7 @@
             self._script_nest += 1
 
             # Debugging.
-            if __main__.debug:
+            if self.debug:
                 self.log.write("Nested by %s (to level %s)\n" % (name, 
self._script_nest))
                 self.log.flush()
 
@@ -121,7 +123,7 @@
         # Skip locking if an auto-analysis is called from a script.
         if self.locked() and self._name == 'script UI' and search('^auto', 
name):
             # Debugging.
-            if __main__.debug:
+            if self.debug:
                 self.log.write("Skipped unlocking of '%s' lock by '%s'\n" % 
(self._name, name))
                 self.log.flush()
 
@@ -135,7 +137,7 @@
         self._name = name
 
         # Debugging.
-        if __main__.debug:
+        if self.debug:
             self.log.write("Acquired by %s\n" % self._name)
             self.log.flush()
             return
@@ -148,7 +150,7 @@
         """Simulate the Lock.locked() mechanism."""
 
         # Debugging (pseudo-locking based on _name).
-        if __main__.debug:
+        if self.debug:
             if self._name:
                 return True
             else:
@@ -164,7 +166,7 @@
         # Nested scripting.
         if self._script_nest:
             # Debugging.
-            if __main__.debug:
+            if self.debug:
                 self.log.write("Script termination, nest decrement (%s -> 
%s)\n" % (self._script_nest, self._script_nest-1))
                 self.log.flush()
 
@@ -177,7 +179,7 @@
         # Auto-analysis launched from script.
         if self._auto_from_script:
             # Debugging.
-            if __main__.debug:
+            if self.debug:
                 self.log.write("Auto-analysis launched from script, skipping 
release.\n")
                 self.log.flush()
 
@@ -191,7 +193,7 @@
         self._name = None
 
         # Debugging.
-        if __main__.debug:
+        if self.debug:
             # Main text.
             text = 'Release'
 

Modified: 1.3/test_suite/test_suite_runner.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/test_suite/test_suite_runner.py?rev=12101&r1=12100&r2=12101&view=diff
==============================================================================
--- 1.3/test_suite/test_suite_runner.py (original)
+++ 1.3/test_suite/test_suite_runner.py Mon Jan  3 21:19:24 2011
@@ -34,6 +34,7 @@
 # relax module imports.
 import __main__
 from relax_test_runner import RelaxTestRunner
+from status import Status
 
 
 class Test_suite_runner:
@@ -57,9 +58,16 @@
         # Store the args.
         self.tests = tests
 
+        # The status object.
+        self.status = Status()
+
+        # A list for skipped tests.
+        self.status.skip = []
+
 
     def run_all_tests(self):
         """Execute all of the test suite test types."""
+
 
         # Execute the system/functional tests.
         self.run_system_tests()




Related Messages


Powered by MHonArc, Updated Mon Jan 03 21:40:01 2011