Author: bugman Date: Tue Apr 17 17:41:06 2012 New Revision: 15764 URL: http://svn.gna.org/viewcvs/relax?rev=15764&view=rev Log: ANSI escape characters are now turned off forcibly when in GUI mode. The prompt.interpreter.Interpreter class was being initialised during the import startup phase due to the gui.interpreter.Interpreter singleton class. This meant that sys.stdout had not been redirected to the relax controller yet and was still set to the terminal TTY. This hack turns off the relax prompt colouring forcibly. Modified: 1.3/gui/interpreter.py 1.3/prompt/base_class.py 1.3/prompt/interpreter.py Modified: 1.3/gui/interpreter.py URL: http://svn.gna.org/viewcvs/relax/1.3/gui/interpreter.py?rev=15764&r1=15763&r2=15764&view=diff ============================================================================== --- 1.3/gui/interpreter.py (original) +++ 1.3/gui/interpreter.py Tue Apr 17 17:41:06 2012 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2011 Edward d'Auvergne # +# Copyright (C) 2011-2012 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -65,6 +65,11 @@ self._instance._interpreter_thread = Interpreter_thread() self._instance._interpreter_thread.start() + # Hack to turn off ANSI escape characters in GUI mode. + self._instance._interpreter.ps1 = self._instance._interpreter._exec_info.ps1 + self._instance._interpreter.ps2 = self._instance._interpreter._exec_info.ps2 + self._instance._interpreter.ps3 = self._instance._interpreter._exec_info.ps3 + # Already instantiated, so return the instance. return self._instance Modified: 1.3/prompt/base_class.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/base_class.py?rev=15764&r1=15763&r2=15764&view=diff ============================================================================== --- 1.3/prompt/base_class.py (original) +++ 1.3/prompt/base_class.py Tue Apr 17 17:41:06 2012 @@ -226,10 +226,9 @@ self.ps3 = '\n%s' % self.ps1 # Coloured text. - if sys.stdout.isatty(): - self.ps1 = "\033[94m%s\033[0m" % self.ps1 - self.ps2 = "\033[94m%s\033[0m" % self.ps2 - self.ps3 = "\n\033[94m%s\033[0m" % self.ps1 + self.ps1_colour = "\033[94m%s\033[0m" % self.ps1 + self.ps2_colour = "\033[94m%s\033[0m" % self.ps2 + self.ps3_colour = "\n\033[94m%s\033[0m" % self.ps1 Modified: 1.3/prompt/interpreter.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/interpreter.py?rev=15764&r1=15763&r2=15764&view=diff ============================================================================== --- 1.3/prompt/interpreter.py (original) +++ 1.3/prompt/interpreter.py Tue Apr 17 17:41:06 2012 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2003-2011 Edward d'Auvergne # +# Copyright (C) 2003-2012 Edward d'Auvergne # # # # This file is part of the program relax. # # # @@ -131,9 +131,14 @@ self._exec_info = Exec_info() # The prompts (change the Python prompt, as well as the function print outs). - sys.ps1 = self._exec_info.ps1 - sys.ps2 = self._exec_info.ps2 - sys.ps3 = self._exec_info.ps3 + if sys.stdout.isatty(): + sys.ps1 = self._exec_info.ps1_colour + sys.ps2 = self._exec_info.ps2_colour + sys.ps3 = self._exec_info.ps3_colour + else: + sys.ps1 = self._exec_info.ps1 + sys.ps2 = self._exec_info.ps2 + sys.ps3 = self._exec_info.ps3 # The function intro flag (store in the execution information container). self._exec_info.intro = False