Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1df70d6

Browse files
committed
informative message on failure to connect
1 parent bbe47e2 commit 1df70d6

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

bipython/__init__.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -748,15 +748,25 @@ def echo(x):
748748
#XXX: backwards compatibility for IPython < 1.0
749749
if not hasattr(kc, 'iopub_channel'):
750750
kc.iopub_channel = kc.sub_channel
751-
print km
752-
self.send_ipython('# bpython connected')
753751
self.km = km
754752
self.kc = kc
755-
# TODO: hide this from user_ns
756-
self.ipython_set_pid()
753+
print km
754+
msg_id = self.send_ipython('# bpython connected')
755+
try:
756+
child = self.ipython_get_child_msg(msg_id)
757+
except Empty:
758+
import sys
759+
sys.stderr.write("\n")
760+
sys.stderr.write("""Unable to connect to IPython:
761+
Either it's busy executing, or you haven't started one.
762+
use `ipython console` in another shell first, or open a
763+
new IPython Notebook""")
764+
sys.exit(1)
765+
757766
self.send_ipython(bipy_func, silent=True)
758767
# TODO: get a proper history navigator
759768
#self.rl_history = IPythonHistory(kc)
769+
self.ipython_set_pid()
760770

761771
return km
762772

@@ -1875,3 +1885,4 @@ def load_urwid_command_map(config):
18751885
"""
18761886
if __name__ == '__main__':
18771887
sys.exit(main())
1888+

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@
3838
setup_kwargs['install_requires'] = [
3939
'Pygments >= 1.6',
4040
'urwid >= 1.1.1',
41-
'bipython >= 0.12',
41+
'bpython >= 0.12',
4242
'ipython >= 0.12',
4343
]
4444

4545
if __name__ == '__main__':
46-
with open('README.md').read() as f:
46+
with open('README.md') as f:
4747
descr = f.read()
4848
descr = descr[:descr.find('TODO')]
4949
setup(

0 commit comments

Comments
 (0)