python实现VTS和CTS-ON-GSI自动flash system.img脚本

Delfina ·
更新时间:2024-11-10
· 559 次阅读

import os import time import sys import re from colorama import init init(autoreset=True) a = sys.argv[1] try: boot = sys.argv[2] except: boot = " " system = "system.img" def flashGsi(a, boot, sn, s): os.system("adb -s {} reboot bootloader".format(sn)) time.sleep(1) if a == "vts": os.system("fastboot flash boot {}".format(boot)) time.sleep(1) os.system("fastboot -w") else: os.system("fastboot -w") time.sleep(1) os.system("fastboot reboot fastboot") time.sleep(2) os.system("fastboot flash system {}".format(system)) time.sleep(5) os.system("fastboot reboot") print("\n") #output = '*'*int((s/2-37)) + "\033[0;32;40m\t{}:此设备刷GSI成功,正在重启中\033[0m".format(sn) + '*'*int((s/2-37)) print("#####\033[0;32;40m{}:此设备刷GSI成功,正在重启中\033[0m#####".format(sn).center(s, '*')) def getDevicesSn(): SN_list = [] device_info = os.popen('adb devices').read() for line in device_info.splitlines(): if line == 'List of devices attached': continue else: com = re.compile('(.*?)\tde.*?') SN = re.findall(com, line) for i in SN: SN_list.append(i) return SN_list if __name__ == '__main__': width = os.get_terminal_size().columns sn = getDevicesSn() for i in sn: print("\n"+ "#####\033[0;32;40m{}:此设备正在刷GSI,请稍等!\033[0m#####".format(i).center(width, '*')) flashGsi(a, boot, i, width) time.sleep(10) print("\n"+ "#####\033[0;32;40m共{}台手机刷GSI完成!\033[0m#####".format(len(sn)).center(width, '*')) time.sleep(2) if a == 'gsi': print("\n"+ "#####\033[0;31;40m请手动点击Allow USB debugging弹框\033[0m#####".center(width)) time.sleep(75) os.system("python3 setting.py") time.sleep(1) os.system("python3 auto_media_push.py") else: time.sleep(75) os.system("python3 setting.py") 想了解,flash system.img开机后,VTS和CTS-on-GSI手机前期设置的小伙伴们,请关注我。
作者:ZT_小天



cts img flash system Python

需要 登录 后方可回复, 如果你还没有账号请 注册新账号