如何获得"adb设备"与env一起使用Popen()时可以正常工作 [英] how to get "adb device" to work when using Popen() with env

查看:122
本文介绍了如何获得"adb设备"与env一起使用Popen()时可以正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

原始代码为

在没有env={'ADB_TRACE':'adb'}的情况下可以正常工作.

it works fine without env={'ADB_TRACE':'adb'}.

使用env变量执行有关adb的任何命令,我得到一个错误:

exec any command about adb with the env variable, i got an error:

ADB server didn't ACK
* failed to start daemon *
error: cannot connect to daemon

在杀死adb服务器后似乎不起作用

it seems not to work after kill the adb server

整个输出为此处

OS:win7

推荐答案

我怀疑adb还需要其他环境变量(例如$HOME). 您应该克隆现有环境,然后在其中添加ADB_TRACE.

I suspect adb also needs other environment variables (like $HOME). You should clone your existing environment and add ADB_TRACE to it.

import os
new_env = os.environ.copy()
new_env['ADB_TRACE'] = 'adb'

# sp.popen()

从文档中

If env is not None, it must be a mapping that defines the environment variables
for the new process; these are used instead of inheriting the current process’
environment, which is the default behavior.

看来,这与恩文本身无关. 相反,如果设置了ADB_TRACE,则adb服务器将损坏. 尝试在没有ADB_TRACE的环境中预先启动服务器.

It seems, it's not about the envoronment itself. Rather the adb server is broken if ADB_TRACE is set. Try to start the server beforehand in an environment without ADB_TRACE.

这篇关于如何获得"adb设备"与env一起使用Popen()时可以正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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