##// END OF EJS Templates
ipy_signals win32 version
vivainio -
Show More
@@ -9,18 +9,19 b' If _ip.options.verbose is true, show exit status if nonzero'
9
9
10 """
10 """
11
11
12 import signal,os
12 import signal,os,sys
13 import IPython.ipapi
13 import IPython.ipapi
14 import subprocess
14 import subprocess
15
15
16 ip = IPython.ipapi.get()
16 ip = IPython.ipapi.get()
17
17
18
18 def new_ipsystem_posix(cmd):
19 def new_ipsystem(cmd):
20 """ ctrl+c ignoring replacement for system() command in iplib.
19 """ ctrl+c ignoring replacement for system() command in iplib.
21
20
22 Ignore ctrl + c in IPython process during the command execution.
21 Ignore ctrl + c in IPython process during the command execution.
23 The subprocess will still get the ctrl + c signal.
22 The subprocess will still get the ctrl + c signal.
23
24 posix implementation
24 """
25 """
25
26
26 p = subprocess.Popen(cmd, shell = True)
27 p = subprocess.Popen(cmd, shell = True)
@@ -31,6 +32,21 b' def new_ipsystem(cmd):'
31 if status and ip.options.verbose:
32 if status and ip.options.verbose:
32 print "[exit status: %d]" % status
33 print "[exit status: %d]" % status
33
34
35 def new_ipsystem_win32(cmd):
36 """ ctrl+c ignoring replacement for system() command in iplib.
37
38 Ignore ctrl + c in IPython process during the command execution.
39 The subprocess will still get the ctrl + c signal.
40
41 win32 implementation
42 """
43 old_handler = signal.signal(signal.SIGINT, signal.SIG_IGN)
44 status = os.system(cmd)
45 signal.signal(signal.SIGINT, old_handler)
46 if status and ip.options.verbose:
47 print "[exit status: %d]" % status
48
49
34 def init():
50 def init():
35 o = ip.options
51 o = ip.options
36 try:
52 try:
@@ -39,7 +55,8 b' def init():'
39 o.allow_new_attr (True )
55 o.allow_new_attr (True )
40 o.verbose = 0
56 o.verbose = 0
41
57
42 ip.IP.system = new_ipsystem
58 ip.IP.system = (sys.platform == 'win32' and new_ipsystem_win32 or
59 new_ipsystem_posix)
43
60
44 init()
61 init()
45 No newline at end of file
62
General Comments 0
You need to be logged in to leave comments. Login now