ifuse挂载后,在python代码中访问iOS沙盒目录获取app日志

上一次使用pymobiledevice3,在python代码中访问app的沙盒目录并分析业务日志,在使用过程中发现,在获取app日志的时候速度很慢,执行时间很长,需要30-61秒,所以这次尝试使用libimobiledevic和ifuse,现在已经将iOS沙盒目录挂载到了本地,在python代码中访问并分析日志:

python 复制代码
def get_dev_play_state_through_libimobiledevice(iphone_model, sn, state, log_date):
    """
    :param iphone_model: iPhone型号,例如,iPhoneX,本地根据手机型号创建挂载目录
    :param sn: 设备sn
    :param state: 不同开流状态,例如,wakeS1234、awake success、p4pS1234、p4pE12、previewS1234、previewS123456
    :param log_date: 日志日期,例如,20241028
    :return:
    """
    filter_condition = f"'{state} success.*deviceId = {sn}'"
    mount_path = f"/Users/testmanzhang/ios_sandbox/{iphone_model}/Documents/Logs/1234567_app_ios_{log_date}.log"
    command = f"grep {filter_condition} {mount_path}"

    result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
    print(result.stdout)

响应速度相对于pymobiledevice3快很多。时间大概在1-6秒左右。在ifuse同步周期内,首次访问文件内容会稍微慢些,大概6秒左右;周期内第2次开始会快些,大概1秒左右。

有个问题需要注意的是,mac锁屏再解锁后之前的挂载关系报错,There was an error accessing the mount point: Input/output error,

需要重新挂载:

testmanzhang@TestMandeMBP ~ % ifuse ~/ios_sandbox/iPhoneX --container com.glazero.ios --udid f89d929e8c45a81c0fe2d22f80c1a36e227e90ef

There was an error accessing the mount point: Input/output error

testmanzhang@TestMandeMBP ~ % umount ~/ios_sandbox/iPhoneX

testmanzhang@TestMandeMBP ~ % mount | grep ios_sandbox

testmanzhang@TestMandeMBP ~ % ifuse ~/ios_sandbox/iPhoneX --container com.glazero.ios --udid f89d929e8c45a81c0fe2d22f80c1a36e227e90ef

testmanzhang@TestMandeMBP ~ %

相关推荐
Storynone16 分钟前
【Day29】LeetCode:62. 不同路径,63. 不同路径 II,343. 整数拆分,96. 不同的二叉搜索树
python·算法·leetcode
chushiyunen22 分钟前
python语法-继承、方法命名、单例等
开发语言·python
咚咚王者22 分钟前
人工智能之语言领域 自然语言处理 第十八章 Python NLP生态
人工智能·python·自然语言处理
码路飞23 分钟前
AI 写的代码越来越多,但你敢直接上线吗?我的多模型交叉 Review 方案
python·openai
MgArcher25 分钟前
Python 入门核心考点:数据类型与变量全解
python
m0_6625779728 分钟前
自动化机器学习(AutoML)库TPOT使用指南
jvm·数据库·python
q_354888515333 分钟前
计算机毕业设计源码:Python动漫智能推荐与可视化分析系统 Django框架 协同过滤推荐算法 可视化 数据分析 大数据 大模型(建议收藏)✅
python·scrapy·数据分析·django·课程设计·旅游·推荐算法
与虾牵手33 分钟前
写了 8 年 Python 转 Rust,我被所有权机制折磨了整整一周
python
sqyno1sky41 分钟前
机器学习模型部署:将模型转化为Web API
jvm·数据库·python
何政@1 小时前
通过python 快速完成ai 构建
人工智能·python·ai·大模型·love l