Please enable JavaScript to use RhodeCode Enterprise
##// END OF EJS Templates
gvaroquaux
- Mon, 11 Aug 2008 18:41:53
Show More
IPython/kernel/core/fd_redirector.py
0
+14
0
@@
-2,6
+2,8
b''
2
2
3
3
"""
4
4
Stdout/stderr redirector, at the OS level, using file descriptors.
5
6
This also works under windows.
5
7
"""
6
8
7
9
__docformat__ = "restructuredtext en"
@@
-31,8
+33,12
b' class FDRedirector(object):'
31
33
"""
32
34
self . fd = fd
33
35
self . started = False
36
self . piper = None
37
self . pipew = None
34
38
35
39
def start ( self ):
40
""" Setup the redirection.
41
"""
36
42
if not self . started :
37
43
self . oldhandle = os . dup ( self . fd )
38
44
self . piper , self . pipew = os . pipe ()
@@
-42,12
+48,17
b' class FDRedirector(object):'
42
48
self . started = True
43
49
44
50
def flush ( self ):
51
""" Flush the captured output, similar to the flush method of any
52
stream.
53
"""
45
54
if self . fd == STDOUT :
46
55
sys . stdout . flush ()
47
56
elif self . fd == STDERR :
48
57
sys . stderr . flush ()
49
58
50
59
def stop ( self ):
60
""" Unset the redirection and return the captured output.
61
"""
51
62
if self . started :
52
63
self . flush ()
53
64
os . dup2 ( self . oldhandle , self . fd )
@@
-62,6
+73,9
b' class FDRedirector(object):'
62
73
return ''
63
74
64
75
def getvalue ( self ):
76
""" Return the output captured since the last getvalue, or the
77
start of the redirection.
78
"""
65
79
output = self . stop ()
66
80
self . start ()
67
81
return output
IPython/kernel/core/file_like.py
0
+19
-2
@@
-25,25
+25,42
b' class FileLike(object):'
25
25
self . write = write_callback
26
26
27
27
def flush ( self ):
28
""" This method is there for compatibility with other file-like
29
objects.
30
"""
28
31
pass
29
32
30
33
def close ( self ):
34
""" This method is there for compatibility with other file-like
35
objects.
36
"""
31
37
pass
32
38
33
39
def writelines ( self , lines ):
34
for line in lines :
35
self . write ( line )
40
map ( self . write , lines )
36
41
37
42
def isatty ( self ):
43
""" This method is there for compatibility with other file-like
44
objects.
45
"""
38
46
return False
39
47
40
48
def getvalue ( self ):
49
""" This method is there for compatibility with other file-like
50
objects.
51
"""
41
52
return ''
42
53
43
54
def reset ( self ):
55
""" This method is there for compatibility with other file-like
56
objects.
57
"""
44
58
pass
45
59
46
60
def truncate ( self ):
61
""" This method is there for compatibility with other file-like
62
objects.
63
"""
47
64
pass
48
65
49
66
IPython/kernel/core/redirector_output_trap.py
0
+4
0
@@
-31,6
+31,10
b' class RedirectorOutputTrap(OutputTrap):'
31
31
# OutputTrap interface.
32
32
#------------------------------------------------------------------------
33
33
def __init__ ( self , out_callback , err_callback ):
34
"""
35
out_callback : callable called when there is output in the stdout
36
err_callback : callable called when there is output in the stderr
37
"""
34
38
# Callback invoked on write to stdout and stderr
35
39
self . out_callback = out_callback
36
40
self . err_callback = err_callback
IPython/kernel/core/sync_traceback_trap.py
0
+8
0
@@
-21,9
+21,17
b' from traceback_trap import TracebackTrap'
21
21
from IPython.ultraTB import ColorTB
22
22
23
23
class SyncTracebackTrap ( TracebackTrap ):
24
""" TracebackTrap that displays immediatly the traceback in addition
25
to capturing it. Useful in frontends, as without this traceback trap,
26
some tracebacks never get displayed.
27
"""
24
28
25
29
def __init__ ( self , sync_formatter = None , formatters = None ,
26
30
raiseException = True ):
31
"""
32
sync_formatter: Callable to display the traceback.
33
formatters: A list of formatters to apply.
34
"""
27
35
TracebackTrap . __init__ ( self , formatters = formatters )
28
36
if sync_formatter is None :
29
37
sync_formatter = ColorTB ( color_scheme = 'LightBG' )
Site-wide shortcuts
/
Use quick search box
g h
Goto home page
g g
Goto my private gists page
g G
Goto my public gists page
g 0-9
Goto bookmarked items from 0-9
n r
New repository page
n g
New gist page
Repositories
g s
Goto summary page
g c
Goto changelog page
g f
Goto files page
g F
Goto files page with file search activated
g p
Goto pull requests page
g o
Goto repository settings
g O
Goto repository access permissions settings
t s
Toggle sidebar on some pages