Skip to content
Snippets Groups Projects
Commit 4e13f231 authored by rdiankov's avatar rdiankov
Browse files

0.8.0 hotfix for ipython 0.11+

parent 2d6ab8dd
Branches
No related tags found
No related merge requests found
...@@ -199,8 +199,14 @@ if __name__ == "__main__": ...@@ -199,8 +199,14 @@ if __name__ == "__main__":
ipythonthread = None ipythonthread = None
if options.ipython: if options.ipython:
api_version = None
import IPython
if IPython.__version__.startswith("0.10"):
api_version = '0.10'
elif IPython.__version__.startswith("0.11"):
api_version = '0.11'
# start ipython in a separate thread # start ipython in a separate thread
from IPython.Shell import IPShellEmbed
def ipythonthreadfn(env): def ipythonthreadfn(env):
try: try:
with env: with env:
...@@ -208,8 +214,17 @@ if __name__ == "__main__": ...@@ -208,8 +214,17 @@ if __name__ == "__main__":
robot=None if len(robots) == 0 else robots[0] robot=None if len(robots) == 0 else robots[0]
bodies=env.GetBodies() bodies=env.GetBodies()
body=None if len(bodies) == 0 else bodies[0] body=None if len(bodies) == 0 else bodies[0]
ipshell = IPShellEmbed(argv='',banner = 'OpenRAVE Dropping into IPython, variables: env, robot, body',exit_msg = 'Leaving Interpreter and closing program.') if api_version == '0.10':
ipshell(local_ns=locals()) ipshell = IPython.Shell.IPShellEmbed(argv='',banner = 'OpenRAVE %s dropping into IPython, variables: env, robot, body'%openravepy.__version__,exit_msg = 'Leaving Interpreter and closing program.')
ipshell(local_ns=locals())
else:
from IPython.config.loader import Config
cfg = Config()
cfg.InteractiveShellEmbed.local_ns = locals()
cfg.InteractiveShellEmbed.global_ns = globals()
IPython.embed(config=cfg, banner2 = 'OpenRAVE %s dropping into IPython, variables: env, robot, body'%openravepy.__version__)
from IPython.frontend.terminal.embed import InteractiveShellEmbed
ipshell = InteractiveShellEmbed(config=cfg)
finally: finally:
# ipython exited. if viewer is valid, then exit the viewer also # ipython exited. if viewer is valid, then exit the viewer also
if viewer is not None: if viewer is not None:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment