##// END OF EJS Templates
jobctrl: publish in _ip namespace after installation
vivainio -
Show More
@@ -24,21 +24,30 b' from subprocess import Popen,PIPE'
24 24
25 25 from IPython import genutils
26 26
27 import IPython.ipapi
28
27 29 class IpyPopen(Popen):
28 30 def go(self):
29 31 print self.communicate()[0]
32 def __repr__(self):
33 return '<IPython job "%s">' % self.line
30 34
31 def job(job):
32 #p = Popen(r"q:\opt\vlc\vlc.exe http://di.fm/mp3/djmixes.pls")
35 def startjob(job):
33 36 p = IpyPopen(job, stdout=PIPE)
34 37 p.line = job
35 38 return p
36 39
37 40 def jobctrl_prefilter_f(self,line):
38 41 if line.startswith('&'):
39 return 'jobctrl.job(%s)' % genutils.make_quoted_expr(line[1:])
42 return '_ip.startjob(%s)' % genutils.make_quoted_expr(line[1:])
40 43
41 44 raise IPython.ipapi.TryNext
42 45
43 import IPython.ipapi
44 IPython.ipapi.get().set_hook('input_prefilter', jobctrl_prefilter_f)
46 def install():
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