diff --git a/helpers/extract.py b/helpers/extract.py index fc25fb2..56562b8 100644 --- a/helpers/extract.py +++ b/helpers/extract.py @@ -12,7 +12,6 @@ def recovery_boot(): else: device = root.adb_connect() root.twrp_download(device) - root.push_files(device) root.reboot_bootloader() adb = "platform-tools\\adb.exe" fastboot = "platform-tools\\fastboot.exe" @@ -20,6 +19,15 @@ def recovery_boot(): for file in files: if "twrp" in 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) input("Press Enter when TWRP has booted") @@ -44,7 +52,8 @@ def download_app(o=None): else: os.system(adb+" pull /sdcard/"+app) else: - os.makedirs(o) + if os.path.isdir(o) == False: + os.makedirs(o) os.system(adb+" pull /sdcard/"+app+" "+o) diff --git a/helpers/root.py b/helpers/root.py index 0d8598c..d5fd821 100644 --- a/helpers/root.py +++ b/helpers/root.py @@ -36,24 +36,28 @@ def twrp_download(d): for i in urls: if "img" in i: downloads.append(i) - url_to_download = "https://dl.twrp.me"+downloads[0] - url_to_download = url_to_download.replace('.html', '') - s = requests.Session() - s.headers.update({'referer':url_to_download}) - img = s.get(url_to_download) - with open("twrp.img",'wb') as f: - f.write(img.content) - files = os.listdir(os.curdir) - for file in files: - if "twrp" in file: - found = 1 - while found != 1: - print("File not found. Please confirm it has been moved to the correct directory") - input("Press Enter to continue...") - files = os.listdir(os.curdir) - for file in files: - if "twrp" in file: - found = 1 + url_to_download = "https://dl.twrp.me"+downloads[0] + url_to_download = url_to_download.replace('.html', '') + s = requests.Session() + s.headers.update({'referer':url_to_download}) + img = s.get(url_to_download) + with open("twrp.img",'wb') as f: + f.write(img.content) + files = os.listdir(os.curdir) + for file in files: + if "twrp" in file: + found = 1 + while found != 1: + print("File not found. Please confirm it has been moved to the correct directory") + input("Press Enter to continue...") + files = os.listdir(os.curdir) + for file in files: + if "twrp" in file: + found = 1 + else: + print("Error. Returning to the main menu") + time.sleep(2) + else: print("twrp already downloaded")