[IPython-dev] A couple of odd behaviours...

Carl Smith carl.input at gmail.com
Tue Nov 6 20:43:31 EST 2012

Hi all

I've been playing with IPython and Android and have come across a
couple of issues.

In order to connect the droid to my PC, I have to run the following
two commands.

adb forward tcp:9999 tcp:45001
export AP_PORT=9999

For the record, adb is the Android Debug Bridge, which enables the connection.

If I do the above commands in a regular shell, then launch IPython,
Classic or Notebook, it all works as expected, but if I run the above
commands in IPython, it fails with an adb specific error. For


!adb forward tcp:9999 tcp:45001
!export AP_PORT=9999

import android
d = android.Android()


gaierror                                  Traceback (most recent call last)
<ipython-input-4-59c060a72514> in <module>()
----> 1 d = android.Android()

/home/carl/droidbridge/android.pyc in __init__(self, addr)
     32     if addr is None:
     33       addr = HOST, PORT
---> 34     self.conn = socket.create_connection(addr)
     35     self.client = self.conn.makefile()
     36     self.id = 0

/usr/lib/python2.7/socket.pyc in create_connection(address, timeout,
    551     host, port = address
    552     err = None
--> 553     for res in getaddrinfo(host, port, 0, SOCK_STREAM):
    554         af, socktype, proto, canonname, sa = res
    555         sock = None

gaierror: [Errno -2] Name or service not known

Any thoughts on this would be appreciated.

Also, once I have the Notebook running, and the above problem dealt
with, there's an issue with output.

You can use adb to issue shell commands using `adb shell <cmd>`, so
`adb shell ls` runs `ls` on the droid. When I do this in the notebook,
the output is blank. The page moves to show the list, so if there's
three files, it renders three lines, if there five files, it renders
five lines, but the lines are blank. If you drag select them with a
mouse, each line is just a newline character.

If you do `a = !adb shell ls`, you can eval or print `a` and get a
list of the files, as you'd expect.

I appreciate there's not many people around IPython Dev that will have
adb to hand, but if anyone would like more details, just let me know.
I'm really just hoping someone might have some idea of why this would

Note: In IPython Classic, `!abd shell ls` works fine. The blank lines
are in the Notebook only.



More information about the IPython-dev mailing list