Show More
@@ -0,0 +1,9 b'' | |||
|
1 | #!/usr/bin/env python | |
|
2 | ||
|
3 | """Thin wrapper around the IPython irunner module. | |
|
4 | ||
|
5 | Run with --help for details, or see the irunner source.""" | |
|
6 | ||
|
7 | from IPython import irunner | |
|
8 | ||
|
9 | irunner.main() |
@@ -71,12 +71,24 b' class InteractiveRunner(object):' | |||
|
71 | 71 | |
|
72 | 72 | - args(None): optional list of strings to pass as arguments to the |
|
73 | 73 | child program. |
|
74 | ||
|
75 | Public members not parameterized in the constructor: | |
|
76 | ||
|
77 | - delaybeforesend(0): Newer versions of pexpect have a delay before | |
|
78 | sending each new input. For our purposes here, it's typically best | |
|
79 | to just set this to zero, but if you encounter reliability problems | |
|
80 | or want an interactive run to pause briefly at each prompt, just | |
|
81 | increase this value (it is measured in seconds). Note that this | |
|
82 | variable is not honored at all by older versions of pexpect. | |
|
74 | 83 | """ |
|
75 | 84 | |
|
76 | 85 | self.program = program |
|
77 | 86 | self.prompts = prompts |
|
78 | 87 | if args is None: args = [] |
|
79 | 88 | self.args = args |
|
89 | # Other public members which we don't make as parameters, but which | |
|
90 | # users may occasionally want to tweak | |
|
91 | self.delaybeforesend = 0 | |
|
80 | 92 | |
|
81 | 93 | def run_file(self,fname,interact=False): |
|
82 | 94 | """Run the given file interactively. |
@@ -119,6 +131,7 b' class InteractiveRunner(object):' | |||
|
119 | 131 | write = sys.stdout.write |
|
120 | 132 | |
|
121 | 133 | c = pexpect.spawn(self.program,self.args,timeout=None) |
|
134 | c.delaybeforesend = self.delaybeforesend | |
|
122 | 135 | |
|
123 | 136 | prompts = c.compile_pattern_list(self.prompts) |
|
124 | 137 | |
@@ -222,13 +235,12 b' class PythonRunner(InteractiveRunner):' | |||
|
222 | 235 | class SAGERunner(InteractiveRunner): |
|
223 | 236 | """Interactive SAGE runner. |
|
224 | 237 | |
|
225 | XXX - This class is currently untested, meant for feedback from the SAGE | |
|
226 | team. """ | |
|
238 | WARNING: this runner only works if you manually configure your SAGE copy | |
|
239 | to use 'colors NoColor' in the ipythonrc config file, since currently the | |
|
240 | prompt matching regexp does not identify color sequences.""" | |
|
227 | 241 | |
|
228 | 242 | def __init__(self,program='sage',args=None): |
|
229 | 243 | """New runner, optionally passing the sage command to use.""" |
|
230 | print 'XXX - This class is currently untested!!!' | |
|
231 | print 'It is a placeholder, meant for feedback from the SAGE team.' | |
|
232 | 244 | |
|
233 | 245 | prompts = ['sage: ',r'\s*\.\.\. '] |
|
234 | 246 | InteractiveRunner.__init__(self,program,prompts,args) |
@@ -246,10 +258,17 b' irunner.py --python -- --help' | |||
|
246 | 258 | |
|
247 | 259 | will pass --help to the python runner. Similarly, |
|
248 | 260 | |
|
249 |
irunner.py --ipython -- -- |
|
|
261 | irunner.py --ipython -- --interact script.ipy | |
|
262 | ||
|
263 | will run the script.ipy file under the IPython runner, and then will start to | |
|
264 | interact with IPython at the end of the script (instead of exiting). | |
|
265 | ||
|
266 | The already implemented runners are listed below; adding one for a new program | |
|
267 | is a trivial task, see the source for examples. | |
|
250 | 268 | |
|
251 | will run the script.ipy file under the IPython runner, logging all output into | |
|
252 | the test.log file. | |
|
269 | WARNING: the SAGE runner only works if you manually configure your SAGE copy | |
|
270 | to use 'colors NoColor' in the ipythonrc config file, since currently the | |
|
271 | prompt matching regexp does not identify color sequences. | |
|
253 | 272 | """ |
|
254 | 273 | |
|
255 | 274 | def main(): |
@@ -263,7 +282,7 b' def main():' | |||
|
263 | 282 | newopt('--python',action='store_const',dest='mode',const='python', |
|
264 | 283 | help='Python interactive runner.') |
|
265 | 284 | newopt('--sage',action='store_const',dest='mode',const='sage', |
|
266 |
help='SAGE interactive runner |
|
|
285 | help='SAGE interactive runner.') | |
|
267 | 286 | |
|
268 | 287 | opts,args = parser.parse_args() |
|
269 | 288 | runners = dict(ipython=IPythonRunner, |
@@ -1,5 +1,15 b'' | |||
|
1 | 1 | 2006-05-31 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2 | 2 | |
|
3 | * scripts/irunner: thin script interface so users don't have to | |
|
4 | find the module and call it as an executable, since modules rarely | |
|
5 | live in people's PATH. | |
|
6 | ||
|
7 | * IPython/irunner.py (InteractiveRunner.__init__): added | |
|
8 | delaybeforesend attribute to control delays with newer versions of | |
|
9 | pexpect. Thanks to detailed help from pexpect's author, Noah | |
|
10 | Spurrier <noah-AT-noah.org>. Noted how to use the SAGE runner | |
|
11 | correctly (it works in NoColor mode). | |
|
12 | ||
|
3 | 13 | * IPython/iplib.py (handle_normal): fix nasty crash reported on |
|
4 | 14 | SAGE list, from improper log() calls. |
|
5 | 15 |
@@ -1011,16 +1011,34 b' Coloring of prompts, code and tracebacks.' | |||
|
1011 | 1011 | These, by default, are only available under Unix-like operating systems. |
|
1012 | 1012 | However, thanks to Gary Bishop's work, Windows XP/2k users can also benefit |
|
1013 | 1013 | from them. |
|
1014 |
His readline library implement |
|
|
1015 |
support, so that IPython under Windows XP/2k can be as friendly |
|
|
1016 | as under Unix-like environments. | |
|
1014 | His readline library originally implemented both GNU readline functionality | |
|
1015 | and color support, so that IPython under Windows XP/2k can be as friendly | |
|
1016 | and powerful as under Unix-like environments. | |
|
1017 | ||
|
1018 | \layout Standard | |
|
1019 | ||
|
1020 | This library, now named | |
|
1021 | \family typewriter | |
|
1022 | PyReadline | |
|
1023 | \family default | |
|
1024 | , has been absorbed by the IPython team (J�rgen Stenarson, in particular), | |
|
1025 | and it continues to be developed with new features, as well as being distribute | |
|
1026 | d directly from the IPython site. | |
|
1017 | 1027 | \layout Standard |
|
1018 | 1028 | |
|
1019 | 1029 | The |
|
1020 | 1030 | \family typewriter |
|
1021 |
|
|
|
1031 | PyReadline | |
|
1032 | \family default | |
|
1033 | extension requires | |
|
1034 | \family typewriter | |
|
1035 | CTypes | |
|
1036 | \family default | |
|
1037 | and the windows IPython installer needs | |
|
1038 | \family typewriter | |
|
1039 | PyWin32 | |
|
1022 | 1040 | \family default |
|
1023 | extension needs two other libraries to work, so in all you need: | |
|
1041 | , so in all you need: | |
|
1024 | 1042 | \layout Enumerate |
|
1025 | 1043 | |
|
1026 | 1044 | |
@@ -1053,14 +1071,16 b' must' | |||
|
1053 | 1071 | |
|
1054 | 1072 | |
|
1055 | 1073 | \family typewriter |
|
1056 | Readline | |
|
1074 | PyReadline | |
|
1057 | 1075 | \family default |
|
1058 | 1076 | for Windows from |
|
1059 |
\begin_inset LatexCommand \htmlurl{http:// |
|
|
1077 | \begin_inset LatexCommand \htmlurl{http://projects.scipy.org/ipython/ipython/wiki/PyReadline/Intro} | |
|
1060 | 1078 | |
|
1061 | 1079 | \end_inset |
|
1062 | 1080 | |
|
1063 | 1081 | . |
|
1082 | That page contains further details on using and configuring the system | |
|
1083 | to your liking. | |
|
1064 | 1084 | \layout Standard |
|
1065 | 1085 | |
|
1066 | 1086 |
General Comments 0
You need to be logged in to leave comments.
Login now