Show More
@@ -24,21 +24,30 b' from subprocess import Popen,PIPE' | |||||
24 |
|
24 | |||
25 | from IPython import genutils |
|
25 | from IPython import genutils | |
26 |
|
26 | |||
|
27 | import IPython.ipapi | |||
|
28 | ||||
27 | class IpyPopen(Popen): |
|
29 | class IpyPopen(Popen): | |
28 | def go(self): |
|
30 | def go(self): | |
29 | print self.communicate()[0] |
|
31 | print self.communicate()[0] | |
|
32 | def __repr__(self): | |||
|
33 | return '<IPython job "%s">' % self.line | |||
30 |
|
34 | |||
31 | def job(job): |
|
35 | def startjob(job): | |
32 | #p = Popen(r"q:\opt\vlc\vlc.exe http://di.fm/mp3/djmixes.pls") |
|
|||
33 | p = IpyPopen(job, stdout=PIPE) |
|
36 | p = IpyPopen(job, stdout=PIPE) | |
34 | p.line = job |
|
37 | p.line = job | |
35 | return p |
|
38 | return p | |
36 |
|
39 | |||
37 | def jobctrl_prefilter_f(self,line): |
|
40 | def jobctrl_prefilter_f(self,line): | |
38 | if line.startswith('&'): |
|
41 | if line.startswith('&'): | |
39 |
return ' |
|
42 | return '_ip.startjob(%s)' % genutils.make_quoted_expr(line[1:]) | |
40 |
|
43 | |||
41 | raise IPython.ipapi.TryNext |
|
44 | raise IPython.ipapi.TryNext | |
42 |
|
45 | |||
43 | import IPython.ipapi |
|
46 | def install(): | |
44 | IPython.ipapi.get().set_hook('input_prefilter', jobctrl_prefilter_f) |
|
47 | ||
|
48 | ip = IPython.ipapi.get() | |||
|
49 | # needed to make startjob visible as _ip.startjob('blah') | |||
|
50 | ip.startjob = startjob | |||
|
51 | ip.set_hook('input_prefilter', jobctrl_prefilter_f) | |||
|
52 | ||||
|
53 | install() No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now