在vim的Andr​​oid远程Python脚本 [英] android remote python scripting in vim

查看:177
本文介绍了在vim的Andr​​oid远程Python脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,你可以'远程'脚本使用的android端口转发,使用以下内容:

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

,然后在python2.6的:

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)

这工作得很好,但后来我想和VIM(的MacVim)尝试它。的想法是,我可以使用:

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>

在我的.vimrc运行code,我的编辑。这工作正常在Mac上测试Python脚本。但随着Android,我得到了以下尝试它的时候,如果我尝试这个运行(保存为and.py):

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

我是presuming,出口AP_PORT = 9999是不是VIM看得见的问题似乎是在创建 self.conn 。有任何想法吗?有没有人用这种方式?

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?

我不使用模拟器作为我的电脑是toooooo缓慢。

I am not using the emulator as my computer is toooooo slow.

推荐答案

您需要设置VIM环境中的环境变量。用途:

You need to set the environment variable in vim's environment. Use:

:let $AP_PORT=9999

设置它 - 这将由你产卵蟒蛇子进程继承

to set it - this will be inherited by the python sub-process you're spawning.

这篇关于在vim的Andr​​oid远程Python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆