【发布时间】:2016-01-30 08:53:35
【问题描述】:
我正在尝试获取 adb logcat 并保存到文件中。我尝试了 POPEN 并调用如下
f = open("/Users/log.txt")
subprocess.call(["adb logcat"], stdout=f)
f_read = f.read()
print f_read
但我得到错误
File "testPython.py", line 198, in getadbLogs
subprocess.call(["adb logcat"], stdout=f)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
**OSError: [Errno 2] No such file or directory**
我不确定我做错了什么。是否可以使用子进程获取 adb logcat 日志?我检查了文件路径是否正确。
【问题讨论】:
标签: android python python-2.7 subprocess logcat