erppeek icon indicating copy to clipboard operation
erppeek copied to clipboard

IPython integration

Open guaka opened this issue 10 years ago • 9 comments

I'm very happy I just bumped into this project. I'm also a very happy IPython user.

Is there a way to get erppeek inside ipython? (or vice versa)

guaka avatar Jul 27 '14 00:07 guaka

I have no idea, since I am not an IPython user myself. I welcome your own feedback.

florentx avatar Jul 27 '14 11:07 florentx

I started hacking towards this, by copying main() into another file and adapting it so that it returns global_vars. If I manage to get these global_vars in the IPython environment it would be quite workable.

Another approach is to let erppeek check for the presence of IPython and in that case use that as an alternative to erppeek._interact().

guaka avatar Jul 27 '14 20:07 guaka

I think what you want is something like this:

try:
    import IPython
    return IPython.start_ipython(user_ns=global_vars)
except ImportError:
   pass # Continue to set up a basic shell if IPython isn't installed

takluyver avatar Jul 29 '14 21:07 takluyver

Excellent! It worked after I added a line for handling argv.

    try:
        import IPython
        sys.argv = [sys.argv[0]]
        return IPython.start_ipython(user_ns=global_vars)
    except ImportError:
        pass # Continue to set up a basic shell if IPython isn't installed

guaka avatar Jul 29 '14 21:07 guaka

You can also pass argv=sys.argv[:1] into start_ipython() - that will prevent IPython from trying to parse your programs arguments, but if the user inspects sys.argv, they'll still see the original value.

takluyver avatar Jul 29 '14 21:07 takluyver

Nice, but unfortunately erppeek exits without any feedback when I try IPython.start_ipython(user_ns=global_vars, argv=sys.argv[:1])

guaka avatar Jul 29 '14 21:07 guaka

Oh, sorry, it should be just argv=[] (i.e. an empty list).

takluyver avatar Jul 29 '14 21:07 takluyver

@florentx you could replace the [question] label with the [enhancement] label :)

guaka avatar Sep 19 '14 12:09 guaka

Please confirm that 1.6 gives enough flexibility for IPython.

I have posted details on pull request #62 ... You can contribute an addition to the documentation, if it works.

florentx avatar Sep 23 '14 14:09 florentx