Show More
@@ -0,0 +1,44 b'' | |||
|
1 | """ Preliminary "job control" extensions for IPython | |
|
2 | ||
|
3 | requires python 2.4 (or separate 'subprocess' module | |
|
4 | ||
|
5 | At the moment this is in a very "unhelpful" form, will be extended in the future. | |
|
6 | ||
|
7 | Usage: | |
|
8 | ||
|
9 | [ipython]|2> import jobctrl | |
|
10 | [ipython]|3> &ls | |
|
11 | <3> <jobctrl.IpyPopen object at 0x00D87FD0> | |
|
12 | [ipython]|4> _3.go | |
|
13 | -----------> _3.go() | |
|
14 | ChangeLog | |
|
15 | IPython | |
|
16 | MANIFEST.in | |
|
17 | README | |
|
18 | README_Windows.txt | |
|
19 | ||
|
20 | ... | |
|
21 | """ | |
|
22 | ||
|
23 | from subprocess import Popen,PIPE | |
|
24 | ||
|
25 | from IPython import genutils | |
|
26 | ||
|
27 | class IpyPopen(Popen): | |
|
28 | def go(self): | |
|
29 | print self.communicate()[0] | |
|
30 | ||
|
31 | def job(job): | |
|
32 | #p = Popen(r"q:\opt\vlc\vlc.exe http://di.fm/mp3/djmixes.pls") | |
|
33 | p = IpyPopen(job, stdout=PIPE) | |
|
34 | p.line = job | |
|
35 | return p | |
|
36 | ||
|
37 | def jobctrl_prefilter_f(self,line): | |
|
38 | if line.startswith('&'): | |
|
39 | return 'jobctrl.job(%s)' % genutils.make_quoted_expr(line[1:]) | |
|
40 | ||
|
41 | raise IPython.ipapi.TryNext | |
|
42 | ||
|
43 | import IPython.ipapi | |
|
44 | IPython.ipapi.get().set_hook('input_prefilter', jobctrl_prefilter_f) |
@@ -1,3 +1,9 b'' | |||
|
1 | 2006-10-12 Ville Vainio <vivainio@gmail.com> | |
|
2 | ||
|
3 | * jobctrl.py: Add new "jobctrl" extension for spawning background | |
|
4 | processes with "&find /". 'import jobctrl' to try it out. Requires | |
|
5 | 'subprocess' module, standard in python 2.4+. | |
|
6 | ||
|
1 | 7 | 2006-10-09 Fernando Perez <Fernando.Perez@colorado.edu> |
|
2 | 8 | |
|
3 | 9 | * IPython/Magic.py (Magic.parse_options): add a new posix option |
General Comments 0
You need to be logged in to leave comments.
Login now