做外國網(wǎng)用哪些網(wǎng)站小廣告網(wǎng)頁
上一次使用pymobiledevice3,在python代碼中訪問app的沙盒目錄并分析業(yè)務日志,在使用過程中發(fā)現(xiàn),在獲取app日志的時候速度很慢,執(zhí)行時間很長,需要30-61秒,所以這次嘗試使用libimobiledevic和ifuse,現(xiàn)在已經(jīng)將iOS沙盒目錄掛載到了本地,在python代碼中訪問并分析日志:
def get_dev_play_state_through_libimobiledevice(iphone_model, sn, state, log_date):""":param iphone_model: iPhone型號,例如,iPhoneX,本地根據(jù)手機型號創(chuàng)建掛載目錄:param sn: 設備sn:param state: 不同開流狀態(tài),例如,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同步周期內(nèi),首次訪問文件內(nèi)容會稍微慢些,大概6秒左右;周期內(nèi)第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 ~ %?