I am aware that you can ‘remotely’ script android using port forwarding, using the following:
adb forward tcp:9999 tcp:<android port no>
export AP_PORT=9999
and then in python2.6:
Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import android
>>> droid = android.Android()
>>> droid.makeToast("this works")
Result(id=0, result=None, error=None)
this works fine, but then I thought about trying it with VIM (macVim). the idea being that I could use:
map <buffer> <S-e> :w<CR>:!/usr/bin/python2.6 % <CR>
in my .vimrc to run the code I am editing. This works fine for testing python scripts on the mac. But when trying it with the android I get the following if i try the run this (saved as and.py):
import android
droid = android.Android()
droid.makeToadt("hihi")
:!/usr/bin/python2.6 and.py
Traceback (most recent call last):
File "and.py", line 2, in <module>
droid = android.Android()
File "/Library/Python/2.6/site-packages/android.py", line 34, in __init__
self.conn = socket.create_connection(addr)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/socket.py", line 498, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
I am presuming that the export AP_PORT=9999 is not ‘visible’ to vim as the problem seems to be in creating the self.conn . any ideas? Does anyone use this approach?
I am not using the emulator as my computer is toooooo slow.
You need to set the environment variable in vim’s environment. Use:
to set it – this will be inherited by the python sub-process you’re spawning.