Author: bugman Date: Tue Jan 8 15:18:10 2008 New Revision: 4485 URL: http://svn.gna.org/viewcvs/relax?rev=4485&view=rev Log: Tidied up the interact_script() function (with comments). The function also returns its status. The status is obviously only returned if relax doesn't not quit. Modified: 1.3/prompt/interpreter.py Modified: 1.3/prompt/interpreter.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/interpreter.py?rev=4485&r1=4484&r2=4485&view=diff ============================================================================== --- 1.3/prompt/interpreter.py (original) +++ 1.3/prompt/interpreter.py Tue Jan 8 15:18:10 2008 @@ -367,27 +367,53 @@ sys.stdout.write("----------------------------------------------------------------------------------------------------\n") file.close() + # The execution status. + status = True + # Execute the script. try: execfile(script_file, local) + + # Catch ctrl-C. except KeyboardInterrupt: + # Throw the error. if Debug: raise + + # Be nicer to the user. else: sys.stderr.write("\nScript execution cancelled.\n") + + # The script failed. + status = False + + # Catch the RelaxErrors. except AllRelaxErrors, instance: + # Print the scary traceback normally hidden from the user. if Debug: self.showtraceback() + + # Print the RelaxError message line. else: sys.stderr.write(instance.__str__()) + + # The script failed. + status = False + + # Throw all other errors. except: raise - sys.stdout.write("\n") - - # Quit. + # Add an empty line to make exiting relax look better. + if show_script: + sys.stdout.write("\n") + + # Quit relax. if quit: sys.exit() + + # Return the status. + return status def prompt(intro=None, local=None):