From: Menno Smits Date: Tue, 8 Nov 2011 21:01:53 +0000 (+0000) Subject: interact.py now works with both ipython 0.10 and 0.11 shell embedding X-Git-Tag: 0.8~14 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=b74d3342e4910b392e03c7bb5312e8f7e83a3e00;p=imapclient.git interact.py now works with both ipython 0.10 and 0.11 shell embedding --- diff --git a/interact.py b/interact.py index faa151b..900e5d8 100755 --- a/interact.py +++ b/interact.py @@ -5,7 +5,6 @@ # Please see http://en.wikipedia.org/wiki/BSD_licenses -import code from getpass import getpass from optparse import OptionParser @@ -48,11 +47,27 @@ def command_line(): if __name__ == '__main__': opts = command_line() + print 'Connecting...' client = create_client_from_config(opts) + print 'Connected.' banner = '\nIMAPClient instance is "c"' - try: + + def ipython_011(c): + from IPython.frontend.terminal.embed import InteractiveShellEmbed + ipshell = InteractiveShellEmbed(banner1=banner) + ipshell('') + + def ipython_010(c): from IPython.Shell import IPShellEmbed - c = client IPShellEmbed('', banner=banner)() - except ImportError: - code.interact(banner, local=dict(c=client)) + + def builtin(c): + import code + code.interact(banner, local=dict(c=c)) + + for shell_attempt in (ipython_011, ipython_010, builtin): + try: + shell_attempt(client) + break + except ImportError: + pass