python - 如何运行 stop logcat 一段时间或检测某些关键字
问题描述
我希望编写一个脚本来完成某些工作。
我遇到的问题是logcat
我的状况并没有停止。
logcat
我的意图是在它运行一段时间后停止,或者计算机从日志中检测到一个关键短语。
time.sleep()
我尝试通过在命令下方放置 a 来使用时间限制方法,logcat
但显然该过程logcat
永远停留在它下面的任何代码都没有执行。所以我尝试-d time
放入the adb shell logcat
. 但是无论-d
我输入什么值,它下面的代码都会立即执行。另一种方法是在日志中出现某些短语时停止,
logcat
但我不知道该怎么做。
任何人都可以帮忙吗?
import os
import subprocess
import time
file_directory =r"D:\A.LXR\ns-test\record_SinglePointTV-45du_5m_45_Midea-NS_adult_normal_guan-bi-zuo-you-bai-feng_25_25.wav"
file_name ='in_2021-23-02_15-45-22.pcm.wav'
push_command = 'adb push '+file_directory
push_command = os.path.join(push_command,file_name)
push_command = push_command+' /sdcard/'+file_name
test_command = 'adb shell am broadcast -a start_feed --es path /sdcard/'+file_name
print('pushing audio')
subprocess.call(push_command)
subprocess.Popen('adb shell logcat -c')
print('recording the logs')
return_log = subprocess.call(r"adb shell logcat -d 50000 -f > D:\A.LXR\ns-test\record_SinglePointTV-45du_5m_45_Midea-NS_adult_normal_guan-bi-zuo-you-bai-feng_25_25.wav\in_2021-23-02_15-45-22.log", shell = True)
subprocess.call(test_command)
# time.sleep(5)
subprocess.Popen('adb shell killall -2 logcat')
print('stop recording logs')
print('extracting sliced audio')
subprocess.Popen(r'adb pull /sdcard/speech/* > D:\A.LXR\ns-test')
subprocess.Popen('adb shell rm -f -r /sdcard/speech/*')
谢谢
解决方案
推荐阅读
- html - 如何控制元素周围的 div 或框
- web-services - 在 Go 中使用 Channels 重定向
- r - R中的时间序列没有得到预期的索引日期格式
- angular - 角度 6 中的滑块
- angular - Angular RxJS 最佳实践根据之前的结果订阅多个 http 请求
- scala - 如何从长度大于 Scala Long 的任意整数创建 Scala BigInt?
- powerbi - Power BI Visual 使用日期切片器的一侧
- django - DjangoREST 使用过滤注释相关条目的计数
- javascript - 单击链接时如何关闭/隐藏全屏菜单/导航
- javascript - 显示游戏选项然后比较