diff --git a/IPython/irunner.py b/IPython/irunner.py index a4b1d56..2f28cab 100755 --- a/IPython/irunner.py +++ b/IPython/irunner.py @@ -71,12 +71,24 @@ class InteractiveRunner(object): - args(None): optional list of strings to pass as arguments to the child program. + + Public members not parameterized in the constructor: + + - delaybeforesend(0): Newer versions of pexpect have a delay before + sending each new input. For our purposes here, it's typically best + to just set this to zero, but if you encounter reliability problems + or want an interactive run to pause briefly at each prompt, just + increase this value (it is measured in seconds). Note that this + variable is not honored at all by older versions of pexpect. """ self.program = program self.prompts = prompts if args is None: args = [] self.args = args + # Other public members which we don't make as parameters, but which + # users may occasionally want to tweak + self.delaybeforesend = 0 def run_file(self,fname,interact=False): """Run the given file interactively. @@ -119,6 +131,7 @@ class InteractiveRunner(object): write = sys.stdout.write c = pexpect.spawn(self.program,self.args,timeout=None) + c.delaybeforesend = self.delaybeforesend prompts = c.compile_pattern_list(self.prompts) @@ -222,13 +235,12 @@ class PythonRunner(InteractiveRunner): class SAGERunner(InteractiveRunner): """Interactive SAGE runner. - XXX - This class is currently untested, meant for feedback from the SAGE - team. """ + WARNING: this runner only works if you manually configure your SAGE copy + to use 'colors NoColor' in the ipythonrc config file, since currently the + prompt matching regexp does not identify color sequences.""" def __init__(self,program='sage',args=None): """New runner, optionally passing the sage command to use.""" - print 'XXX - This class is currently untested!!!' - print 'It is a placeholder, meant for feedback from the SAGE team.' prompts = ['sage: ',r'\s*\.\.\. '] InteractiveRunner.__init__(self,program,prompts,args) @@ -246,10 +258,17 @@ irunner.py --python -- --help will pass --help to the python runner. Similarly, -irunner.py --ipython -- --log test.log script.ipy +irunner.py --ipython -- --interact script.ipy + +will run the script.ipy file under the IPython runner, and then will start to +interact with IPython at the end of the script (instead of exiting). + +The already implemented runners are listed below; adding one for a new program +is a trivial task, see the source for examples. -will run the script.ipy file under the IPython runner, logging all output into -the test.log file. +WARNING: the SAGE runner only works if you manually configure your SAGE copy +to use 'colors NoColor' in the ipythonrc config file, since currently the +prompt matching regexp does not identify color sequences. """ def main(): @@ -263,7 +282,7 @@ def main(): newopt('--python',action='store_const',dest='mode',const='python', help='Python interactive runner.') newopt('--sage',action='store_const',dest='mode',const='sage', - help='SAGE interactive runner - UNTESTED.') + help='SAGE interactive runner.') opts,args = parser.parse_args() runners = dict(ipython=IPythonRunner, diff --git a/doc/ChangeLog b/doc/ChangeLog index 10348a0..1a99898 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,5 +1,15 @@ 2006-05-31 Fernando Perez + * scripts/irunner: thin script interface so users don't have to + find the module and call it as an executable, since modules rarely + live in people's PATH. + + * IPython/irunner.py (InteractiveRunner.__init__): added + delaybeforesend attribute to control delays with newer versions of + pexpect. Thanks to detailed help from pexpect's author, Noah + Spurrier . Noted how to use the SAGE runner + correctly (it works in NoColor mode). + * IPython/iplib.py (handle_normal): fix nasty crash reported on SAGE list, from improper log() calls. diff --git a/doc/manual_base.lyx b/doc/manual_base.lyx index 16647ad..47e9ded 100644 --- a/doc/manual_base.lyx +++ b/doc/manual_base.lyx @@ -1011,16 +1011,34 @@ Coloring of prompts, code and tracebacks. These, by default, are only available under Unix-like operating systems. However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit from them. - His readline library implements both GNU readline functionality and color - support, so that IPython under Windows XP/2k can be as friendly and powerful - as under Unix-like environments. + His readline library originally implemented both GNU readline functionality + and color support, so that IPython under Windows XP/2k can be as friendly + and powerful as under Unix-like environments. + +\layout Standard + +This library, now named +\family typewriter +PyReadline +\family default +, has been absorbed by the IPython team (Jörgen Stenarson, in particular), + and it continues to be developed with new features, as well as being distribute +d directly from the IPython site. \layout Standard The \family typewriter - readline + PyReadline +\family default + extension requires +\family typewriter +CTypes +\family default + and the windows IPython installer needs +\family typewriter +PyWin32 \family default - extension needs two other libraries to work, so in all you need: +, so in all you need: \layout Enumerate @@ -1053,14 +1071,16 @@ must \family typewriter -Readline +PyReadline \family default for Windows from -\begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/uncpythontools} +\begin_inset LatexCommand \htmlurl{http://projects.scipy.org/ipython/ipython/wiki/PyReadline/Intro} \end_inset . + That page contains further details on using and configuring the system + to your liking. \layout Standard diff --git a/scripts/irunner b/scripts/irunner new file mode 100755 index 0000000..c350d39 --- /dev/null +++ b/scripts/irunner @@ -0,0 +1,9 @@ +#!/usr/bin/env python + +"""Thin wrapper around the IPython irunner module. + +Run with --help for details, or see the irunner source.""" + +from IPython import irunner + +irunner.main()