Show More
@@ -211,15 +211,10 b' def hg_completer(self,event):' | |||
|
211 | 211 | |
|
212 | 212 | |
|
213 | 213 | |
|
214 |
bzr_commands |
|
|
215 | add annotate bind branch break-lock bundle-revisions cat check | |
|
216 | checkout commit conflicts deleted diff export gannotate gbranch | |
|
217 | gcommit gdiff help ignore ignored info init init-repository inventory | |
|
218 | log merge missing mkdir mv nick pull push reconcile register-branch | |
|
219 | remerge remove renames resolve revert revno root serve sign-my-commits | |
|
220 | status testament unbind uncommit unknowns update upgrade version | |
|
221 | version-info visualise whoami | |
|
222 | """ | |
|
214 | def bzr_commands(): | |
|
215 | out = os.popen('bzr help commands') | |
|
216 | return [l.split()[0] for l in out] | |
|
217 | ||
|
223 | 218 | |
|
224 | 219 | def bzr_completer(self,event): |
|
225 | 220 | """ Completer for bazaar commands """ |
@@ -232,7 +227,7 b' def bzr_completer(self,event):' | |||
|
232 | 227 | param = cmd_param[-1] |
|
233 | 228 | output_file = (param == '--output=') |
|
234 | 229 | if cmd == 'help': |
|
235 |
return bzr_commands |
|
|
230 | return bzr_commands() | |
|
236 | 231 | elif cmd in ['bundle-revisions','conflicts', |
|
237 | 232 | 'deleted','nick','register-branch', |
|
238 | 233 | 'serve','unbind','upgrade','version', |
@@ -242,7 +237,7 b' def bzr_completer(self,event):' | |||
|
242 | 237 | # the rest are probably file names |
|
243 | 238 | return ip.IP.Completer.file_matches(event.symbol) |
|
244 | 239 | |
|
245 |
return bzr_commands |
|
|
240 | return bzr_commands() | |
|
246 | 241 | |
|
247 | 242 | |
|
248 | 243 | def shlex_split(x): |
@@ -533,7 +533,7 b' class DebugTools:' | |||
|
533 | 533 | if name in self.hotnames: |
|
534 | 534 | self.debug_stack( "HotName '%s' caught" % name) |
|
535 | 535 | |
|
536 | def launch_new_instance(user_ns = None): | |
|
536 | def launch_new_instance(user_ns = None,shellclass = None): | |
|
537 | 537 | """ Make and start a new ipython instance. |
|
538 | 538 | |
|
539 | 539 | This can be called even without having an already initialized |
@@ -542,7 +542,7 b' def launch_new_instance(user_ns = None):' | |||
|
542 | 542 | This is also used as the egg entry point for the 'ipython' script. |
|
543 | 543 | |
|
544 | 544 | """ |
|
545 | ses = make_session(user_ns) | |
|
545 | ses = make_session(user_ns,shellclass) | |
|
546 | 546 | ses.mainloop() |
|
547 | 547 | |
|
548 | 548 | |
@@ -578,7 +578,7 b' def make_user_global_ns(ns = None):' | |||
|
578 | 578 | return ns |
|
579 | 579 | |
|
580 | 580 | |
|
581 | def make_session(user_ns = None): | |
|
581 | def make_session(user_ns = None, shellclass = None): | |
|
582 | 582 | """Makes, but does not launch an IPython session. |
|
583 | 583 | |
|
584 | 584 | Later on you can call obj.mainloop() on the returned object. |
@@ -591,6 +591,6 b' def make_session(user_ns = None):' | |||
|
591 | 591 | WARNING: This should *not* be run when a session exists already.""" |
|
592 | 592 | |
|
593 | 593 | import IPython.Shell |
|
594 | return IPython.Shell.start(user_ns) | |
|
595 | ||
|
596 | ||
|
594 | if shellclass is None: | |
|
595 | return IPython.Shell.start(user_ns) | |
|
596 | return shellclass(user_ns = user_ns) |
@@ -58,6 +58,14 b' from IPython.iplib import InteractiveShell' | |||
|
58 | 58 | from IPython.usage import cmd_line_usage,interactive_usage |
|
59 | 59 | from IPython.genutils import * |
|
60 | 60 | |
|
61 | def force_import(modname): | |
|
62 | if modname in sys.modules: | |
|
63 | print "reload",modname | |
|
64 | reload(sys.modules[modname]) | |
|
65 | else: | |
|
66 | __import__(modname) | |
|
67 | ||
|
68 | ||
|
61 | 69 | #----------------------------------------------------------------------------- |
|
62 | 70 | def make_IPython(argv=None,user_ns=None,user_global_ns=None,debug=1, |
|
63 | 71 | rc_override=None,shell_class=InteractiveShell, |
@@ -633,15 +641,17 b" object? -> Details about 'object'. ?object also works, ?? prints more." | |||
|
633 | 641 | if opts_all.profile and not profile_handled_by_legacy: |
|
634 | 642 | profmodname = 'ipy_profile_' + opts_all.profile |
|
635 | 643 | try: |
|
636 | __import__(profmodname) | |
|
644 | ||
|
645 | force_import(profmodname) | |
|
637 | 646 | except: |
|
638 | 647 | IP.InteractiveTB() |
|
639 | 648 | print "Error importing",profmodname,"- perhaps you should run %upgrade?" |
|
640 | 649 | import_fail_info(profmodname) |
|
641 | 650 | else: |
|
642 |
import |
|
|
643 |
try: |
|
|
644 | import ipy_user_conf | |
|
651 | force_import('ipy_profile_none') | |
|
652 | try: | |
|
653 | ||
|
654 | force_import('ipy_user_conf') | |
|
645 | 655 | |
|
646 | 656 | except: |
|
647 | 657 | conf = opts_all.ipythondir + "/ipy_user_conf.py" |
@@ -6,27 +6,43 b' user namespace.' | |||
|
6 | 6 | """ |
|
7 | 7 | |
|
8 | 8 | import sys |
|
9 |
sys.path. |
|
|
9 | sys.path.insert(1,'..') | |
|
10 | 10 | |
|
11 | 11 | import IPython.ipapi |
|
12 | 12 | |
|
13 | my_ns = dict(a=10) | |
|
14 | 13 | |
|
15 | ses = IPython.ipapi.make_session(my_ns) | |
|
16 | 14 | |
|
17 | # Now get the ipapi instance, to be stored somewhere in your program for manipulation of the running | |
|
18 | # IPython session. See http://ipython.scipy.org/moin/IpythonExtensionApi | |
|
19 | ||
|
20 | ip = ses.IP.getapi() | |
|
21 | ||
|
22 | # let's play with the ipapi a bit, creating a magic function for a soon-to-be-started IPython | |
|
23 | def mymagic_f(self,s): | |
|
24 | print "mymagic says",s | |
|
25 | ||
|
26 | ip.expose_magic("mymagic",mymagic_f) | |
|
27 | ||
|
28 | # And finally, start the IPython interaction! This will block until you say Exit. | |
|
29 | ||
|
30 | ses.mainloop() | |
|
31 | ||
|
32 | print "IPython session finished! namespace content:",my_ns | |
|
15 | def test_session(shellclass): | |
|
16 | print "*****************\nLaunch shell for",shellclass | |
|
17 | my_ns = dict(a=10) | |
|
18 | ses = IPython.ipapi.make_session(my_ns, shellclass=shellclass) | |
|
19 | ||
|
20 | # Now get the ipapi instance, to be stored somewhere in your program for manipulation of the running | |
|
21 | # IPython session. See http://ipython.scipy.org/moin/IpythonExtensionApi | |
|
22 | ||
|
23 | ip = ses.IP.getapi() | |
|
24 | ||
|
25 | # let's play with the ipapi a bit, creating a magic function for a soon-to-be-started IPython | |
|
26 | def mymagic_f(self,s): | |
|
27 | print "mymagic says",s | |
|
28 | ||
|
29 | ip.expose_magic("mymagic",mymagic_f) | |
|
30 | ||
|
31 | # And finally, start the IPython interaction! This will block until you say Exit. | |
|
32 | ||
|
33 | ses.mainloop() | |
|
34 | ||
|
35 | print "IPython session for shell ",shellclass," finished! namespace content:" | |
|
36 | for k,v in my_ns.items(): | |
|
37 | print k,':',str(v)[:80].rstrip() | |
|
38 | ||
|
39 | import IPython.Shell | |
|
40 | ||
|
41 | def do_test(arg_line): | |
|
42 | test_session(IPython.Shell._select_shell(arg_line.split())) | |
|
43 | ||
|
44 | do_test('') | |
|
45 | do_test('ipython -gthread') | |
|
46 | do_test('ipython -q4thread') | |
|
47 | do_test('ipython -pylab') | |
|
48 | do_test('ipython -pylab -gthread') No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now