Author: semor Date: Tue Jan 8 00:21:51 2008 New Revision: 4470 URL: http://svn.gna.org/viewcvs/relax?rev=4470&view=rev Log: Merged revisions 4440,4447,4449-4450,4452-4458,4461 via svnmerge from svn+ssh://semor@xxxxxxxxxxx/svn/relax/1.3 ........ r4440 | bugman | 2008-01-07 11:36:57 -0500 (Mon, 07 Jan 2008) | 3 lines Created a directory for user scripts to be used as system/functional tests. ........ r4447 | bugman | 2008-01-07 11:59:23 -0500 (Mon, 07 Jan 2008) | 5 lines Added the quit argument to the run() class method. This is to allow the system/functional tests to run this method and to ask relax not to quit. ........ r4449 | bugman | 2008-01-07 12:09:07 -0500 (Mon, 07 Jan 2008) | 5 lines Created a script containing the commands used in the system test for creating a model-free model. The system test executes the script instead of running the commands itself. ........ r4450 | bugman | 2008-01-07 12:15:09 -0500 (Mon, 07 Jan 2008) | 5 lines The script file is now passed into the interpreter run() method. This change is like to break many things!!! ........ r4452 | bugman | 2008-01-07 12:19:07 -0500 (Mon, 07 Jan 2008) | 3 lines Fixed the running of the script for the model-free m4 model creating system test. ........ r4453 | bugman | 2008-01-07 12:28:57 -0500 (Mon, 07 Jan 2008) | 3 lines Completely changed how the relax program introduction is handled. ........ r4454 | bugman | 2008-01-07 12:35:50 -0500 (Mon, 07 Jan 2008) | 3 lines Added the ability to turn off the printing out of the script prior to its execution. ........ r4455 | bugman | 2008-01-07 12:36:51 -0500 (Mon, 07 Jan 2008) | 3 lines Turned off the printing of the script prior to its execution in the system tests. ........ r4456 | bugman | 2008-01-07 12:42:18 -0500 (Mon, 07 Jan 2008) | 5 lines Shifted the quit option from run() to __init__(). This will remove the need for all system tests using a script to ask the interpreter to not exit. ........ r4457 | bugman | 2008-01-07 12:42:52 -0500 (Mon, 07 Jan 2008) | 3 lines Made the 'intro_string', 'quit', and 'show_script' variables private. ........ r4458 | bugman | 2008-01-07 12:43:35 -0500 (Mon, 07 Jan 2008) | 3 lines Passed the quit flag into the prompt mode of operation. ........ r4461 | semor | 2008-01-07 12:58:13 -0500 (Mon, 07 Jan 2008) | 3 lines Fixed a typo in an import statement. ........ Added: branches/consistency_tests_1.3/test_suite/system_tests/scripts/ - copied from r4461, 1.3/test_suite/system_tests/scripts/ Modified: branches/consistency_tests_1.3/ (props changed) branches/consistency_tests_1.3/prompt/interpreter.py branches/consistency_tests_1.3/relax branches/consistency_tests_1.3/test_suite/system_tests/__init__.py branches/consistency_tests_1.3/test_suite/system_tests/model_free.py Propchange: branches/consistency_tests_1.3/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Tue Jan 8 00:21:51 2008 @@ -1,1 +1,1 @@ -/1.3:1-3320,3333-4175,4223,4241-4335,4338-4433 +/1.3:1-3320,3333-4175,4223,4241-4335,4338-4433,4440-4461 Modified: branches/consistency_tests_1.3/prompt/interpreter.py URL: http://svn.gna.org/viewcvs/relax/branches/consistency_tests_1.3/prompt/interpreter.py?rev=4470&r1=4469&r2=4470&view=diff ============================================================================== --- branches/consistency_tests_1.3/prompt/interpreter.py (original) +++ branches/consistency_tests_1.3/prompt/interpreter.py Tue Jan 8 00:21:51 2008 @@ -78,12 +78,27 @@ class Interpreter: - def __init__(self, relax): - """The interpreter class.""" - - # Place the program class structure under self.relax + def __init__(self, relax, intro_string=None, show_script=True, quit=True): + """The interpreter class. + + @param relax: The relax instance. + @type relax: instance + @param intro_string: The string to print at the start of execution. + @type intro_string: str + @param show_script: If true, the relax will print the script contents prior to executing + the script. + @type show_script: bool + @param quit: If true, the default, then relax will exit after running the run() + method. + @type quit: bool + """ + + # Place the arguments in the class namespace. self.relax = relax - + self.__intro_string = intro_string + self.__show_script = show_script + self.__quit_flag = quit + # The prompts. sys.ps1 = 'relax> ' sys.ps2 = 'relax| ' @@ -137,11 +152,16 @@ self._Vmd = Vmd(relax) - def run(self): + def run(self, script_file=None): """Run the python interpreter. The namespace of this function is the namespace seen inside the interpreter. All user accessible functions, classes, etc, should be placed in this namespace. + + + @param script_file: The script file to be executed. For the interpreter mode, this + should be left as None. + @type script_file: None or str """ # Python modules. @@ -216,12 +236,12 @@ readline.parse_and_bind("tab: complete") # Execute the script file if given. - if self.relax.script_file: + if script_file: # Turn on the function intro flag. self.intro = 1 # Run the script. - run_script(intro=self.relax.intro_string, local=self.local, script_file=self.relax.script_file, quit=1) + run_script(intro=self.__intro_string, local=self.local, script_file=script_file, quit=self.__quit_flag, show_script=self.__show_script) # Test for the dummy mode for generating documentation (then exit). elif hasattr(self.relax, 'dummy_mode'): @@ -231,7 +251,7 @@ # Go to the prompt. else: - prompt(intro=self.relax.intro_string, local=self.local) + prompt(intro=self.__intro_string, local=self.local, quit=self.__quit_flag) def _off(self): @@ -317,7 +337,7 @@ more = 0 -def interact_script(self, intro, local, script_file, quit): +def interact_script(self, intro, local, script_file, quit, show_script=True): """Replacement function for 'code.InteractiveConsole.interact'. This will execute the script file. @@ -331,20 +351,21 @@ local['self'].intro = 1 # Print the script. - try: - file = open(script_file, 'r') - except IOError, warning: + if show_script: try: - raise RelaxError, "The script file '" + script_file + "' does not exist." - except AllRelaxErrors, instance: - sys.stdout.write(instance.__str__()) - sys.stdout.write("\n") - return - sys.stdout.write("script = " + `script_file` + "\n") - sys.stdout.write("----------------------------------------------------------------------------------------------------\n") - sys.stdout.write(file.read()) - sys.stdout.write("----------------------------------------------------------------------------------------------------\n") - file.close() + file = open(script_file, 'r') + except IOError, warning: + try: + raise RelaxError, "The script file '" + script_file + "' does not exist." + except AllRelaxErrors, instance: + sys.stdout.write(instance.__str__()) + sys.stdout.write("\n") + return + sys.stdout.write("script = " + `script_file` + "\n") + sys.stdout.write("----------------------------------------------------------------------------------------------------\n") + sys.stdout.write(file.read()) + sys.stdout.write("----------------------------------------------------------------------------------------------------\n") + file.close() # Execute the script. try: @@ -384,7 +405,7 @@ console.interact(intro, local) -def run_script(intro=None, local=None, script_file=None, quit=1): +def run_script(intro=None, local=None, script_file=None, quit=1, show_script=True): """Python interpreter emulation. This function replaces 'code.interact'. @@ -396,7 +417,7 @@ # The console. console = InteractiveConsole(local) - console.interact(intro, local, script_file, quit) + console.interact(intro, local, script_file, quit, show_script=show_script) def runcode(self, code): Modified: branches/consistency_tests_1.3/relax URL: http://svn.gna.org/viewcvs/relax/branches/consistency_tests_1.3/relax?rev=4470&r1=4469&r2=4470&view=diff ============================================================================== --- branches/consistency_tests_1.3/relax (original) +++ branches/consistency_tests_1.3/relax Tue Jan 8 00:21:51 2008 @@ -139,14 +139,14 @@ elif tee_file and mode != 'thread': tee(tee_file) + # Create a string to pass to the interpreter to print. + intro_string = self.get_intro_string() + # Run the interpreter for the prompt or script modes. if mode == 'prompt' or mode == 'script': - # Create a string to pass to the interpreter to print. - self.set_intro_string() - # Run the interpreter. - self.interpreter = interpreter.Interpreter(self) - self.interpreter.run() + self.interpreter = interpreter.Interpreter(self, intro_string) + self.interpreter.run(self.script_file) # Threading mode. elif mode == 'thread': @@ -167,11 +167,8 @@ # Execute the relax test suite elif mode == 'test suite': - # Create a string to pass to the interpreter to print. - self.set_intro_string() - # Load the interpreter and turn intros on. - self.interpreter = interpreter.Interpreter(self) + self.interpreter = interpreter.Interpreter(self, show_script=False, quit=False) self.interpreter._on() # Run the tests. @@ -180,11 +177,8 @@ # Execute the relax system tests. elif mode == 'system tests': - # Create a string to pass to the interpreter to print. - self.set_intro_string() - # Load the interpreter and turn intros on. - self.interpreter = interpreter.Interpreter(self) + self.interpreter = interpreter.Interpreter(self, show_script=False, quit=False) self.interpreter._on() # Run the tests. @@ -193,9 +187,6 @@ # Execute the relax unit tests. elif mode == 'unit tests': - # Create a string to pass to the interpreter to print. - self.set_intro_string() - # Run the tests. runner = Test_suite_runner(self) runner.run_unit_tests() @@ -366,14 +357,12 @@ return mode, log_file, tee_file - def licence(self): - """Function for displaying the licence.""" - - help(gpl) - - - def set_intro_string(self): - """Create the program introduction.""" + def get_intro_string(self): + """Create the program introduction. + + @return: The program introduction string. + @type return: str + """ # The width of the printout. if self.platform == 'Windows' or self.platform == 'Microsoft': @@ -382,36 +371,45 @@ width = 100 # Some new lines. - self.intro_string = '\n\n\n' + intro_string = '\n\n\n' # Program name and version. string = "relax " + self.version - self.intro_string = self.intro_string + self.spacing(string, width) + '\n\n' + intro_string = intro_string + self.spacing(string, width) + '\n\n' # Program description. string = "Protein dynamics by NMR relaxation data analysis" - self.intro_string = self.intro_string + self.spacing(string, width) + '\n\n' + intro_string = intro_string + self.spacing(string, width) + '\n\n' # Copyright printout. string = "Copyright (C) 2001-2006 Edward d'Auvergne" - self.intro_string = self.intro_string + self.spacing(string, width) + '\n' + intro_string = intro_string + self.spacing(string, width) + '\n' string = "Copyright (C) 2006-2008 the relax development team" - self.intro_string = self.intro_string + self.spacing(string, width) + '\n\n' + intro_string = intro_string + self.spacing(string, width) + '\n\n' # Program licence and help (80 characters wide). if width == 80: - self.intro_string = self.intro_string + "This is free software which you are welcome to modify and redistribute under\n" - self.intro_string = self.intro_string + "the conditions of the GNU General Public License (GPL). This program,\n" - self.intro_string = self.intro_string + "including all modules, is licensed under the GPL and comes with absolutely no\n" - self.intro_string = self.intro_string + "warranty. For details type 'GPL'. Assistance in using this program can be\n" - self.intro_string = self.intro_string + "accessed by typing 'help'.\n" + intro_string = intro_string + "This is free software which you are welcome to modify and redistribute under\n" + intro_string = intro_string + "the conditions of the GNU General Public License (GPL). This program,\n" + intro_string = intro_string + "including all modules, is licensed under the GPL and comes with absolutely no\n" + intro_string = intro_string + "warranty. For details type 'GPL'. Assistance in using this program can be\n" + intro_string = intro_string + "accessed by typing 'help'.\n" # Program licence and help (100 characters wide). else: - self.intro_string = self.intro_string + "This is free software which you are welcome to modify and redistribute under the conditions of the\n" - self.intro_string = self.intro_string + "GNU General Public License (GPL). This program, including all modules, is licensed under the GPL\n" - self.intro_string = self.intro_string + "and comes with absolutely no warranty. For details type 'GPL'. Assistance in using this program\n" - self.intro_string = self.intro_string + "can be accessed by typing 'help'.\n" + intro_string = intro_string + "This is free software which you are welcome to modify and redistribute under the conditions of the\n" + intro_string = intro_string + "GNU General Public License (GPL). This program, including all modules, is licensed under the GPL\n" + intro_string = intro_string + "and comes with absolutely no warranty. For details type 'GPL'. Assistance in using this program\n" + intro_string = intro_string + "can be accessed by typing 'help'.\n" + + # Return the string. + return intro_string + + + def licence(self): + """Function for displaying the licence.""" + + help(gpl) def spacing(self, string, width=100): Modified: branches/consistency_tests_1.3/test_suite/system_tests/__init__.py URL: http://svn.gna.org/viewcvs/relax/branches/consistency_tests_1.3/test_suite/system_tests/__init__.py?rev=4470&r1=4469&r2=4470&view=diff ============================================================================== --- branches/consistency_tests_1.3/test_suite/system_tests/__init__.py (original) +++ branches/consistency_tests_1.3/test_suite/system_tests/__init__.py Tue Jan 8 00:21:51 2008 @@ -42,7 +42,7 @@ __all__ = ['angles', 'consistency_tests', 'diffusion_tensor', - 'generic.py', + 'generic', 'jw_mapping', 'main', 'model_free', Modified: branches/consistency_tests_1.3/test_suite/system_tests/model_free.py URL: http://svn.gna.org/viewcvs/relax/branches/consistency_tests_1.3/test_suite/system_tests/model_free.py?rev=4470&r1=4469&r2=4470&view=diff ============================================================================== --- branches/consistency_tests_1.3/test_suite/system_tests/model_free.py (original) +++ branches/consistency_tests_1.3/test_suite/system_tests/model_free.py Tue Jan 8 00:21:51 2008 @@ -82,14 +82,8 @@ def test_create_m4(self): """Creating model m4 with parameters {S2, te, Rex} using model_free.create_model().""" - # Path of the files. - path = sys.path[-1] + '/test_suite/system_tests/data/model_free/S2_0.970_te_2048_Rex_0.149' - - # Read the sequence. - self.relax.interpreter._Sequence.read(file='noe.500.out', dir=path) - - # Select the model. - self.relax.interpreter._Model_free.create_model(model='m4', equation='mf_orig', params=['S2', 'te', 'Rex'], spin_id=None) + # Execute the script. + self.relax.interpreter.run(script_file='test_suite/system_tests/scripts/create_m4.py') # Alias the current data pipe. cdp = relax_data_store[relax_data_store.current_pipe]