##// END OF EJS Templates
Provide "realistic" sys.argv for scripts run via ipython...
vivainio -
Show More
@@ -6,7 +6,7 b' Requires Python 2.1 or better.'
6 6
7 7 This file contains the main make_IPython() starter function.
8 8
9 $Id: ipmaker.py 1041 2006-01-21 09:29:14Z vivainio $"""
9 $Id: ipmaker.py 1086 2006-01-27 16:02:38Z vivainio $"""
10 10
11 11 #*****************************************************************************
12 12 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
@@ -657,21 +657,24 b" object? -> Details about 'object'. ?object also works, ?? prints more."
657 657 # ipython is fully initialized, just as if they were run via %run at the
658 658 # ipython prompt. This would also give them the benefit of ipython's
659 659 # nice tracebacks.
660
660
661 661 if not embedded and IP_rc.args:
662 662 name_save = IP.user_ns['__name__']
663 663 IP.user_ns['__name__'] = '__main__'
664 # Set our own excepthook in case the user code tries to call it
665 # directly. This prevents triggering the IPython crash handler.
666 old_excepthook,sys.excepthook = sys.excepthook, IP.excepthook
667
668 save_argv = sys.argv[:] # save it for later restoring
669 sys.argv.pop(0) # the first arg is 'ipython'
670
664 671 try:
665 # Set our own excepthook in case the user code tries to call it
666 # directly. This prevents triggering the IPython crash handler.
667 old_excepthook,sys.excepthook = sys.excepthook, IP.excepthook
668 for run in args:
669 IP.safe_execfile(run,IP.user_ns)
672 IP.safe_execfile(args[0], IP.user_ns)
670 673 finally:
671 674 # Reset our crash handler in place
672 675 sys.excepthook = old_excepthook
673
674 IP.user_ns['__name__'] = name_save
676 sys.argv = save_argv
677 IP.user_ns['__name__'] = name_save
675 678
676 679 msg.user_exec.release_all()
677 680 if IP_rc.messages:
@@ -1,3 +1,10 b''
1 2006-01-27 Ville Vainio <vivainio@gmail.com>
2
3 * ipmaker.py: Give "realistic" sys.argv for scripts (without
4 'ipython' at argv[0]) executed through command line.
5 NOTE: this DEPRECATES calling ipython with multiple scripts
6 ("ipython a.py b.py c.py")
7
1 8 2006-01-25 Fernando Perez <Fernando.Perez@colorado.edu>
2 9
3 10 * IPython/demo.py (Demo.show): Flush stdout after each block, so
General Comments 0
You need to be logged in to leave comments. Login now