ios 常用命令封装
tidevice安装:pip3 install tidevice
ideviceinstaller安装: 1.brew install --HEAD libimobiledevice
2.brew install ideviceinstaller
import os
class IOS:
def __init__(self, log):
self.log = log
def getdeviceslist(self)->list:
"""获取设备列表"""
all_devices = []
cmd = "tidevice list"
reslut = os.popen(cmd).readlines()
for item in reslut:
if item != "\n":
all_devices.append(str(item).split("\t")[0].split(' ')[0])
return all_devices
def isinstallipa(self, packname: str, devices: str) -> bool:
"""
是否安装ipa包
:param packname: ipa包 路径
:param devices: 设备ID
:return:
"""
cmd = "tidevice --udid {} applist".format(devices)
reslut = os.popen(cmd).readlines()
all_apkname = []
for i in reslut:
apkname = str(i).split(' ')[0]
all_apkname.append(apkname)
if packname in all_apkname:
return True
return False
def uninstallipa(self, packname: str, devices: str) -> bool:
"""
卸载
:param packname: ipa包 路径
:param devices: 设备ID
:return:
"""
reslut = self.isinstallipa(packname, devices)
if reslut:
cmd = 'tidevice --udid %s uninstall %s ' % (devices, packname)
os.system(cmd)
return True
return False
def installipa(self, paknamepath: str, devices: str) -> bool:
"""
安装
:param paknamepath: ipa包 路径
:param devices: 设备ID
:return:
"""
cmd = 'tidevice --udid %s install %s' % (devices, paknamepath)
os.system(cmd)
return True
def get_uuid(self):
"""获取uuid"""
return str(os.popen('idevice_id -l').read()).replace("\n", "")
def get_platform_version(self):
"""获取设备信息"""
return str(os.popen('ideviceinfo -k ProductVersion').read()).replace("\n", "")
def get_device_name(self):
""""""
UDID = self.get_uuid()
device_name = os.popen('ideviceinfo -u %s -k DeviceName' % (UDID)).read()
return str(device_name).replace("\n", "")
学习最大的乐趣在于分享,我是绝世老中医,欢迎来诊
个人qq:1978529954