##// END OF EJS Templates
Merge with upstream
Fernando Perez -
r1670:099aada6 merge
parent child Browse files
Show More
@@ -0,0 +1,26 b''
1 # encoding: utf-8
2
3 """This file contains unittests for the interpreter.py module."""
4
5 __docformat__ = "restructuredtext en"
6
7 #-----------------------------------------------------------------------------
8 # Copyright (C) 2008 The IPython Development Team
9 #
10 # Distributed under the terms of the BSD License. The full license is in
11 # the file COPYING, distributed as part of this software.
12 #-----------------------------------------------------------------------------
13
14 #-----------------------------------------------------------------------------
15 # Imports
16 #-----------------------------------------------------------------------------
17
18 from IPython.kernel.core.interpreter import Interpreter
19
20 def test_unicode():
21 """ Test unicode handling with the interpreter.
22 """
23 i = Interpreter()
24 i.execute_python(u'print "ù"')
25 i.execute_python('print "ù"')
26
1 NO CONTENT: new file 100644
NO CONTENT: new file 100644
@@ -0,0 +1,32 b''
1 # encoding: utf-8
2
3 """Tests for genutils.py"""
4
5 __docformat__ = "restructuredtext en"
6
7 #-----------------------------------------------------------------------------
8 # Copyright (C) 2008 The IPython Development Team
9 #
10 # Distributed under the terms of the BSD License. The full license is in
11 # the file COPYING, distributed as part of this software.
12 #-----------------------------------------------------------------------------
13
14 #-----------------------------------------------------------------------------
15 # Imports
16 #-----------------------------------------------------------------------------
17
18 from IPython import genutils
19
20
21 def test_get_home_dir():
22 """Make sure we can get the home directory."""
23 home_dir = genutils.get_home_dir()
24
25 def test_get_ipython_dir():
26 """Make sure we can get the ipython directory."""
27 ipdir = genutils.get_ipython_dir()
28
29 def test_get_security_dir():
30 """Make sure we can get the ipython/security directory."""
31 sdir = genutils.get_security_dir()
32 No newline at end of file
@@ -38,6 +38,8 b' ececute rad = pi/180.'
38 execute print '*** q is an alias for PhysicalQuantityInteractive'
38 execute print '*** q is an alias for PhysicalQuantityInteractive'
39 execute print '*** g = 9.8 m/s^2 has been defined'
39 execute print '*** g = 9.8 m/s^2 has been defined'
40 execute print '*** rad = pi/180 has been defined'
40 execute print '*** rad = pi/180 has been defined'
41 execute import ipy_constants as C
42 execute print '*** C is the physical constants module'
41
43
42 # Files to execute
44 # Files to execute
43 execfile
45 execfile
@@ -16,7 +16,9 b' __docformat__ = "restructuredtext en"'
16 #-------------------------------------------------------------------------------
16 #-------------------------------------------------------------------------------
17
17
18 import os
18 import os
19 from IPython.config.cutils import get_home_dir, get_ipython_dir
19 from os.path import join as pjoin
20
21 from IPython.genutils import get_home_dir, get_ipython_dir
20 from IPython.external.configobj import ConfigObj
22 from IPython.external.configobj import ConfigObj
21
23
22 # Traitlets config imports
24 # Traitlets config imports
@@ -53,7 +55,7 b' class ConfigObjManager(object):'
53
55
54 def write_default_config_file(self):
56 def write_default_config_file(self):
55 ipdir = get_ipython_dir()
57 ipdir = get_ipython_dir()
56 fname = ipdir + '/' + self.filename
58 fname = pjoin(ipdir, self.filename)
57 if not os.path.isfile(fname):
59 if not os.path.isfile(fname):
58 print "Writing the configuration file to: " + fname
60 print "Writing the configuration file to: " + fname
59 self.write_config_obj_to_file(fname)
61 self.write_config_obj_to_file(fname)
@@ -87,11 +89,11 b' class ConfigObjManager(object):'
87
89
88 # In ipythondir if it is set
90 # In ipythondir if it is set
89 if ipythondir is not None:
91 if ipythondir is not None:
90 trythis = ipythondir + '/' + filename
92 trythis = pjoin(ipythondir, filename)
91 if os.path.isfile(trythis):
93 if os.path.isfile(trythis):
92 return trythis
94 return trythis
93
95
94 trythis = get_ipython_dir() + '/' + filename
96 trythis = pjoin(get_ipython_dir(), filename)
95 if os.path.isfile(trythis):
97 if os.path.isfile(trythis):
96 return trythis
98 return trythis
97
99
@@ -22,71 +22,6 b' import sys'
22 # Normal code begins
22 # Normal code begins
23 #---------------------------------------------------------------------------
23 #---------------------------------------------------------------------------
24
24
25 class HomeDirError(Exception):
26 pass
27
28 def get_home_dir():
29 """Return the closest possible equivalent to a 'home' directory.
30
31 We first try $HOME. Absent that, on NT it's $HOMEDRIVE\$HOMEPATH.
32
33 Currently only Posix and NT are implemented, a HomeDirError exception is
34 raised for all other OSes. """
35
36 isdir = os.path.isdir
37 env = os.environ
38 try:
39 homedir = env['HOME']
40 if not isdir(homedir):
41 # in case a user stuck some string which does NOT resolve to a
42 # valid path, it's as good as if we hadn't foud it
43 raise KeyError
44 return homedir
45 except KeyError:
46 if os.name == 'posix':
47 raise HomeDirError,'undefined $HOME, IPython can not proceed.'
48 elif os.name == 'nt':
49 # For some strange reason, win9x returns 'nt' for os.name.
50 try:
51 homedir = os.path.join(env['HOMEDRIVE'],env['HOMEPATH'])
52 if not isdir(homedir):
53 homedir = os.path.join(env['USERPROFILE'])
54 if not isdir(homedir):
55 raise HomeDirError
56 return homedir
57 except:
58 try:
59 # Use the registry to get the 'My Documents' folder.
60 import _winreg as wreg
61 key = wreg.OpenKey(wreg.HKEY_CURRENT_USER,
62 "Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders")
63 homedir = wreg.QueryValueEx(key,'Personal')[0]
64 key.Close()
65 if not isdir(homedir):
66 e = ('Invalid "Personal" folder registry key '
67 'typically "My Documents".\n'
68 'Value: %s\n'
69 'This is not a valid directory on your system.' %
70 homedir)
71 raise HomeDirError(e)
72 return homedir
73 except HomeDirError:
74 raise
75 except:
76 return 'C:\\'
77 elif os.name == 'dos':
78 # Desperate, may do absurd things in classic MacOS. May work under DOS.
79 return 'C:\\'
80 else:
81 raise HomeDirError,'support for your operating system not implemented.'
82
83 def get_ipython_dir():
84 ipdir_def = '.ipython'
85 home_dir = get_home_dir()
86 ipdir = os.path.abspath(os.environ.get('IPYTHONDIR',
87 os.path.join(home_dir,ipdir_def)))
88 return ipdir
89
90 def import_item(key):
25 def import_item(key):
91 """
26 """
92 Import and return bar given the string foo.bar.
27 Import and return bar given the string foo.bar.
@@ -50,7 +50,6 b' import subprocess'
50 from subprocess import PIPE
50 from subprocess import PIPE
51 import sys
51 import sys
52 import os
52 import os
53 import time
54 import types
53 import types
55
54
56 try:
55 try:
@@ -69,8 +68,16 b' except ImportError:'
69
68
70 mswindows = (sys.platform == "win32")
69 mswindows = (sys.platform == "win32")
71
70
71 skip = False
72
72 if mswindows:
73 if mswindows:
73 import winprocess
74 import platform
75 if platform.uname()[3] == '' or platform.uname()[3] > '6.0.6000':
76 # Killable process does not work under vista when starting for
77 # something else than cmd.
78 skip = True
79 else:
80 import winprocess
74 else:
81 else:
75 import signal
82 import signal
76
83
@@ -78,7 +85,11 b' if not mswindows:'
78 def DoNothing(*args):
85 def DoNothing(*args):
79 pass
86 pass
80
87
81 class Popen(subprocess.Popen):
88
89 if skip:
90 Popen = subprocess.Popen
91 else:
92 class Popen(subprocess.Popen):
82 if not mswindows:
93 if not mswindows:
83 # Override __init__ to set a preexec_fn
94 # Override __init__ to set a preexec_fn
84 def __init__(self, *args, **kwargs):
95 def __init__(self, *args, **kwargs):
@@ -50,7 +50,7 b' class PipedProcess(Thread):'
50 """
50 """
51 env = os.environ
51 env = os.environ
52 env['TERM'] = 'xterm'
52 env['TERM'] = 'xterm'
53 process = Popen((self.command_string + ' 2>&1', ), shell=True,
53 process = Popen(self.command_string + ' 2>&1', shell=True,
54 env=env,
54 env=env,
55 universal_newlines=True,
55 universal_newlines=True,
56 stdout=PIPE, stdin=PIPE, )
56 stdout=PIPE, stdin=PIPE, )
@@ -20,6 +20,8 b' import re'
20
20
21 import IPython
21 import IPython
22 import sys
22 import sys
23 import codeop
24 import traceback
23
25
24 from frontendbase import FrontEndBase
26 from frontendbase import FrontEndBase
25 from IPython.kernel.core.interpreter import Interpreter
27 from IPython.kernel.core.interpreter import Interpreter
@@ -76,6 +78,11 b' class LineFrontEndBase(FrontEndBase):'
76
78
77 if banner is not None:
79 if banner is not None:
78 self.banner = banner
80 self.banner = banner
81
82 def start(self):
83 """ Put the frontend in a state where it is ready for user
84 interaction.
85 """
79 if self.banner is not None:
86 if self.banner is not None:
80 self.write(self.banner, refresh=False)
87 self.write(self.banner, refresh=False)
81
88
@@ -141,9 +148,18 b' class LineFrontEndBase(FrontEndBase):'
141 and not re.findall(r"\n[\t ]*\n[\t ]*$", string)):
148 and not re.findall(r"\n[\t ]*\n[\t ]*$", string)):
142 return False
149 return False
143 else:
150 else:
144 # Add line returns here, to make sure that the statement is
151 self.capture_output()
145 # complete.
152 try:
146 return FrontEndBase.is_complete(self, string.rstrip() + '\n\n')
153 # Add line returns here, to make sure that the statement is
154 # complete.
155 is_complete = codeop.compile_command(string.rstrip() + '\n\n',
156 "<string>", "exec")
157 self.release_output()
158 except Exception, e:
159 # XXX: Hack: return True so that the
160 # code gets executed and the error captured.
161 is_complete = True
162 return is_complete
147
163
148
164
149 def write(self, string, refresh=True):
165 def write(self, string, refresh=True):
@@ -181,7 +197,7 b' class LineFrontEndBase(FrontEndBase):'
181 #--------------------------------------------------------------------------
197 #--------------------------------------------------------------------------
182
198
183 def prefilter_input(self, string):
199 def prefilter_input(self, string):
184 """ Priflter the input to turn it in valid python.
200 """ Prefilter the input to turn it in valid python.
185 """
201 """
186 string = string.replace('\r\n', '\n')
202 string = string.replace('\r\n', '\n')
187 string = string.replace('\t', 4*' ')
203 string = string.replace('\t', 4*' ')
@@ -210,9 +226,12 b' class LineFrontEndBase(FrontEndBase):'
210 line = self.input_buffer
226 line = self.input_buffer
211 new_line, completions = self.complete(line)
227 new_line, completions = self.complete(line)
212 if len(completions)>1:
228 if len(completions)>1:
213 self.write_completion(completions)
229 self.write_completion(completions, new_line=new_line)
214 self.input_buffer = new_line
230 elif not line == new_line:
231 self.input_buffer = new_line
215 if self.debug:
232 if self.debug:
233 print >>sys.__stdout__, 'line', line
234 print >>sys.__stdout__, 'new_line', new_line
216 print >>sys.__stdout__, completions
235 print >>sys.__stdout__, completions
217
236
218
237
@@ -222,10 +241,15 b' class LineFrontEndBase(FrontEndBase):'
222 return 80
241 return 80
223
242
224
243
225 def write_completion(self, possibilities):
244 def write_completion(self, possibilities, new_line=None):
226 """ Write the list of possible completions.
245 """ Write the list of possible completions.
246
247 new_line is the completed input line that should be displayed
248 after the completion are writen. If None, the input_buffer
249 before the completion is used.
227 """
250 """
228 current_buffer = self.input_buffer
251 if new_line is None:
252 new_line = self.input_buffer
229
253
230 self.write('\n')
254 self.write('\n')
231 max_len = len(max(possibilities, key=len)) + 1
255 max_len = len(max(possibilities, key=len)) + 1
@@ -246,7 +270,7 b' class LineFrontEndBase(FrontEndBase):'
246 self.write(''.join(buf))
270 self.write(''.join(buf))
247 self.new_prompt(self.input_prompt_template.substitute(
271 self.new_prompt(self.input_prompt_template.substitute(
248 number=self.last_result['number'] + 1))
272 number=self.last_result['number'] + 1))
249 self.input_buffer = current_buffer
273 self.input_buffer = new_line
250
274
251
275
252 def new_prompt(self, prompt):
276 def new_prompt(self, prompt):
@@ -275,6 +299,8 b' class LineFrontEndBase(FrontEndBase):'
275 else:
299 else:
276 self.input_buffer += self._get_indent_string(
300 self.input_buffer += self._get_indent_string(
277 current_buffer[:-1])
301 current_buffer[:-1])
302 if len(current_buffer.split('\n')) == 2:
303 self.input_buffer += '\t\t'
278 if current_buffer[:-1].split('\n')[-1].rstrip().endswith(':'):
304 if current_buffer[:-1].split('\n')[-1].rstrip().endswith(':'):
279 self.input_buffer += '\t'
305 self.input_buffer += '\t'
280
306
@@ -24,6 +24,7 b' __docformat__ = "restructuredtext en"'
24 import sys
24 import sys
25
25
26 from linefrontendbase import LineFrontEndBase, common_prefix
26 from linefrontendbase import LineFrontEndBase, common_prefix
27 from frontendbase import FrontEndBase
27
28
28 from IPython.ipmaker import make_IPython
29 from IPython.ipmaker import make_IPython
29 from IPython.ipapi import IPApi
30 from IPython.ipapi import IPApi
@@ -34,6 +35,7 b' from IPython.kernel.core.sync_traceback_trap import SyncTracebackTrap'
34 from IPython.genutils import Term
35 from IPython.genutils import Term
35 import pydoc
36 import pydoc
36 import os
37 import os
38 import sys
37
39
38
40
39 def mk_system_call(system_call_function, command):
41 def mk_system_call(system_call_function, command):
@@ -57,6 +59,8 b' class PrefilterFrontEnd(LineFrontEndBase):'
57 to execute the statements and the ipython0 used for code
59 to execute the statements and the ipython0 used for code
58 completion...
60 completion...
59 """
61 """
62
63 debug = False
60
64
61 def __init__(self, ipython0=None, *args, **kwargs):
65 def __init__(self, ipython0=None, *args, **kwargs):
62 """ Parameters:
66 """ Parameters:
@@ -65,12 +69,24 b' class PrefilterFrontEnd(LineFrontEndBase):'
65 ipython0: an optional ipython0 instance to use for command
69 ipython0: an optional ipython0 instance to use for command
66 prefiltering and completion.
70 prefiltering and completion.
67 """
71 """
72 LineFrontEndBase.__init__(self, *args, **kwargs)
73 self.shell.output_trap = RedirectorOutputTrap(
74 out_callback=self.write,
75 err_callback=self.write,
76 )
77 self.shell.traceback_trap = SyncTracebackTrap(
78 formatters=self.shell.traceback_trap.formatters,
79 )
80
81 # Start the ipython0 instance:
68 self.save_output_hooks()
82 self.save_output_hooks()
69 if ipython0 is None:
83 if ipython0 is None:
70 # Instanciate an IPython0 interpreter to be able to use the
84 # Instanciate an IPython0 interpreter to be able to use the
71 # prefiltering.
85 # prefiltering.
72 # XXX: argv=[] is a bit bold.
86 # XXX: argv=[] is a bit bold.
73 ipython0 = make_IPython(argv=[])
87 ipython0 = make_IPython(argv=[],
88 user_ns=self.shell.user_ns,
89 user_global_ns=self.shell.user_global_ns)
74 self.ipython0 = ipython0
90 self.ipython0 = ipython0
75 # Set the pager:
91 # Set the pager:
76 self.ipython0.set_hook('show_in_pager',
92 self.ipython0.set_hook('show_in_pager',
@@ -86,24 +102,13 b' class PrefilterFrontEnd(LineFrontEndBase):'
86 'ls -CF')
102 'ls -CF')
87 # And now clean up the mess created by ipython0
103 # And now clean up the mess created by ipython0
88 self.release_output()
104 self.release_output()
105
106
89 if not 'banner' in kwargs and self.banner is None:
107 if not 'banner' in kwargs and self.banner is None:
90 kwargs['banner'] = self.ipython0.BANNER + """
108 self.banner = self.ipython0.BANNER + """
91 This is the wx frontend, by Gael Varoquaux. This is EXPERIMENTAL code."""
109 This is the wx frontend, by Gael Varoquaux. This is EXPERIMENTAL code."""
92
110
93 LineFrontEndBase.__init__(self, *args, **kwargs)
111 self.start()
94 # XXX: Hack: mix the two namespaces
95 self.shell.user_ns.update(self.ipython0.user_ns)
96 self.ipython0.user_ns = self.shell.user_ns
97 self.shell.user_global_ns.update(self.ipython0.user_global_ns)
98 self.ipython0.user_global_ns = self.shell.user_global_ns
99
100 self.shell.output_trap = RedirectorOutputTrap(
101 out_callback=self.write,
102 err_callback=self.write,
103 )
104 self.shell.traceback_trap = SyncTracebackTrap(
105 formatters=self.shell.traceback_trap.formatters,
106 )
107
112
108 #--------------------------------------------------------------------------
113 #--------------------------------------------------------------------------
109 # FrontEndBase interface
114 # FrontEndBase interface
@@ -113,7 +118,7 b' This is the wx frontend, by Gael Varoquaux. This is EXPERIMENTAL code."""'
113 """ Use ipython0 to capture the last traceback and display it.
118 """ Use ipython0 to capture the last traceback and display it.
114 """
119 """
115 self.capture_output()
120 self.capture_output()
116 self.ipython0.showtraceback()
121 self.ipython0.showtraceback(tb_offset=-1)
117 self.release_output()
122 self.release_output()
118
123
119
124
@@ -164,6 +169,8 b' This is the wx frontend, by Gael Varoquaux. This is EXPERIMENTAL code."""'
164
169
165
170
166 def complete(self, line):
171 def complete(self, line):
172 # FIXME: This should be factored out in the linefrontendbase
173 # method.
167 word = line.split('\n')[-1].split(' ')[-1]
174 word = line.split('\n')[-1].split(' ')[-1]
168 completions = self.ipython0.complete(word)
175 completions = self.ipython0.complete(word)
169 # FIXME: The proper sort should be done in the complete method.
176 # FIXME: The proper sort should be done in the complete method.
@@ -25,6 +25,8 b' except ImportError:'
25 import nose
25 import nose
26 raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap")
26 raise nose.SkipTest("This test requires zope.interface, Twisted and Foolscap")
27
27
28 from IPython.testing.decorators import skip
29
28 class FrontEndCallbackChecker(AsyncFrontEndBase):
30 class FrontEndCallbackChecker(AsyncFrontEndBase):
29 """FrontEndBase subclass for checking callbacks"""
31 """FrontEndBase subclass for checking callbacks"""
30 def __init__(self, engine=None, history=None):
32 def __init__(self, engine=None, history=None):
@@ -56,12 +58,10 b' class TestAsyncFrontendBase(unittest.TestCase):'
56
58
57 self.fb = FrontEndCallbackChecker(engine=EngineService())
59 self.fb = FrontEndCallbackChecker(engine=EngineService())
58
60
59
60 def test_implements_IFrontEnd(self):
61 def test_implements_IFrontEnd(self):
61 assert(frontendbase.IFrontEnd.implementedBy(
62 assert(frontendbase.IFrontEnd.implementedBy(
62 AsyncFrontEndBase))
63 AsyncFrontEndBase))
63
64
64
65 def test_is_complete_returns_False_for_incomplete_block(self):
65 def test_is_complete_returns_False_for_incomplete_block(self):
66 """"""
66 """"""
67
67
@@ -80,7 +80,6 b' class TestAsyncFrontendBase(unittest.TestCase):'
80
80
81 assert(self.fb.is_complete(block))
81 assert(self.fb.is_complete(block))
82
82
83
84 def test_blockID_added_to_result(self):
83 def test_blockID_added_to_result(self):
85 block = """3+3"""
84 block = """3+3"""
86
85
@@ -113,12 +112,11 b' class TestAsyncFrontendBase(unittest.TestCase):'
113 d = self.fb.execute("10+10")
112 d = self.fb.execute("10+10")
114 d.addCallback(self.checkCallbacks)
113 d.addCallback(self.checkCallbacks)
115
114
116
117 def checkCallbacks(self, result):
115 def checkCallbacks(self, result):
118 assert(self.fb.updateCalled)
116 assert(self.fb.updateCalled)
119 assert(self.fb.renderResultCalled)
117 assert(self.fb.renderResultCalled)
120
118
121
119 @skip("This test fails and lead to an unhandled error in a Deferred.")
122 def test_error_callback_added_to_execute(self):
120 def test_error_callback_added_to_execute(self):
123 """test that render_error called on execution error"""
121 """test that render_error called on execution error"""
124
122
@@ -19,6 +19,7 b' import sys'
19 from IPython.frontend._process import PipedProcess
19 from IPython.frontend._process import PipedProcess
20 from IPython.testing import decorators as testdec
20 from IPython.testing import decorators as testdec
21
21
22
22 def test_capture_out():
23 def test_capture_out():
23 """ A simple test to see if we can execute a process and get the output.
24 """ A simple test to see if we can execute a process and get the output.
24 """
25 """
@@ -29,8 +30,7 b' def test_capture_out():'
29 result = s.getvalue().rstrip()
30 result = s.getvalue().rstrip()
30 assert result == '1'
31 assert result == '1'
31
32
32 # FIXME
33
33 @testdec.skip("This doesn't work under Windows")
34 def test_io():
34 def test_io():
35 """ Checks that we can send characters on stdin to the process.
35 """ Checks that we can send characters on stdin to the process.
36 """
36 """
@@ -23,6 +23,7 b' import wx'
23 import wx.stc as stc
23 import wx.stc as stc
24
24
25 from wx.py import editwindow
25 from wx.py import editwindow
26 import time
26 import sys
27 import sys
27 LINESEP = '\n'
28 LINESEP = '\n'
28 if sys.platform == 'win32':
29 if sys.platform == 'win32':
@@ -115,12 +116,15 b' class ConsoleWidget(editwindow.EditWindow):'
115 # The color of the carret (call _apply_style() after setting)
116 # The color of the carret (call _apply_style() after setting)
116 carret_color = 'BLACK'
117 carret_color = 'BLACK'
117
118
119 # Store the last time a refresh was done
120 _last_refresh_time = 0
121
118 #--------------------------------------------------------------------------
122 #--------------------------------------------------------------------------
119 # Public API
123 # Public API
120 #--------------------------------------------------------------------------
124 #--------------------------------------------------------------------------
121
125
122 def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition,
126 def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition,
123 size=wx.DefaultSize, style=0, ):
127 size=wx.DefaultSize, style=wx.WANTS_CHARS, ):
124 editwindow.EditWindow.__init__(self, parent, id, pos, size, style)
128 editwindow.EditWindow.__init__(self, parent, id, pos, size, style)
125 self._configure_scintilla()
129 self._configure_scintilla()
126
130
@@ -168,9 +172,14 b' class ConsoleWidget(editwindow.EditWindow):'
168
172
169 self.GotoPos(self.GetLength())
173 self.GotoPos(self.GetLength())
170 if refresh:
174 if refresh:
171 # Maybe this is faster than wx.Yield()
175 current_time = time.time()
172 self.ProcessEvent(wx.PaintEvent())
176 if current_time - self._last_refresh_time > 0.03:
173 #wx.Yield()
177 if sys.platform == 'win32':
178 wx.SafeYield()
179 else:
180 wx.Yield()
181 # self.ProcessEvent(wx.PaintEvent())
182 self._last_refresh_time = current_time
174
183
175
184
176 def new_prompt(self, prompt):
185 def new_prompt(self, prompt):
@@ -183,7 +192,6 b' class ConsoleWidget(editwindow.EditWindow):'
183 # now we update our cursor giving end of prompt
192 # now we update our cursor giving end of prompt
184 self.current_prompt_pos = self.GetLength()
193 self.current_prompt_pos = self.GetLength()
185 self.current_prompt_line = self.GetCurrentLine()
194 self.current_prompt_line = self.GetCurrentLine()
186 wx.Yield()
187 self.EnsureCaretVisible()
195 self.EnsureCaretVisible()
188
196
189
197
@@ -128,6 +128,7 b' class WxController(ConsoleWidget, PrefilterFrontEnd):'
128 # while it is being swapped
128 # while it is being swapped
129 _out_buffer_lock = Lock()
129 _out_buffer_lock = Lock()
130
130
131 # The different line markers used to higlight the prompts.
131 _markers = dict()
132 _markers = dict()
132
133
133 #--------------------------------------------------------------------------
134 #--------------------------------------------------------------------------
@@ -135,12 +136,16 b' class WxController(ConsoleWidget, PrefilterFrontEnd):'
135 #--------------------------------------------------------------------------
136 #--------------------------------------------------------------------------
136
137
137 def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition,
138 def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition,
138 size=wx.DefaultSize, style=wx.CLIP_CHILDREN,
139 size=wx.DefaultSize,
140 style=wx.CLIP_CHILDREN|wx.WANTS_CHARS,
139 *args, **kwds):
141 *args, **kwds):
140 """ Create Shell instance.
142 """ Create Shell instance.
141 """
143 """
142 ConsoleWidget.__init__(self, parent, id, pos, size, style)
144 ConsoleWidget.__init__(self, parent, id, pos, size, style)
143 PrefilterFrontEnd.__init__(self, **kwds)
145 PrefilterFrontEnd.__init__(self, **kwds)
146
147 # Stick in our own raw_input:
148 self.ipython0.raw_input = self.raw_input
144
149
145 # Marker for complete buffer.
150 # Marker for complete buffer.
146 self.MarkerDefine(_COMPLETE_BUFFER_MARKER, stc.STC_MARK_BACKGROUND,
151 self.MarkerDefine(_COMPLETE_BUFFER_MARKER, stc.STC_MARK_BACKGROUND,
@@ -164,9 +169,11 b' class WxController(ConsoleWidget, PrefilterFrontEnd):'
164 # Inject self in namespace, for debug
169 # Inject self in namespace, for debug
165 if self.debug:
170 if self.debug:
166 self.shell.user_ns['self'] = self
171 self.shell.user_ns['self'] = self
172 # Inject our own raw_input in namespace
173 self.shell.user_ns['raw_input'] = self.raw_input
167
174
168
175
169 def raw_input(self, prompt):
176 def raw_input(self, prompt=''):
170 """ A replacement from python's raw_input.
177 """ A replacement from python's raw_input.
171 """
178 """
172 self.new_prompt(prompt)
179 self.new_prompt(prompt)
@@ -174,15 +181,13 b' class WxController(ConsoleWidget, PrefilterFrontEnd):'
174 if hasattr(self, '_cursor'):
181 if hasattr(self, '_cursor'):
175 del self._cursor
182 del self._cursor
176 self.SetCursor(wx.StockCursor(wx.CURSOR_CROSS))
183 self.SetCursor(wx.StockCursor(wx.CURSOR_CROSS))
177 self.waiting = True
178 self.__old_on_enter = self._on_enter
184 self.__old_on_enter = self._on_enter
185 event_loop = wx.EventLoop()
179 def my_on_enter():
186 def my_on_enter():
180 self.waiting = False
187 event_loop.Exit()
181 self._on_enter = my_on_enter
188 self._on_enter = my_on_enter
182 # XXX: Busy waiting, ugly.
189 # XXX: Running a separate event_loop. Ugly.
183 while self.waiting:
190 event_loop.Run()
184 wx.Yield()
185 sleep(0.1)
186 self._on_enter = self.__old_on_enter
191 self._on_enter = self.__old_on_enter
187 self._input_state = 'buffering'
192 self._input_state = 'buffering'
188 self._cursor = wx.BusyCursor()
193 self._cursor = wx.BusyCursor()
@@ -191,16 +196,18 b' class WxController(ConsoleWidget, PrefilterFrontEnd):'
191
196
192 def system_call(self, command_string):
197 def system_call(self, command_string):
193 self._input_state = 'subprocess'
198 self._input_state = 'subprocess'
199 event_loop = wx.EventLoop()
200 def _end_system_call():
201 self._input_state = 'buffering'
202 self._running_process = False
203 event_loop.Exit()
204
194 self._running_process = PipedProcess(command_string,
205 self._running_process = PipedProcess(command_string,
195 out_callback=self.buffered_write,
206 out_callback=self.buffered_write,
196 end_callback = self._end_system_call)
207 end_callback = _end_system_call)
197 self._running_process.start()
208 self._running_process.start()
198 # XXX: another one of these polling loops to have a blocking
209 # XXX: Running a separate event_loop. Ugly.
199 # call
210 event_loop.Run()
200 wx.Yield()
201 while self._running_process:
202 wx.Yield()
203 sleep(0.1)
204 # Be sure to flush the buffer.
211 # Be sure to flush the buffer.
205 self._buffer_flush(event=None)
212 self._buffer_flush(event=None)
206
213
@@ -226,8 +233,9 b' class WxController(ConsoleWidget, PrefilterFrontEnd):'
226 for name in symbol_string.split('.')[1:] + ['__doc__']:
233 for name in symbol_string.split('.')[1:] + ['__doc__']:
227 symbol = getattr(symbol, name)
234 symbol = getattr(symbol, name)
228 self.AutoCompCancel()
235 self.AutoCompCancel()
229 wx.Yield()
236 # Check that the symbol can indeed be converted to a string:
230 self.CallTipShow(self.GetCurrentPos(), symbol)
237 symbol += ''
238 wx.CallAfter(self.CallTipShow, self.GetCurrentPos(), symbol)
231 except:
239 except:
232 # The retrieve symbol couldn't be converted to a string
240 # The retrieve symbol couldn't be converted to a string
233 pass
241 pass
@@ -238,9 +246,9 b' class WxController(ConsoleWidget, PrefilterFrontEnd):'
238 true, open the menu.
246 true, open the menu.
239 """
247 """
240 if self.debug:
248 if self.debug:
241 print >>sys.__stdout__, "_popup_completion",
249 print >>sys.__stdout__, "_popup_completion"
242 line = self.input_buffer
250 line = self.input_buffer
243 if (self.AutoCompActive() and not line[-1] == '.') \
251 if (self.AutoCompActive() and line and not line[-1] == '.') \
244 or create==True:
252 or create==True:
245 suggestion, completions = self.complete(line)
253 suggestion, completions = self.complete(line)
246 offset=0
254 offset=0
@@ -284,19 +292,21 b' class WxController(ConsoleWidget, PrefilterFrontEnd):'
284 if i in self._markers:
292 if i in self._markers:
285 self.MarkerDeleteHandle(self._markers[i])
293 self.MarkerDeleteHandle(self._markers[i])
286 self._markers[i] = self.MarkerAdd(i, _COMPLETE_BUFFER_MARKER)
294 self._markers[i] = self.MarkerAdd(i, _COMPLETE_BUFFER_MARKER)
287 # Update the display:
295 # Use a callafter to update the display robustly under windows
288 wx.Yield()
296 def callback():
289 self.GotoPos(self.GetLength())
297 self.GotoPos(self.GetLength())
290 PrefilterFrontEnd.execute(self, python_string, raw_string=raw_string)
298 PrefilterFrontEnd.execute(self, python_string,
299 raw_string=raw_string)
300 wx.CallAfter(callback)
291
301
292 def save_output_hooks(self):
302 def save_output_hooks(self):
293 self.__old_raw_input = __builtin__.raw_input
303 self.__old_raw_input = __builtin__.raw_input
294 PrefilterFrontEnd.save_output_hooks(self)
304 PrefilterFrontEnd.save_output_hooks(self)
295
305
296 def capture_output(self):
306 def capture_output(self):
297 __builtin__.raw_input = self.raw_input
298 self.SetLexer(stc.STC_LEX_NULL)
307 self.SetLexer(stc.STC_LEX_NULL)
299 PrefilterFrontEnd.capture_output(self)
308 PrefilterFrontEnd.capture_output(self)
309 __builtin__.raw_input = self.raw_input
300
310
301
311
302 def release_output(self):
312 def release_output(self):
@@ -316,12 +326,24 b' class WxController(ConsoleWidget, PrefilterFrontEnd):'
316 def show_traceback(self):
326 def show_traceback(self):
317 start_line = self.GetCurrentLine()
327 start_line = self.GetCurrentLine()
318 PrefilterFrontEnd.show_traceback(self)
328 PrefilterFrontEnd.show_traceback(self)
319 wx.Yield()
329 self.ProcessEvent(wx.PaintEvent())
330 #wx.Yield()
320 for i in range(start_line, self.GetCurrentLine()):
331 for i in range(start_line, self.GetCurrentLine()):
321 self._markers[i] = self.MarkerAdd(i, _ERROR_MARKER)
332 self._markers[i] = self.MarkerAdd(i, _ERROR_MARKER)
322
333
323
334
324 #--------------------------------------------------------------------------
335 #--------------------------------------------------------------------------
336 # FrontEndBase interface
337 #--------------------------------------------------------------------------
338
339 def render_error(self, e):
340 start_line = self.GetCurrentLine()
341 self.write('\n' + e + '\n')
342 for i in range(start_line, self.GetCurrentLine()):
343 self._markers[i] = self.MarkerAdd(i, _ERROR_MARKER)
344
345
346 #--------------------------------------------------------------------------
325 # ConsoleWidget interface
347 # ConsoleWidget interface
326 #--------------------------------------------------------------------------
348 #--------------------------------------------------------------------------
327
349
@@ -351,7 +373,8 b' class WxController(ConsoleWidget, PrefilterFrontEnd):'
351 if self._input_state == 'subprocess':
373 if self._input_state == 'subprocess':
352 if self.debug:
374 if self.debug:
353 print >>sys.__stderr__, 'Killing running process'
375 print >>sys.__stderr__, 'Killing running process'
354 self._running_process.process.kill()
376 if hasattr(self._running_process, 'process'):
377 self._running_process.process.kill()
355 elif self._input_state == 'buffering':
378 elif self._input_state == 'buffering':
356 if self.debug:
379 if self.debug:
357 print >>sys.__stderr__, 'Raising KeyboardInterrupt'
380 print >>sys.__stderr__, 'Raising KeyboardInterrupt'
@@ -376,7 +399,7 b' class WxController(ConsoleWidget, PrefilterFrontEnd):'
376 char = '\04'
399 char = '\04'
377 self._running_process.process.stdin.write(char)
400 self._running_process.process.stdin.write(char)
378 self._running_process.process.stdin.flush()
401 self._running_process.process.stdin.flush()
379 elif event.KeyCode in (ord('('), 57):
402 elif event.KeyCode in (ord('('), 57, 53):
380 # Calltips
403 # Calltips
381 event.Skip()
404 event.Skip()
382 self.do_calltip()
405 self.do_calltip()
@@ -410,8 +433,8 b' class WxController(ConsoleWidget, PrefilterFrontEnd):'
410 self.input_buffer = new_buffer
433 self.input_buffer = new_buffer
411 # Tab-completion
434 # Tab-completion
412 elif event.KeyCode == ord('\t'):
435 elif event.KeyCode == ord('\t'):
413 last_line = self.input_buffer.split('\n')[-1]
436 current_line, current_line_number = self.CurLine
414 if not re.match(r'^\s*$', last_line):
437 if not re.match(r'^\s*$', current_line):
415 self.complete_current_input()
438 self.complete_current_input()
416 if self.AutoCompActive():
439 if self.AutoCompActive():
417 wx.CallAfter(self._popup_completion, create=True)
440 wx.CallAfter(self._popup_completion, create=True)
@@ -427,7 +450,7 b' class WxController(ConsoleWidget, PrefilterFrontEnd):'
427 if event.KeyCode in (59, ord('.')):
450 if event.KeyCode in (59, ord('.')):
428 # Intercepting '.'
451 # Intercepting '.'
429 event.Skip()
452 event.Skip()
430 self._popup_completion(create=True)
453 wx.CallAfter(self._popup_completion, create=True)
431 else:
454 else:
432 ConsoleWidget._on_key_up(self, event, skip=skip)
455 ConsoleWidget._on_key_up(self, event, skip=skip)
433
456
@@ -456,13 +479,6 b' class WxController(ConsoleWidget, PrefilterFrontEnd):'
456 # Private API
479 # Private API
457 #--------------------------------------------------------------------------
480 #--------------------------------------------------------------------------
458
481
459 def _end_system_call(self):
460 """ Called at the end of a system call.
461 """
462 self._input_state = 'buffering'
463 self._running_process = False
464
465
466 def _buffer_flush(self, event):
482 def _buffer_flush(self, event):
467 """ Called by the timer to flush the write buffer.
483 """ Called by the timer to flush the write buffer.
468
484
@@ -979,6 +979,38 b' def get_home_dir():'
979 else:
979 else:
980 raise HomeDirError,'support for your operating system not implemented.'
980 raise HomeDirError,'support for your operating system not implemented.'
981
981
982
983 def get_ipython_dir():
984 """Get the IPython directory for this platform and user.
985
986 This uses the logic in `get_home_dir` to find the home directory
987 and the adds either .ipython or _ipython to the end of the path.
988 """
989 if os.name == 'posix':
990 ipdir_def = '.ipython'
991 else:
992 ipdir_def = '_ipython'
993 home_dir = get_home_dir()
994 ipdir = os.path.abspath(os.environ.get('IPYTHONDIR',
995 os.path.join(home_dir,ipdir_def)))
996 return ipdir
997
998 def get_security_dir():
999 """Get the IPython security directory.
1000
1001 This directory is the default location for all security related files,
1002 including SSL/TLS certificates and FURL files.
1003
1004 If the directory does not exist, it is created with 0700 permissions.
1005 If it exists, permissions are set to 0700.
1006 """
1007 security_dir = os.path.join(get_ipython_dir(), 'security')
1008 if not os.path.isdir(security_dir):
1009 os.mkdir(security_dir, 0700)
1010 else:
1011 os.chmod(security_dir, 0700)
1012 return security_dir
1013
982 #****************************************************************************
1014 #****************************************************************************
983 # strings and text
1015 # strings and text
984
1016
@@ -15,17 +15,15 b' __docformat__ = "restructuredtext en"'
15 # Imports
15 # Imports
16 #-------------------------------------------------------------------------------
16 #-------------------------------------------------------------------------------
17
17
18 from os.path import join as pjoin
19
18 from IPython.external.configobj import ConfigObj
20 from IPython.external.configobj import ConfigObj
19 from IPython.config.api import ConfigObjManager
21 from IPython.config.api import ConfigObjManager
20 from IPython.config.cutils import get_ipython_dir
22 from IPython.genutils import get_ipython_dir, get_security_dir
21
23
22 default_kernel_config = ConfigObj()
24 default_kernel_config = ConfigObj()
23
25
24 try:
26 security_dir = get_security_dir()
25 ipython_dir = get_ipython_dir() + '/'
26 except:
27 # This will defaults to the cwd
28 ipython_dir = ''
29
27
30 #-------------------------------------------------------------------------------
28 #-------------------------------------------------------------------------------
31 # Engine Configuration
29 # Engine Configuration
@@ -33,7 +31,7 b' except:'
33
31
34 engine_config = dict(
32 engine_config = dict(
35 logfile = '', # Empty means log to stdout
33 logfile = '', # Empty means log to stdout
36 furl_file = ipython_dir + 'ipcontroller-engine.furl'
34 furl_file = pjoin(security_dir, 'ipcontroller-engine.furl')
37 )
35 )
38
36
39 #-------------------------------------------------------------------------------
37 #-------------------------------------------------------------------------------
@@ -69,10 +67,10 b' controller_config = dict('
69 port = 0, # 0 means pick a port for me
67 port = 0, # 0 means pick a port for me
70 location = '', # Empty string means try to set automatically
68 location = '', # Empty string means try to set automatically
71 secure = True,
69 secure = True,
72 cert_file = ipython_dir + 'ipcontroller-engine.pem',
70 cert_file = pjoin(security_dir, 'ipcontroller-engine.pem'),
73 ),
71 ),
74 engine_fc_interface = 'IPython.kernel.enginefc.IFCControllerBase',
72 engine_fc_interface = 'IPython.kernel.enginefc.IFCControllerBase',
75 engine_furl_file = ipython_dir + 'ipcontroller-engine.furl',
73 engine_furl_file = pjoin(security_dir, 'ipcontroller-engine.furl'),
76
74
77 controller_interfaces = dict(
75 controller_interfaces = dict(
78 # multiengine = dict(
76 # multiengine = dict(
@@ -83,12 +81,12 b' controller_config = dict('
83 task = dict(
81 task = dict(
84 controller_interface = 'IPython.kernel.task.ITaskController',
82 controller_interface = 'IPython.kernel.task.ITaskController',
85 fc_interface = 'IPython.kernel.taskfc.IFCTaskController',
83 fc_interface = 'IPython.kernel.taskfc.IFCTaskController',
86 furl_file = ipython_dir + 'ipcontroller-tc.furl'
84 furl_file = pjoin(security_dir, 'ipcontroller-tc.furl')
87 ),
85 ),
88 multiengine = dict(
86 multiengine = dict(
89 controller_interface = 'IPython.kernel.multiengine.IMultiEngine',
87 controller_interface = 'IPython.kernel.multiengine.IMultiEngine',
90 fc_interface = 'IPython.kernel.multienginefc.IFCSynchronousMultiEngine',
88 fc_interface = 'IPython.kernel.multienginefc.IFCSynchronousMultiEngine',
91 furl_file = ipython_dir + 'ipcontroller-mec.furl'
89 furl_file = pjoin(security_dir, 'ipcontroller-mec.furl')
92 )
90 )
93 ),
91 ),
94
92
@@ -97,7 +95,7 b' controller_config = dict('
97 port = 0, # 0 means pick a port for me
95 port = 0, # 0 means pick a port for me
98 location = '', # Empty string means try to set automatically
96 location = '', # Empty string means try to set automatically
99 secure = True,
97 secure = True,
100 cert_file = ipython_dir + 'ipcontroller-client.pem'
98 cert_file = pjoin(security_dir, 'ipcontroller-client.pem')
101 )
99 )
102 )
100 )
103
101
@@ -108,10 +106,10 b' controller_config = dict('
108 client_config = dict(
106 client_config = dict(
109 client_interfaces = dict(
107 client_interfaces = dict(
110 task = dict(
108 task = dict(
111 furl_file = ipython_dir + 'ipcontroller-tc.furl'
109 furl_file = pjoin(security_dir, 'ipcontroller-tc.furl')
112 ),
110 ),
113 multiengine = dict(
111 multiengine = dict(
114 furl_file = ipython_dir + 'ipcontroller-mec.furl'
112 furl_file = pjoin(security_dir, 'ipcontroller-mec.furl')
115 )
113 )
116 )
114 )
117 )
115 )
@@ -50,7 +50,7 b' from IPython.kernel.engineservice import \\'
50 IEngineSerialized, \
50 IEngineSerialized, \
51 IEngineQueued
51 IEngineQueued
52
52
53 from IPython.config import cutils
53 from IPython.genutils import get_ipython_dir
54 from IPython.kernel import codeutil
54 from IPython.kernel import codeutil
55
55
56 #-------------------------------------------------------------------------------
56 #-------------------------------------------------------------------------------
@@ -170,7 +170,7 b' class ControllerService(object, service.Service):'
170
170
171 def _getEngineInfoLogFile(self):
171 def _getEngineInfoLogFile(self):
172 # Store all logs inside the ipython directory
172 # Store all logs inside the ipython directory
173 ipdir = cutils.get_ipython_dir()
173 ipdir = get_ipython_dir()
174 pjoin = os.path.join
174 pjoin = os.path.join
175 logdir_base = pjoin(ipdir,'log')
175 logdir_base = pjoin(ipdir,'log')
176 if not os.path.isdir(logdir_base):
176 if not os.path.isdir(logdir_base):
@@ -680,6 +680,13 b' class Interpreter(object):'
680 # how trailing whitespace is handled, but this seems to work.
680 # how trailing whitespace is handled, but this seems to work.
681 python = python.strip()
681 python = python.strip()
682
682
683 # The compiler module does not like unicode. We need to convert
684 # it encode it:
685 if isinstance(python, unicode):
686 # Use the utf-8-sig BOM so the compiler detects this a UTF-8
687 # encode string.
688 python = '\xef\xbb\xbf' + python.encode('utf-8')
689
683 # The compiler module will parse the code into an abstract syntax tree.
690 # The compiler module will parse the code into an abstract syntax tree.
684 ast = compiler.parse(python)
691 ast = compiler.parse(python)
685
692
@@ -93,7 +93,7 b' from subprocess import Popen,call'
93 # IPython imports
93 # IPython imports
94 #---------------------------------------------------------------------------
94 #---------------------------------------------------------------------------
95 from IPython.tools import utils
95 from IPython.tools import utils
96 from IPython.config import cutils
96 from IPython.genutils import get_ipython_dir
97
97
98 #---------------------------------------------------------------------------
98 #---------------------------------------------------------------------------
99 # Normal code begins
99 # Normal code begins
@@ -180,7 +180,7 b' def clusterLocal(opt,arg):'
180 """Start a cluster on the local machine."""
180 """Start a cluster on the local machine."""
181
181
182 # Store all logs inside the ipython directory
182 # Store all logs inside the ipython directory
183 ipdir = cutils.get_ipython_dir()
183 ipdir = get_ipython_dir()
184 pjoin = os.path.join
184 pjoin = os.path.join
185
185
186 logfile = opt.logfile
186 logfile = opt.logfile
@@ -256,6 +256,24 b' def clusterLocal(opt,arg):'
256 def clusterRemote(opt,arg):
256 def clusterRemote(opt,arg):
257 """Start a remote cluster over SSH"""
257 """Start a remote cluster over SSH"""
258
258
259 # B. Granger, 9/3/08
260 # The launching of a remote cluster using SSH and a clusterfile
261 # is broken. Because it won't be fixed before the 0.9 release,
262 # we are removing it. For now, we just print a message to the
263 # user and abort.
264
265 print """The launching of a remote IPython cluster using SSL
266 and a clusterfile has been removed in this release.
267 It has been broken for a while and we are in the process
268 of building a new process management system that will be
269 used to provide a more robust way of starting an IPython
270 cluster.
271
272 For now remote clusters have to be launched using ipcontroller
273 and ipengine separately.
274 """
275 sys.exit(1)
276
259 # Load the remote cluster configuration
277 # Load the remote cluster configuration
260 clConfig = {}
278 clConfig = {}
261 execfile(opt.clusterfile,clConfig)
279 execfile(opt.clusterfile,clConfig)
@@ -265,7 +283,7 b' def clusterRemote(opt,arg):'
265 sshx = clConfig.get('sshx',os.environ.get('IPYTHON_SSHX','sshx'))
283 sshx = clConfig.get('sshx',os.environ.get('IPYTHON_SSHX','sshx'))
266
284
267 # Store all logs inside the ipython directory
285 # Store all logs inside the ipython directory
268 ipdir = cutils.get_ipython_dir()
286 ipdir = get_ipython_dir()
269 pjoin = os.path.join
287 pjoin = os.path.join
270
288
271 logfile = opt.logfile
289 logfile = opt.logfile
@@ -311,6 +329,11 b' def clusterRemote(opt,arg):'
311 def main():
329 def main():
312 """Main driver for the two big options: local or remote cluster."""
330 """Main driver for the two big options: local or remote cluster."""
313
331
332 if sys.platform=='win32':
333 print """ipcluster does not work on Microsoft Windows. Please start
334 your IPython cluster using the ipcontroller and ipengine scripts."""
335 sys.exit(1)
336
314 opt,arg = parse_args()
337 opt,arg = parse_args()
315
338
316 clusterfile = opt.clusterfile
339 clusterfile = opt.clusterfile
@@ -105,6 +105,7 b' def start_engine():'
105 # register_engine to tell the controller we are ready to do work
105 # register_engine to tell the controller we are ready to do work
106 engine_connector = EngineConnector(tub_service)
106 engine_connector = EngineConnector(tub_service)
107 furl_file = kernel_config['engine']['furl_file']
107 furl_file = kernel_config['engine']['furl_file']
108 log.msg("Using furl file: %s" % furl_file)
108 d = engine_connector.connect_to_controller(engine_service, furl_file)
109 d = engine_connector.connect_to_controller(engine_service, furl_file)
109 d.addErrback(lambda _: reactor.stop())
110 d.addErrback(lambda _: reactor.stop())
110
111
@@ -245,7 +245,7 b' class IEngineSerializedTestCase(object):'
245 self.assert_(es.IEngineSerialized.providedBy(self.engine))
245 self.assert_(es.IEngineSerialized.providedBy(self.engine))
246
246
247 def testIEngineSerializedInterfaceMethods(self):
247 def testIEngineSerializedInterfaceMethods(self):
248 """Does self.engine have the methods and attributes in IEngireCore."""
248 """Does self.engine have the methods and attributes in IEngineCore."""
249 for m in list(es.IEngineSerialized):
249 for m in list(es.IEngineSerialized):
250 self.assert_(hasattr(self.engine, m))
250 self.assert_(hasattr(self.engine, m))
251
251
@@ -288,7 +288,7 b' class IEngineQueuedTestCase(object):'
288 self.assert_(es.IEngineQueued.providedBy(self.engine))
288 self.assert_(es.IEngineQueued.providedBy(self.engine))
289
289
290 def testIEngineQueuedInterfaceMethods(self):
290 def testIEngineQueuedInterfaceMethods(self):
291 """Does self.engine have the methods and attributes in IEngireQueued."""
291 """Does self.engine have the methods and attributes in IEngineQueued."""
292 for m in list(es.IEngineQueued):
292 for m in list(es.IEngineQueued):
293 self.assert_(hasattr(self.engine, m))
293 self.assert_(hasattr(self.engine, m))
294
294
@@ -326,7 +326,7 b' class IEnginePropertiesTestCase(object):'
326 self.assert_(es.IEngineProperties.providedBy(self.engine))
326 self.assert_(es.IEngineProperties.providedBy(self.engine))
327
327
328 def testIEnginePropertiesInterfaceMethods(self):
328 def testIEnginePropertiesInterfaceMethods(self):
329 """Does self.engine have the methods and attributes in IEngireProperties."""
329 """Does self.engine have the methods and attributes in IEngineProperties."""
330 for m in list(es.IEngineProperties):
330 for m in list(es.IEngineProperties):
331 self.assert_(hasattr(self.engine, m))
331 self.assert_(hasattr(self.engine, m))
332
332
@@ -1,6 +1,5 b''
1 # Set this prefix to where you want to install the plugin
1 # Set this prefix to where you want to install the plugin
2 PREFIX=~/usr/local
2 PREFIX=/usr/local
3 PREFIX=~/tmp/local
4
3
5 NOSE0=nosetests -vs --with-doctest --doctest-tests --detailed-errors
4 NOSE0=nosetests -vs --with-doctest --doctest-tests --detailed-errors
6 NOSE=nosetests -vvs --with-ipdoctest --doctest-tests --doctest-extension=txt \
5 NOSE=nosetests -vvs --with-ipdoctest --doctest-tests --doctest-extension=txt \
@@ -40,3 +40,4 b' def main():'
40
40
41 if __name__ == '__main__':
41 if __name__ == '__main__':
42 main()
42 main()
43
@@ -53,5 +53,5 b" if __name__ == '__main__':"
53 %timeit -n1 -r1 parallelDiffs(rc, nmats, matsize)
53 %timeit -n1 -r1 parallelDiffs(rc, nmats, matsize)
54
54
55 # Uncomment these to plot the histogram
55 # Uncomment these to plot the histogram
56 import pylab
56 # import pylab
57 pylab.hist(parallelDiffs(rc,matsize,matsize))
57 # pylab.hist(parallelDiffs(rc,matsize,matsize))
@@ -2,6 +2,7 b''
2 """Windows-specific part of the installation"""
2 """Windows-specific part of the installation"""
3
3
4 import os, sys, shutil
4 import os, sys, shutil
5 pjoin = os.path.join
5
6
6 def mkshortcut(target,description,link_file,*args,**kw):
7 def mkshortcut(target,description,link_file,*args,**kw):
7 """make a shortcut if it doesn't exist, and register its creation"""
8 """make a shortcut if it doesn't exist, and register its creation"""
@@ -11,69 +12,85 b' def mkshortcut(target,description,link_file,*args,**kw):'
11
12
12 def install():
13 def install():
13 """Routine to be run by the win32 installer with the -install switch."""
14 """Routine to be run by the win32 installer with the -install switch."""
14
15
15 from IPython.Release import version
16 from IPython.Release import version
16
17
17 # Get some system constants
18 # Get some system constants
18 prefix = sys.prefix
19 prefix = sys.prefix
19 python = prefix + r'\python.exe'
20 python = pjoin(prefix, 'python.exe')
20 # Lookup path to common startmenu ...
21 ip_dir = get_special_folder_path('CSIDL_COMMON_PROGRAMS') + r'\IPython'
22
21
23 # Some usability warnings at installation time. I don't want them at the
22 # Lookup path to common startmenu ...
24 # top-level, so they don't appear if the user is uninstalling.
23 ip_start_menu = pjoin(get_special_folder_path('CSIDL_COMMON_PROGRAMS'), 'IPython')
25 try:
26 import ctypes
27 except ImportError:
28 print ('To take full advantage of IPython, you need ctypes from:\n'
29 'http://sourceforge.net/projects/ctypes')
30
31 try:
32 import win32con
33 except ImportError:
34 print ('To take full advantage of IPython, you need pywin32 from:\n'
35 'http://starship.python.net/crew/mhammond/win32/Downloads.html')
36
37 try:
38 import readline
39 except ImportError:
40 print ('To take full advantage of IPython, you need readline from:\n'
41 'https://launchpad.net/pyreadline')
42
43 ipybase = '"' + prefix + r'\scripts\ipython"'
44 # Create IPython entry ...
24 # Create IPython entry ...
45 if not os.path.isdir(ip_dir):
25 if not os.path.isdir(ip_start_menu):
46 os.mkdir(ip_dir)
26 os.mkdir(ip_start_menu)
47 directory_created(ip_dir)
27 directory_created(ip_start_menu)
48
28
49 # Create program shortcuts ...
29 # Create .py and .bat files to make things available from
50 f = ip_dir + r'\IPython.lnk'
30 # the Windows command line. Thanks to the Twisted project
51 a = ipybase
31 # for this logic!
52 mkshortcut(python,'IPython',f,a)
32 programs = [
53
33 'ipython',
54 f = ip_dir + r'\pysh.lnk'
34 'iptest',
55 a = ipybase+' -p sh'
35 'ipcontroller',
56 mkshortcut(python,'IPython (command prompt mode)',f,a)
36 'ipengine',
57
37 'ipcluster',
58 f = ip_dir + r'\pylab.lnk'
38 'ipythonx',
59 a = ipybase+' -pylab'
39 'ipython-wx',
60 mkshortcut(python,'IPython (PyLab mode)',f,a)
40 'irunner'
61
41 ]
62 f = ip_dir + r'\scipy.lnk'
42 scripts = pjoin(prefix,'scripts')
63 a = ipybase+' -pylab -p scipy'
43 for program in programs:
64 mkshortcut(python,'IPython (scipy profile)',f,a)
44 raw = pjoin(scripts, program)
65
45 bat = raw + '.bat'
46 py = raw + '.py'
47 # Create .py versions of the scripts
48 shutil.copy(raw, py)
49 # Create .bat files for each of the scripts
50 bat_file = file(bat,'w')
51 bat_file.write("@%s %s %%*" % (python, py))
52 bat_file.close()
53
54 # Now move onto setting the Start Menu up
55 ipybase = pjoin(scripts, 'ipython')
56
57 link = pjoin(ip_start_menu, 'IPython.lnk')
58 cmd = '"%s"' % ipybase
59 mkshortcut(python,'IPython',link,cmd)
60
61 link = pjoin(ip_start_menu, 'pysh.lnk')
62 cmd = '"%s" -p sh' % ipybase
63 mkshortcut(python,'IPython (command prompt mode)',link,cmd)
64
65 link = pjoin(ip_start_menu, 'pylab.lnk')
66 cmd = '"%s" -pylab' % ipybase
67 mkshortcut(python,'IPython (PyLab mode)',link,cmd)
68
69 link = pjoin(ip_start_menu, 'scipy.lnk')
70 cmd = '"%s" -pylab -p scipy' % ipybase
71 mkshortcut(python,'IPython (scipy profile)',link,cmd)
72
73 link = pjoin(ip_start_menu, 'IPython test suite.lnk')
74 cmd = '"%s" -vv' % pjoin(scripts, 'iptest')
75 mkshortcut(python,'Run the IPython test suite',link,cmd)
76
77 link = pjoin(ip_start_menu, 'ipcontroller.lnk')
78 cmd = '"%s" -xy' % pjoin(scripts, 'ipcontroller')
79 mkshortcut(python,'IPython controller',link,cmd)
80
81 link = pjoin(ip_start_menu, 'ipengine.lnk')
82 cmd = '"%s"' % pjoin(scripts, 'ipengine')
83 mkshortcut(python,'IPython engine',link,cmd)
84
66 # Create documentation shortcuts ...
85 # Create documentation shortcuts ...
67 t = prefix + r'\share\doc\ipython\manual\ipython.pdf'
86 t = prefix + r'\share\doc\ipython\manual\ipython.pdf'
68 f = ip_dir + r'\Manual in PDF.lnk'
87 f = ip_start_menu + r'\Manual in PDF.lnk'
69 mkshortcut(t,r'IPython Manual - PDF-Format',f)
88 mkshortcut(t,r'IPython Manual - PDF-Format',f)
70
89
71 t = prefix + r'\share\doc\ipython\manual\html\index.html'
90 t = prefix + r'\share\doc\ipython\manual\html\index.html'
72 f = ip_dir + r'\Manual in HTML.lnk'
91 f = ip_start_menu + r'\Manual in HTML.lnk'
73 mkshortcut(t,'IPython Manual - HTML-Format',f)
92 mkshortcut(t,'IPython Manual - HTML-Format',f)
74
93
75 # make ipython.py
76 shutil.copy(prefix + r'\scripts\ipython', prefix + r'\scripts\ipython.py')
77
94
78 def remove():
95 def remove():
79 """Routine to be run by the win32 installer with the -remove switch."""
96 """Routine to be run by the win32 installer with the -remove switch."""
@@ -115,6 +115,7 b' def find_packages():'
115 add_package(packages, 'kernel', config=True, tests=True, scripts=True)
115 add_package(packages, 'kernel', config=True, tests=True, scripts=True)
116 add_package(packages, 'kernel.core', config=True, tests=True)
116 add_package(packages, 'kernel.core', config=True, tests=True)
117 add_package(packages, 'testing', tests=True)
117 add_package(packages, 'testing', tests=True)
118 add_package(packages, 'tests')
118 add_package(packages, 'testing.plugin', tests=False)
119 add_package(packages, 'testing.plugin', tests=False)
119 add_package(packages, 'tools', tests=True)
120 add_package(packages, 'tools', tests=True)
120 add_package(packages, 'UserConfig')
121 add_package(packages, 'UserConfig')
@@ -1,14 +1,8 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 """Wrapper to run setup.py using setuptools."""
2 """Wrapper to run setup.py using setuptools."""
3
3
4 import os
5 import sys
4 import sys
6
5
7 # Add my local path to sys.path
8 home = os.environ['HOME']
9 sys.path.insert(0,'%s/usr/local/lib/python%s/site-packages' %
10 (home,sys.version[:3]))
11
12 # now, import setuptools and call the actual setup
6 # now, import setuptools and call the actual setup
13 import setuptools
7 import setuptools
14 # print sys.argv
8 # print sys.argv
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now