Show More
@@ -8,6 +8,7 b' $Id: iplib.py 1107 2006-01-30 19:02:20Z vivainio $' | |||
|
8 | 8 | """ |
|
9 | 9 | |
|
10 | 10 | import IPython.ipapi |
|
11 | from IPython.ipapi import UsageError | |
|
11 | 12 | ip = IPython.ipapi.get() |
|
12 | 13 | |
|
13 | 14 | import pickleshare |
@@ -96,12 +97,12 b" def magic_store(self, parameter_s=''):" | |||
|
96 | 97 | try: |
|
97 | 98 | todel = args[0] |
|
98 | 99 | except IndexError: |
|
99 | error('You must provide the variable to forget') | |
|
100 | raise UsageError('You must provide the variable to forget') | |
|
100 | 101 | else: |
|
101 | 102 | try: |
|
102 | 103 | del db['autorestore/' + todel] |
|
103 | 104 | except: |
|
104 | error("Can't delete variable '%s'" % todel) | |
|
105 | raise UsageError("Can't delete variable '%s'" % todel) | |
|
105 | 106 | # reset |
|
106 | 107 | elif opts.has_key('z'): |
|
107 | 108 | for k in db.keys('autorestore/*'): |
@@ -165,7 +166,7 b" def magic_store(self, parameter_s=''):" | |||
|
165 | 166 | print "Alias stored:", args[0], self.alias_table[ args[0] ] |
|
166 | 167 | return |
|
167 | 168 | else: |
|
168 |
|
|
|
169 | raise UsageError("Unknown variable '%s'" % args[0]) | |
|
169 | 170 | |
|
170 | 171 | else: |
|
171 | 172 | if isinstance(inspect.getmodule(obj), FakeModule): |
@@ -21,15 +21,13 b' import re' | |||
|
21 | 21 | import sys |
|
22 | 22 | import os |
|
23 | 23 | import locale |
|
24 | import time | |
|
25 | import pydoc,__builtin__,site | |
|
26 | 24 | from thread_ex import ThreadEx |
|
27 | from StringIO import StringIO | |
|
28 | 25 | |
|
29 | 26 | try: |
|
30 | 27 |
|
|
31 | 28 | except Exception,e: |
|
32 |
|
|
|
29 | print "Error importing IPython (%s)" % str(e) | |
|
30 | raise Exception, e | |
|
33 | 31 | |
|
34 | 32 | ############################################################################## |
|
35 | 33 | class _Helper(object): |
@@ -46,10 +44,12 b' class _Helper(object):' | |||
|
46 | 44 | |
|
47 | 45 | def __call__(self, *args, **kwds): |
|
48 | 46 | class DummyWriter(object): |
|
47 | '''Dumy class to handle help output''' | |
|
49 | 48 | def __init__(self,pager): |
|
50 | 49 | self._pager = pager |
|
51 | 50 | |
|
52 | 51 | def write(self,data): |
|
52 | '''hook to fill self._pager''' | |
|
53 | 53 | self._pager(data) |
|
54 | 54 | |
|
55 | 55 | import pydoc |
@@ -61,13 +61,14 b' class _Helper(object):' | |||
|
61 | 61 | |
|
62 | 62 | ############################################################################## |
|
63 | 63 | class _CodeExecutor(ThreadEx): |
|
64 | ||
|
64 | ''' Thread that execute ipython code ''' | |
|
65 | 65 | def __init__(self, instance, after): |
|
66 | 66 | ThreadEx.__init__(self) |
|
67 | 67 | self.instance = instance |
|
68 | 68 | self._afterExecute=after |
|
69 | 69 | |
|
70 | 70 | def run(self): |
|
71 | '''Thread main loop''' | |
|
71 | 72 | try: |
|
72 | 73 | self.instance._doc_text = None |
|
73 | 74 | self.instance._help_text = None |
@@ -112,6 +113,8 b' class NonBlockingIPShell(object):' | |||
|
112 | 113 | @type int |
|
113 | 114 | ''' |
|
114 | 115 | #ipython0 initialisation |
|
116 | self._IP = None | |
|
117 | self._term = None | |
|
115 | 118 | self.initIpython0(argv, user_ns, user_global_ns, |
|
116 | 119 | cin, cout, cerr, |
|
117 | 120 | ask_exit_handler) |
@@ -134,6 +137,8 b' class NonBlockingIPShell(object):' | |||
|
134 | 137 | def initIpython0(self, argv=[], user_ns={}, user_global_ns=None, |
|
135 | 138 | cin=None, cout=None, cerr=None, |
|
136 | 139 | ask_exit_handler=None): |
|
140 | ''' Initialize an ithon0 instance ''' | |
|
141 | ||
|
137 | 142 | #first we redefine in/out/error functions of IPython |
|
138 | 143 | if cin: |
|
139 | 144 | IPython.Shell.Term.cin = cin |
@@ -190,8 +195,8 b' class NonBlockingIPShell(object):' | |||
|
190 | 195 | |
|
191 | 196 | self._line_to_execute = line |
|
192 | 197 | #we launch the ipython line execution in a thread to make it interruptible |
|
193 |
|
|
|
194 |
|
|
|
198 | ce = _CodeExecutor(self, self._afterExecute) | |
|
199 | ce.start() | |
|
195 | 200 | |
|
196 | 201 | #----------------------- IPython management section ---------------------- |
|
197 | 202 | def getDocText(self): |
@@ -321,7 +326,8 b' class NonBlockingIPShell(object):' | |||
|
321 | 326 | ''' |
|
322 | 327 | history = '' |
|
323 | 328 | #the below while loop is used to suppress empty history lines |
|
324 |
while((history == '' or history == '\n') |
|
|
329 | while((history == '' or history == '\n') \ | |
|
330 | and self._history_level <= self._getHistoryMaxIndex()): | |
|
325 | 331 |
|
|
326 | 332 |
|
|
327 | 333 |
|
@@ -375,8 +381,8 b' class NonBlockingIPShell(object):' | |||
|
375 | 381 | ''' |
|
376 | 382 | This function is used as a callback replacment to IPython help pager function |
|
377 | 383 | |
|
378 |
It puts the 'text' value inside the self._help_text string that can be retrived via |
|
|
379 | function. | |
|
384 | It puts the 'text' value inside the self._help_text string that can be retrived via | |
|
385 | getHelpText function. | |
|
380 | 386 | ''' |
|
381 | 387 | if self._help_text == None: |
|
382 | 388 | self._help_text = text |
@@ -387,8 +393,8 b' class NonBlockingIPShell(object):' | |||
|
387 | 393 | ''' |
|
388 | 394 | This function is used as a callback replacment to IPython pager function |
|
389 | 395 | |
|
390 |
It puts the 'text' value inside the self._doc_text string that can be retrived via |
|
|
391 | function. | |
|
396 | It puts the 'text' value inside the self._doc_text string that can be retrived via | |
|
397 | getDocText function. | |
|
392 | 398 | ''' |
|
393 | 399 | self._doc_text = text |
|
394 | 400 | |
@@ -429,8 +435,7 b' class NonBlockingIPShell(object):' | |||
|
429 | 435 | self._IP.showtraceback() |
|
430 | 436 | else: |
|
431 | 437 | self._iter_more = self._IP.push(line) |
|
432 | if (self._IP.SyntaxTB.last_syntax_error and | |
|
433 | self._IP.rc.autoedit_syntax): | |
|
438 | if (self._IP.SyntaxTB.last_syntax_error and self._IP.rc.autoedit_syntax): | |
|
434 | 439 | self._IP.edit_syntax_error() |
|
435 | 440 | if self._iter_more: |
|
436 | 441 | self._prompt = str(self._IP.outputcache.prompt2).strip() |
@@ -452,8 +457,8 b' class NonBlockingIPShell(object):' | |||
|
452 | 457 | ''' |
|
453 | 458 | stdin, stdout = os.popen4(cmd) |
|
454 | 459 | result = stdout.read().decode('cp437').encode(locale.getpreferredencoding()) |
|
455 |
#we use print command because the shell command is called |
|
|
456 | #redirected to thread cout | |
|
460 | #we use print command because the shell command is called | |
|
461 | #inside IPython instance and thus is redirected to thread cout | |
|
457 | 462 | #"\x01\x1b[1;36m\x02" <-- add colour to the text... |
|
458 | 463 | print "\x01\x1b[1;36m\x02"+result |
|
459 | 464 | stdout.close() |
@@ -28,13 +28,7 b' import wx' | |||
|
28 | 28 | import wx.stc as stc |
|
29 | 29 | |
|
30 | 30 | import re |
|
31 | import sys | |
|
32 | import locale | |
|
33 | 31 | from StringIO import StringIO |
|
34 | try: | |
|
35 | import IPython | |
|
36 | except Exception,e: | |
|
37 | raise "Error importing IPython (%s)" % str(e) | |
|
38 | 32 | |
|
39 | 33 | from ipshell_nonblocking import NonBlockingIPShell |
|
40 | 34 | |
@@ -387,9 +381,7 b' class WxConsoleView(stc.StyledTextCtrl):' | |||
|
387 | 381 | max_symbol =' '*max_len |
|
388 | 382 | |
|
389 | 383 | #now we check how much symbol we can put on a line... |
|
390 | cursor_pos = self.getCursorPos() | |
|
391 | 384 | test_buffer = max_symbol + ' '*4 |
|
392 | current_lines = self.GetLineCount() | |
|
393 | 385 | |
|
394 | 386 | allowed_symbols = 80/len(test_buffer) |
|
395 | 387 | if allowed_symbols == 0: |
@@ -462,7 +454,8 b' class WxConsoleView(stc.StyledTextCtrl):' | |||
|
462 | 454 | return True |
|
463 | 455 | |
|
464 | 456 | if skip: |
|
465 |
if event.GetKeyCode() not in [wx.WXK_PAGEUP,wx.WXK_PAGEDOWN] |
|
|
457 | if event.GetKeyCode() not in [wx.WXK_PAGEUP, wx.WXK_PAGEDOWN]\ | |
|
458 | and event.Modifiers == wx.MOD_NONE: | |
|
466 | 459 | self.moveCursorOnNewValidKey() |
|
467 | 460 | |
|
468 | 461 | event.Skip() |
@@ -1,9 +1,22 b'' | |||
|
1 | 2008-06-03 Ville Vainio <vivainio@gmail.com> | |
|
2 | ||
|
3 | * ipython.rst, ipython.1: remove -twisted from man page, | |
|
4 | add -pydb to both man page and manual. | |
|
5 | ||
|
6 | * pspersistence.py: report UsageError on %store -w w/o arg, | |
|
7 | and other usage pattern errors. Bug report by Johann Cohen-Tanugi. | |
|
8 | ||
|
1 | 9 | 2008-06-02 Fernando Perez <Fernando.Perez@berkeley.edu> |
|
2 | 10 | |
|
3 | 11 | * IPython/Shell.py (MatplotlibShellBase._matplotlib_config): add |
|
4 | 12 | numpy/np/pyplot/plt imports according to new conventions we're |
|
5 | 13 | trying to standardize on. This only affects the -pylab mode. |
|
6 | 14 | |
|
15 | 2008-05-31 Fernando Perez <Fernando.Perez@berkeley.edu> | |
|
16 | ||
|
17 | * IPython/ipmaker.py (make_IPython): The -twisted option is fully | |
|
18 | disabled. | |
|
19 | ||
|
7 | 20 | 2008-05-31 *** Released version 0.8.4 |
|
8 | 21 | |
|
9 | 22 | 2008-05-31 Fernando Perez <Fernando.Perez@berkeley.edu> |
@@ -36,7 +36,7 b' The following special options are ONLY valid at the beginning of the command' | |||
|
36 | 36 | line, and not later. This is because they control the initialization of |
|
37 | 37 | ipython itself, before the normal option-handling mechanism is active. |
|
38 | 38 | .TP |
|
39 |
.B \-gthread, \-qthread, \-q4thread, \-wthread, \-pylab |
|
|
39 | .B \-gthread, \-qthread, \-q4thread, \-wthread, \-pylab | |
|
40 | 40 | Only ONE of these can be given, and it can only be given as the first option |
|
41 | 41 | passed to IPython (it will have no effect in any other position). They provide |
|
42 | 42 | threading support for the GTK, QT3, QT4 and WXWidgets toolkits, for the |
@@ -56,10 +56,6 b' request a specific version of wx to be used. This requires that you have the' | |||
|
56 | 56 | distributions. |
|
57 | 57 | .br |
|
58 | 58 | .sp 1 |
|
59 | If \-twisted is given, IPython start a Twisted reactor and runs IPython mainloop | |
|
60 | in a dedicated thread, passing commands to be run inside the Twisted reactor. | |
|
61 | .br | |
|
62 | .sp 1 | |
|
63 | 59 | If \-pylab is given, IPython loads special support for the matplotlib library |
|
64 | 60 | (http://matplotlib.sourceforge.net), allowing interactive usage of any of its |
|
65 | 61 | backends as defined in the user's .matplotlibrc file. It automatically |
@@ -245,6 +241,10 b' you are used to debugging using pdb, this puts you automatically' | |||
|
245 | 241 | inside of it after any call (either in IPython or in code called by |
|
246 | 242 | it) which triggers an exception which goes uncaught. |
|
247 | 243 | .TP |
|
244 | .B \-pydb | |
|
245 | Makes IPython use the third party "pydb" package as debugger, | |
|
246 | instead of pdb. Requires that pydb is installed. | |
|
247 | .TP | |
|
248 | 248 | .B \-[no]pprint |
|
249 | 249 | IPython can optionally use the pprint (pretty printer) module for |
|
250 | 250 | displaying results. pprint tends to give a nicer display of nested |
@@ -1227,6 +1227,10 b' All options with a [no] prepended can be specified in negated form' | |||
|
1227 | 1227 | IPython or in code called by it) which triggers an exception |
|
1228 | 1228 | which goes uncaught. |
|
1229 | 1229 | |
|
1230 | -pydb | |
|
1231 | Makes IPython use the third party "pydb" package as debugger, | |
|
1232 | instead of pdb. Requires that pydb is installed. | |
|
1233 | ||
|
1230 | 1234 | -[no]pprint |
|
1231 | 1235 | ipython can optionally use the pprint (pretty printer) module |
|
1232 | 1236 | for displaying results. pprint tends to give a nicer display |
General Comments 0
You need to be logged in to leave comments.
Login now