From 419434489163b13ff26bb3b36f8b622b4360a953 Mon Sep 17 00:00:00 2001 From: Wirawan Purwanto Date: Thu, 16 Feb 2012 13:45:46 -0500 Subject: [PATCH] * init_interactive() returns True if interactive session is detected; False otherwise. --- interactive_tools.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/interactive_tools.py b/interactive_tools.py index ed3b291..07a8585 100644 --- a/interactive_tools.py +++ b/interactive_tools.py @@ -131,14 +131,20 @@ def init_interactive(use_readline=True, global_ns=None): # Interestingly, under ipython the sys.argv is only "correct" to extract # the program name at the first loading of the script. # So we must capture that: - if int_info['session'] == 'ipython' and 'ARGV' not in g: + if not int_info: + pass + #print >>MSGLOG, "init_interactive: Cannot detect python session type." + return False + elif int_info['session'] == 'ipython' and 'ARGV' not in g: g['ARGV'] = sys.argv try: g['MYSELF'] = os.path.abspath(sys.argv[0]) except: pass + return True elif int_info['session'] in ('python', 'python -i'): g.setdefault('MYSELF', sys.argv[0]) g.setdefault('ARGV', sys.argv) + return True #print "_-helo"