Error prevention mechanisms added

This commit is contained in:
Kevin Rode 2019-10-03 13:36:02 -04:00
parent 71f67b709a
commit 2680ddca0a
2 changed files with 33 additions and 20 deletions

View File

@ -12,7 +12,6 @@ def recovery_boot():
else: else:
device = root.adb_connect() device = root.adb_connect()
root.twrp_download(device) root.twrp_download(device)
root.push_files(device)
root.reboot_bootloader() root.reboot_bootloader()
adb = "platform-tools\\adb.exe" adb = "platform-tools\\adb.exe"
fastboot = "platform-tools\\fastboot.exe" fastboot = "platform-tools\\fastboot.exe"
@ -20,6 +19,15 @@ def recovery_boot():
for file in files: for file in files:
if "twrp" in file: if "twrp" in file:
twrp = file twrp = file
else:
twrploc = 0
while twrploc == 0:
input("TWRP not found. Please ensure it is in the correct location and press enter to continue. ")
files = os.listdir(os.curdir)
for file in files:
if "twrp" in file:
twrp = file
twrploc = 1
os.system(fastboot + " boot "+twrp) os.system(fastboot + " boot "+twrp)
input("Press Enter when TWRP has booted") input("Press Enter when TWRP has booted")
@ -44,7 +52,8 @@ def download_app(o=None):
else: else:
os.system(adb+" pull /sdcard/"+app) os.system(adb+" pull /sdcard/"+app)
else: else:
os.makedirs(o) if os.path.isdir(o) == False:
os.makedirs(o)
os.system(adb+" pull /sdcard/"+app+" "+o) os.system(adb+" pull /sdcard/"+app+" "+o)

View File

@ -36,24 +36,28 @@ def twrp_download(d):
for i in urls: for i in urls:
if "img" in i: if "img" in i:
downloads.append(i) downloads.append(i)
url_to_download = "https://dl.twrp.me"+downloads[0] url_to_download = "https://dl.twrp.me"+downloads[0]
url_to_download = url_to_download.replace('.html', '') url_to_download = url_to_download.replace('.html', '')
s = requests.Session() s = requests.Session()
s.headers.update({'referer':url_to_download}) s.headers.update({'referer':url_to_download})
img = s.get(url_to_download) img = s.get(url_to_download)
with open("twrp.img",'wb') as f: with open("twrp.img",'wb') as f:
f.write(img.content) f.write(img.content)
files = os.listdir(os.curdir) files = os.listdir(os.curdir)
for file in files: for file in files:
if "twrp" in file: if "twrp" in file:
found = 1 found = 1
while found != 1: while found != 1:
print("File not found. Please confirm it has been moved to the correct directory") print("File not found. Please confirm it has been moved to the correct directory")
input("Press Enter to continue...") input("Press Enter to continue...")
files = os.listdir(os.curdir) files = os.listdir(os.curdir)
for file in files: for file in files:
if "twrp" in file: if "twrp" in file:
found = 1 found = 1
else:
print("Error. Returning to the main menu")
time.sleep(2)
else: else:
print("twrp already downloaded") print("twrp already downloaded")