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

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手机前期设置的小伙伴们,请关注我。
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值