SHOW:
|
|
- or go back to the newest paste.
| 1 | - | #!/usr/bin/python |
| 1 | + | #!/usr/bin/env python |
| 2 | - | ### HALF-ASSED ONE + ONE TOOLKIT v1.3b BETA BLOCKERS |
| 2 | + | ### HALF-ASSED ONE + ONE TOOLKIT |
| 3 | - | ##### AUTHOR: vvn |
| 3 | + | ##### VERSION: 1.3.1 STABLE |
| 4 | - | ##### RELEASE DATE: AUGUST 26, 2014 |
| 4 | + | ##### RELEASE DATE: SEPTEMBER 13, 2014 |
| 5 | - | ##### REQUIREMENTS: Python 2.7, Android SDK (or at minimum, adb and fastboot), pyadb.py library |
| 5 | + | ##### AUTHOR: vvn [eudemonics on xda-developers] |
| 6 | ##### DESCRIPTION: a spontaneously created but hopefully comprehensive Android toolkit, | |
| 7 | ##### built originally for the OnePlus One but can be used with most Android devices | |
| 8 | ##### (DO NOT FLASH INCLUDED ONEPLUS ONE DEVICE FILES ON OTHER DEVICES!), that will or | |
| 9 | - | ##### PYTHON SCRIPTS AVAILABLE FOR DOWNLOAD ON MY SITE: |
| 9 | + | ##### will not be irregularly maintained at the developer's whim. |
| 10 | - | ##### notworth (dot) it /opo/opotoolkit.py -AND- notworth (dot) it /opo/pyadb.py |
| 10 | + | ##### REQUIREMENTS: Python 2.7, Android SDK tools, USB drivers, pyadb.py library, opointro.py |
| 11 | - | ##### until the github repo cooperates, check for latest updates on my pastebin: |
| 11 | + | |
| 12 | ##### HOLY SHIT I HAVE A README FILE! | |
| 13 | - | ### DOWNLOAD LINKS (piece 'em together if you're not a robot): |
| 13 | + | |
| 14 | - | ## PYTHON SCRIPTS AND ADB/FASTBOOT BINARIES: notworth (dot) it /opo/1plus1-halfassedtoolkit.zip |
| 14 | + | ##### source code for stable releases should be available on my pastebin: |
| 15 | - | ## SHA1(1plus1-halfassedtoolkit.zip)= c86bfba7da78a5a435adf01dd4e69c479f7d8d21 |
| 15 | + | |
| 16 | ################################################## | |
| 17 | - | import subprocess, sys, re, os, os.path, time, datetime, urllib, urllib2 |
| 17 | + | ################################################## |
| 18 | ##### USER LICENSE AGREEMENT & DISCLAIMER | |
| 19 | ##### copyright (C) 2014 vvn <[email protected]> | |
| 20 | - | def intro(): |
| 20 | + | ##### |
| 21 | ##### This program is FREE software: you can use it, redistribute it and/or modify | |
| 22 | - | print ("\033[41m\033[37;1m#################################################################\033[0m")
|
| 22 | + | ##### it as you wish. Copying and distribution of this file, with or without modification, |
| 23 | - | time.sleep(0.1) |
| 23 | + | ##### are permitted in any medium without royalty provided the copyright |
| 24 | - | print ("\033[41m\033[37;1m#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#\033[0m")
|
| 24 | + | ##### notice and this notice are preserved. This program is offered AS-IS, |
| 25 | - | time.sleep(0.1) |
| 25 | + | ##### WITHOUT ANY WARRANTY; without even the implied warranty of |
| 26 | - | print ("\033[41m\033[37;1m#~~~~~~~~~~~~~~~~~~~~~~ \033[40m\033[33;1mTHE HALF-ASSED\033[41m\033[37;1m ~~~~~~~~~~~~~~~~~~~~~~~~~#\033[0m")
|
| 26 | + | ##### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 27 | - | time.sleep(0.1) |
| 27 | + | ##### GNU General Public License for more details. |
| 28 | - | print ("\033[41m\033[37;1m#~~~~~~~~~~~~~~~~~~~~ \033[40m\033[33mONEPLUS ONE TOOLKIT\033[41m\033[37m ~~~~~~~~I\033[41m\033[37;1m 7~~~~~~~~~#\033[0m")
|
| 28 | + | ##### |
| 29 | - | time.sleep(0.1) |
| 29 | + | ##### For more information, please refer to the "LICENSE AND NOTICE" file that should |
| 30 | - | print ("\033[41m\033[37;1m#~~~~~~~~~~~~~~~~~~~~~~~~~ \033[41m\033[40;1mv1.3 BETA\033[41m\033[37;1m ~~~~~~~~~~~~~I 7~~~~~~~~~#\033[0m")
|
| 30 | + | ##### accompany all official download releases of this program. |
| 31 | - | time.sleep(0.1) |
| 31 | + | ################################################## |
| 32 | - | print ("\033[41m\033[37;1m#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I 7~~~~~~~~~#\033[0m")
|
| 32 | + | ################################################## |
| 33 | - | time.sleep(0.1) |
| 33 | + | ##### don't ask about the arbitrary versioning. i am totally making this shit up. |
| 34 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 77~~~~~I 7~~~#\033[0m")
|
| 34 | + | ##### getting credited for my work is nice. so are donations. |
| 35 | - | time.sleep(0.1) |
| 35 | + | ##### BTC: 1M511j1CHR8x7RYgakNdw1iF3ike2KehXh |
| 36 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 7~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I 7~~~~~~~~~#\033[0m")
|
| 36 | + | ##### https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=26PWMPCNKN28L |
| 37 | - | time.sleep(0.1) |
| 37 | + | ##### but to really show your appreciation, you should buy my EP instead! |
| 38 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 7~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I 7~~~~~~~~~#\033[0m")
|
| 38 | + | ##### you can stream and purchase it at: dreamcorp.bandcamp.com |
| 39 | - | time.sleep(0.1) |
| 39 | + | ##### (you might even enjoy listening to it) |
| 40 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 7~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I 7~~~~~~~~~#\033[0m")
|
| 40 | + | ##### questions, comments, feedback, bugs, complaints, death threats, marriage proposals? |
| 41 | - | time.sleep(0.1) |
| 41 | + | ##### contact me at: |
| 42 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 7~~~~~~~~~~I 7~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#\033[0m")
|
| 42 | + | ##### vvn (at) notworth (dot) it |
| 43 | - | time.sleep(0.2) |
| 43 | + | ##### latest version will always be available HERE: |
| 44 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 7~~~~~~~~~~~~~~~~I 7~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#\033[0m")
|
| 44 | + | ##### http://notworth.it/opo/opotoolkit.py |
| 45 | - | time.sleep(0.2) |
| 45 | + | ##### if above link is not able to download, use this one: |
| 46 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 7~~~~~~~~~~~~~~~~I 7~~~~~~~~~~~~~~~I 7~~~~~~~~~#\033[0m")
|
| 46 | + | ##### http://notworth.it/opo/opotoolkit.py.txt (rename from *.py.txt to *.py) |
| 47 | - | time.sleep(0.2) |
| 47 | + | ##### there be only code after this --> |
| 48 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 7~~~~~~~~~~~~~~~~I 7~~~~~~~~~~~~~~~I 7~~~~~~~~~#\033[0m")
|
| 48 | + | |
| 49 | - | time.sleep(0.2) |
| 49 | + | import subprocess, sys, re, os, os.path, time, datetime, urllib |
| 50 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 7~~~~~~~~~~~~~~~~I 7~~~~~~~~~~~~~~~I 7~~~~~~~~~#\033[0m")
|
| 50 | + | from opointro import * |
| 51 | - | time.sleep(0.1) |
| 51 | + | |
| 52 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 7~~~~~~~~~~~~~~~~I 7~~~~~~~~~~~~~~~I 7~~~~~~~~~#\033[0m")
|
| 52 | + | if os.name == 'nt' or sys.platform == 'win32': |
| 53 | - | time.sleep(0.1) |
| 53 | + | try: |
| 54 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 7~~~~~~~~~~~~~~~~I 7~~~~~~~~~~~~~~~I 7~~~~~~~~~#\033[0m")
|
| 54 | + | import colorama |
| 55 | - | time.sleep(0.1) |
| 55 | + | colorama.init() |
| 56 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 7~~~~~~~~~~~~~~~~I 7~~~~~~~~~~~~~~~I 7~~~~~~~~~#\033[0m")
|
| 56 | + | s = opointro() |
| 57 | - | time.sleep(0.1) |
| 57 | + | s.colorlogo() |
| 58 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 7~~~~~~~~~~I 7~~~~~~~~~I 7~~~~~~~~~#\033[0m")
|
| 58 | + | startmenu = s.colormenu |
| 59 | - | time.sleep(0.1) |
| 59 | + | except: |
| 60 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 7~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I 7~~~~~~~~~#\033[0m")
|
| 60 | + | try: |
| 61 | - | time.sleep(0.1) |
| 61 | + | import tendo.ansiterm |
| 62 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 7~~~~ SUPPORT MY WORK! BUY MY EP! ~~~I 7~~~~~~~~~#\033[0m")
|
| 62 | + | s = opointro() |
| 63 | - | time.sleep(0.1) |
| 63 | + | s.colorlogo() |
| 64 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 7~~ http://dreamcorp.bandcamp.com ~~~I 7~~~~~~~~~#\033[0m")
|
| 64 | + | startmenu = s.colormenu |
| 65 | - | time.sleep(0.1) |
| 65 | + | except: |
| 66 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 7~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I 7~~~~~~~~~#\033[0m")
|
| 66 | + | s = opointro() |
| 67 | - | time.sleep(0.1) |
| 67 | + | s.cleanlogo() |
| 68 | - | print ("\033[41m\033[37;1m#~~~~~~~~I 7~~~~~~~~~#\033[0m")
|
| 68 | + | startmenu = s.cleanmenu |
| 69 | - | time.sleep(0.1) |
| 69 | + | pass |
| 70 | - | print ("\033[41m\033[37;1m#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#\033[0m")
|
| 70 | + | else: |
| 71 | - | time.sleep(0.1) |
| 71 | + | s = opointro() |
| 72 | - | print ("\033[41m\033[37;1m#~~~~~~~~~~~~~~~~~~~~~~~~~ \033[40m\033[35;1mAUTHOR: VVN \033[41m\033[37;1m~~~~~~~~~~~~~~~~~~~~~~~~~#\033[0m")
|
| 72 | + | s.colorlogo() |
| 73 | - | time.sleep(0.1) |
| 73 | + | startmenu = s.colormenu |
| 74 | - | print ("\033[41m\033[37;1m#~~~~~~~~~~~~~~~~ \033[40m\033[36;1mRELEASE DATE: AUGUST 26, 2014 \033[41m\033[37;1m~~~~~~~~~~~~~~~~#\033[0m")
|
| 74 | + | |
| 75 | - | time.sleep(0.1) |
| 75 | + | def mainmenu(): |
| 76 | - | print ("\033[41m\033[37;1m#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#\033[0m")
|
| 76 | + | print(startmenu) |
| 77 | - | time.sleep(0.1) |
| 77 | + | |
| 78 | - | print ("\033[41m\033[37;1m#################################################################\033[0m")
|
| 78 | + | |
| 79 | - | time.sleep(4.5) |
| 79 | + | os.system('cls' if os.name == 'nt' else 'clear')
|
| 80 | - | print("\n\n")
|
| 80 | + | mainmenu() |
| 81 | ||
| 82 | global option | |
| 83 | - | """menu output user input""" |
| 83 | + | option = raw_input('Select an option 0-11 --> ')
|
| 84 | - | quotes = [ |
| 84 | + | |
| 85 | - | '\[email protected]\n' |
| 85 | + | while not re.search(r'^[0-9]$', option) and not re.search(r'^1[0-1]$', option): |
| 86 | - | ] |
| 86 | + | option = raw_input('Invalid selection. Please select an option 0-11 --> ')
|
| 87 | - | print ('''
|
| 87 | + | |
| 88 | - | \033[40m\033[34m***********************************************************\033[0m |
| 88 | + | |
| 89 | - | \033[40m\033[34m************ \033[36mTHE HALF-ASSED ONEPLUS ONE TOOLKIT \033[34m***********\033[0m |
| 89 | + | |
| 90 | - | \033[40m\033[34m*************** \033[37mVERSION: 1.3b BETA \033[34m* \033[35mby vvn \033[34m***************\033[0m |
| 90 | + | |
| 91 | - | \033[40m\033[34m***********************************************************\033[0m |
| 91 | + | |
| 92 | - | \033[40m\033[34m*** \033[33mthis is a FREE program, released AS-IS: NO WARRANTY \033[34m***\033[0m |
| 92 | + | |
| 93 | - | \033[40m\033[34m****************** \033[32mUSE AT YOUR OWN RISK! \033[34m******************\033[0m |
| 93 | + | |
| 94 | - | \033[40m\033[34m***********************************************************\033[0m |
| 94 | + | |
| 95 | - | \033[40m\033[34m*************** \033[37msupport my work: buy my EP! \033[34m***************\033[0m |
| 95 | + | |
| 96 | - | \033[40m\033[34m************** \033[37mhttp://dreamcorp.bandcamp.com \033[34m**************\033[0m |
| 96 | + | |
| 97 | - | \033[40m\033[34m***********************************************************\033[0m \n''') |
| 97 | + | |
| 98 | rbtype = "android" | |
| 99 | - | print("\033[33mDEVICE MUST BE CONNECTED VIA USB WITH ANDROID DEBUGGING ENABLED. \033[0m\n")
|
| 99 | + | |
| 100 | rbtype = "bootloader" | |
| 101 | - | print ('''\033[32mMAIN MENU:\033[0m
|
| 101 | + | |
| 102 | - | -\033[31m[1]\033[37m reboot into android, bootloader, or recovery\033[0m |
| 102 | + | |
| 103 | - | -\033[31m[2]\033[37m wipe device or flash partitions\033[0m |
| 103 | + | |
| 104 | - | -\033[31m[3]\033[37m boot once into custom recovery without flashing\033[0m |
| 104 | + | |
| 105 | - | -\033[31m[4]\033[37m install or uninstall APK\033[0m |
| 105 | + | |
| 106 | - | -\033[31m[5]\033[37m copy files between computer and device, or sync\033[0m |
| 106 | + | |
| 107 | - | -\033[31m[6]\033[37m backup or restore device\033[0m |
| 107 | + | |
| 108 | - | -\033[31m[7]\033[37m root device and/or install ZIP in fastboot\033[0m |
| 108 | + | |
| 109 | - | -\033[31m[8]\033[37m unlock bootloader and/or flash custom image\033[0m |
| 109 | + | |
| 110 | - | -\033[31m[9]\033[37m run shell command on device\033[0m |
| 110 | + | |
| 111 | - | -\033[31m[0]\033[37m quit \033[0m\n''') |
| 111 | + | |
| 112 | print("rebooting via fastboot..\n")
| |
| 113 | if rboption == '3': | |
| 114 | - | option = raw_input('Select an option 0-9 --> ')
|
| 114 | + | |
| 115 | obj.fastreboot(rbtype) | |
| 116 | - | while not re.search(r'^[0-9]$', option): |
| 116 | + | |
| 117 | - | option = raw_input('Invalid selection. Please select an option 0-9 --> ')
|
| 117 | + | |
| 118 | elif "unknown" in str(checkdev) and listdev is not None and "device" in str(fastdev): | |
| 119 | print("rebooting via ADB..\n")
| |
| 120 | obj.reboot(rbtype) | |
| 121 | time.sleep(0.9) | |
| 122 | main() | |
| 123 | elif "recovery" in [str(fastdev), str(listdev)] and checkdev is not None: | |
| 124 | print("rebooting via ADB...\n")
| |
| 125 | obj.reboot(rbtype) | |
| 126 | time.sleep(0.9) | |
| 127 | main() | |
| 128 | elif "unknown" in str(checkdev) and fastdev is not None and listdev is None: | |
| 129 | print("rebooting via fastboot...\n")
| |
| 130 | if rboption == '3': | |
| 131 | rbtype = "bootloader" | |
| 132 | obj.fastreboot(rbtype) | |
| 133 | time.sleep(0.9) | |
| 134 | main() | |
| 135 | elif "unknown" in str(checkdev) and "unauthorized" in str(listdev): | |
| 136 | raw_input("verify that DEVICE IS UNLOCKED and COMPUTER IS AUTHORIZED FOR ADB ACCESS, then press ENTER.")
| |
| 137 | print("rebooting via ADB...\n")
| |
| 138 | obj.reboot(rbtype) | |
| 139 | time.sleep(0.9) | |
| 140 | main() | |
| 141 | elif "unknown" in str(checkdev) and listdev is not None and fastdev is None: | |
| 142 | raw_input("device appears to be in recovery mode. reboot from recovery menu, then press ENTER.")
| |
| 143 | checkstate = obj.get_state() | |
| 144 | if "device" in str(checkstate): | |
| 145 | obj.reboot(rbtype) | |
| 146 | time.sleep(0.9) | |
| 147 | main() | |
| 148 | else: | |
| 149 | print("rebooting via fastboot....\n")
| |
| 150 | if rboption == '3': | |
| 151 | rbtype = "bootloader" | |
| 152 | fastreboot = obj.fastreboot(rbtype) | |
| 153 | if not fastreboot: | |
| 154 | print("rebooting via ADB after fastboot... \n")
| |
| 155 | obj.reboot(rbtype) | |
| 156 | if "error" in str(fastreboot): | |
| 157 | print("rebooting via fastboot second time...\n")
| |
| 158 | obj.fastreboot(rbtype) | |
| 159 | time.sleep(0.9) | |
| 160 | main() | |
| 161 | ||
| 162 | elif option == '2': #wipe | |
| 163 | print("\033[35m***WIPING SOME PARTITIONS WILL ERASE YOUR DATA.***\n please make sure to back up any important data before proceeding!\n\n")
| |
| 164 | print('''\033[36mCHOOSE AN OPTION 1-8:\033[32m\n
| |
| 165 | [1]\033[37m perform a full system wipe [system, data, and cache partitions]\033[32m | |
| 166 | [2]\033[37m wipe only the system partition\033[32m | |
| 167 | [3]\033[37m wipe only the data partition\033[32m | |
| 168 | [4]\033[37m wipe only the cache partition\033[32m | |
| 169 | [5]\033[37m wipe only the boot partition\033[32m | |
| 170 | [6]\033[37m wipe only the recovery partition\033[32m | |
| 171 | [7]\033[37m flash device to factory images [flash system, boot, and recovery]\033[32m | |
| 172 | [8]\033[37m return to main menu\n\n\033[0m''') | |
| 173 | confirmwipe = raw_input("please enter an option 1-8 --> ")
| |
| 174 | while not re.search(r'^[1-8]$', confirmwipe): | |
| 175 | confirmwipe = raw_input('not a valid option. please enter a selection between 1-8 from above choices -->')
| |
| 176 | if confirmwipe == '1': | |
| 177 | obj.wipe('all')
| |
| 178 | raw_input("press ENTER to continue.")
| |
| 179 | time.sleep(0.9) | |
| 180 | main() | |
| 181 | elif confirmwipe == '2': | |
| 182 | obj.wipe('system')
| |
| 183 | raw_input("press ENTER to continue.")
| |
| 184 | time.sleep(0.9) | |
| 185 | main() | |
| 186 | elif confirmwipe == '3': | |
| 187 | obj.wipe('data')
| |
| 188 | raw_input("press ENTER to continue.")
| |
| 189 | time.sleep(0.9) | |
| 190 | main() | |
| 191 | elif confirmwipe == '4': | |
| 192 | obj.wipe('cache')
| |
| 193 | raw_input("press ENTER to continue.")
| |
| 194 | time.sleep(0.9) | |
| 195 | main() | |
| 196 | elif confirmwipe == '5': | |
| 197 | obj.wipe('boot')
| |
| 198 | raw_input("press ENTER to continue.")
| |
| 199 | time.sleep(0.9) | |
| 200 | main() | |
| 201 | elif confirmwipe == '6': | |
| 202 | obj.wipe('recovery')
| |
| 203 | raw_input("press ENTER to continue.")
| |
| 204 | time.sleep(0.9) | |
| 205 | main() | |
| 206 | elif confirmwipe == '7': | |
| 207 | obj.wipe('flashall')
| |
| 208 | raw_input("press ENTER to continue.")
| |
| 209 | time.sleep(0.9) | |
| 210 | main() | |
| 211 | elif confirmwipe == '8': | |
| 212 | time.sleep(0.9) | |
| 213 | main() | |
| 214 | else: | |
| 215 | print("there was a problem connecting to the device. returning to menu..\n")
| |
| 216 | time.sleep(0.9) | |
| 217 | main() | |
| 218 | ||
| 219 | ||
| 220 | elif option == '3': #boot custom recovery | |
| 221 | recovery = raw_input("enter 1 for TWRP, 2 for ClockworkMod, or 3 for Philz recovery --> ")
| |
| 222 | while not re.search(r'^[1-3]$', recovery): | |
| 223 | recovery = raw_input("invalid selection. please choose 1 for TWRP, 2 for CWM, or 3 for Philz --> ")
| |
| 224 | def dlrecov(recovfile): | |
| 225 | dlfile = "http://notworth.it/opo/" + recovfile | |
| 226 | dl = urllib.URLopener() | |
| 227 | dl.retrieve(dlfile, recovfile) | |
| 228 | site = urllib.urlopen(dlfile) | |
| 229 | meta = site.info() | |
| 230 | dlsize = meta.getheaders("Content-Length")[0]
| |
| 231 | fsize = os.path.getsize(recovfile) | |
| 232 | print("file size: \033[33m")
| |
| 233 | print(dlsize) | |
| 234 | print("\n\033[0mbytes downloaded: \033[33m")
| |
| 235 | print(fsize) | |
| 236 | print("\033[0m\n")
| |
| 237 | obj.reboot("bootloader")
| |
| 238 | if recovery == '1': | |
| 239 | recovfile = "twrp.img" | |
| 240 | while not os.path.isfile(recovfile): | |
| 241 | print("file \033[32mtwrp.img \033[0mnot found. attempting download...\n")
| |
| 242 | dlrecov(recovfile) | |
| 243 | print("file \033[32mtwrp.img \033[0mfound!\n")
| |
| 244 | raw_input("press ENTER to continue booting into TWRP..")
| |
| 245 | obj.bootimg("twrp.img")
| |
| 246 | elif recovery == '2': | |
| 247 | recovfile = "cwm.img" | |
| 248 | while not os.path.isfile(recovfile): | |
| 249 | print("file \033[32mcwm.img \033[0mnot found. attempting download...\n")
| |
| 250 | dlrecov(recovfile) | |
| 251 | print("file \033[32mcwm.img \033[0mfound!\n")
| |
| 252 | raw_input("press ENTER to continue booting into ClockworkMod Recovery..")
| |
| 253 | obj.bootimg("cwm.img")
| |
| 254 | elif recovery == '3': | |
| 255 | recovfile = "philz.img" | |
| 256 | while not os.path.isfile(recovfile): | |
| 257 | print("file \033[32mphilz.img \033[0mnot found. attempting download...\n")
| |
| 258 | dlrecov(recovfile) | |
| 259 | print("file \033[32mphilz.img \033[0mfound!\n")
| |
| 260 | raw_input("press ENTER to continue booting into Philz Recovery..")
| |
| 261 | obj.bootimg("philz.img")
| |
| 262 | else: | |
| 263 | print("unable to connect to device.\n")
| |
| 264 | ||
| 265 | raw_input("press ENTER to return to main menu..")
| |
| 266 | time.sleep(0.9) | |
| 267 | main() | |
| 268 | ||
| 269 | elif option == '4': #install or uninstall APK | |
| 270 | whichinstall = raw_input("please enter 1 to install, 2 to uninstall, or 3 to return to main menu. --> ")
| |
| 271 | while not re.search(r'^[1-3]$', whichinstall): | |
| 272 | whichinstall = raw_input("invalid selection. please enter 1 to install, 2 to uninstall, or 3 to return to main menu. --> ")
| |
| 273 | if not os.path.exists('apps'):
| |
| 274 | os.makedirs('apps')
| |
| 275 | if whichinstall == '1': | |
| 276 | getapk = raw_input("place the APK file to install in the \"apps\" subdirectory, then type the filename --> ")
| |
| 277 | apkfile = os.path.join('apps', getapk)
| |
| 278 | while not os.path.isfile(apkfile): | |
| 279 | print("\033[37mfile does not exist. please make sure the APK file is in the \"apps\" subdirectory.\033[0m\n")
| |
| 280 | getapk = raw_input("enter valid filename for the APK you want to install -->")
| |
| 281 | apkfile = os.path.join('apps', getapk)
| |
| 282 | print("installing \033[36m" + getapk + "\033[0m...")
| |
| 283 | obj.install(apkfile) | |
| 284 | raw_input("press ENTER to continue...")
| |
| 285 | time.sleep(0.9) | |
| 286 | main() | |
| 287 | ||
| 288 | if whichinstall == '2': | |
| 289 | getunapk = raw_input("please enter the complete path for the app you wish to uninstall --> ")
| |
| 290 | keepcheck = raw_input("would you like to keep your app data? Y or N --> ")
| |
| 291 | while not re.search(r'^[nyNY]$', keepcheck): | |
| 292 | keepcheck = raw_input("invalid selection. please enter Y to keep app data or N to erase --> ")
| |
| 293 | keepargs = "erase" | |
| 294 | uninstcmd = "pm uninstall " + getunapk | |
| 295 | if re.match(r'(?i)Y', keepcheck): | |
| 296 | keepargs = "keep" | |
| 297 | uninstcmd = "pm uninstall -k " + getunapk | |
| 298 | print("uninstalling \033[36m" + getunapk + "\033[0m...\n")
| |
| 299 | obj.uninstall(getunapk, keepargs) | |
| 300 | obj.shell(uninstcmd) | |
| 301 | raw_input("press ENTER to continue...")
| |
| 302 | time.sleep(0.9) | |
| 303 | main() | |
| 304 | ||
| 305 | if whichinstall == '3': | |
| 306 | main() | |
| 307 | ||
| 308 | else: | |
| 309 | print("could not connect to device.\n")
| |
| 310 | time.sleep(0.9) | |
| 311 | main() | |
| 312 | ||
| 313 | elif option == '5': #copy and/or sync between computer and device | |
| 314 | copytype = raw_input("to push file from computer to device, enter T. to pull file from device to computer, enter F. to sync, enter S --> ")
| |
| 315 | matchT = re.search(r'(?i)T', copytype) | |
| 316 | matchF = re.search(r'(?i)F', copytype) | |
| 317 | matchS = re.search(r'(?i)S', copytype) | |
| 318 | while not re.search(r'^[FfSsTt]$', copytype): | |
| 319 | copytype = raw_input("invalid option. please enter T to push file, F to pull file, or S to sync --> ")
| |
| 320 | ||
| 321 | if matchT: | |
| 322 | getpushfile = raw_input("please enter the file or directory you wish to copy as the RELATIVE path from the script location --> ")
| |
| 323 | while not os.path.exists(getpushfile): | |
| 324 | getpushfile = raw_input("file does not exist. please enter valid path --> ")
| |
| 325 | getpushremote = raw_input("please enter destination path for copied file(s) on the device --> ")
| |
| 326 | obj.push(getpushfile, getpushremote) | |
| 327 | raw_input("file transfer complete. press ENTER to continue...")
| |
| 328 | ||
| 329 | elif matchF: | |
| 330 | getpullfile = raw_input("please enter path for the file or directory on your device to copy --> ")
| |
| 331 | getpulllocal = raw_input("please enter the copy destination folder as a RELATIVE path from the script location --> ")
| |
| 332 | if not os.path.exists(getpulllocal): | |
| 333 | print("copy destination \033[35m" + getpulllocal + " \033[0mdoes not exist! creating new directory...")
| |
| 334 | os.makedirs(getpulllocal) | |
| 335 | obj.pull(getpullfile, getpulllocal) | |
| 336 | print("\033[32mtransferred file(s) in destination directory:\n")
| |
| 337 | for fn in next(os.walk(getpulllocal))[2]: | |
| 338 | fullpath = os.path.join(getpulllocal, fn) | |
| 339 | if os.path.getmtime(fullpath) >= os.path.getctime(getpulllocal): | |
| 340 | print(fullpath) | |
| 341 | print("\033[0m\n")
| |
| 342 | raw_input("file transfer complete. press ENTER to continue...")
| |
| 343 | ||
| 344 | elif matchS: | |
| 345 | syncargs = raw_input("enter 1 to set sync directory, or 2 to sync the default system and data directories. --> ")
| |
| 346 | while not re.search(r'^[12]$', syncargs): | |
| 347 | syncargs = raw_input("invalid selection. please enter 1 to set sync directory, or 2 to use default. --> ")
| |
| 348 | if syncargs == '1': | |
| 349 | syncdir = raw_input("please enter sync directory --> ")
| |
| 350 | localargs = raw_input("enter 1 to set local sync directory, or 2 to use default ANDROID_PRODUCT_OUT --> ")
| |
| 351 | while not re.search(r'^[12]$',localargs): | |
| 352 | localargs = raw_input("invalid selection. enter 1 to set local sync directory or 2 to use default ANDROID_PRODUCT_OUT --> ")
| |
| 353 | if localargs == '1': | |
| 354 | localdir = raw_input("please enter relative path for local directory to sync device --> ")
| |
| 355 | while not os.path.exists(localdir): | |
| 356 | print("the path you entered does not exist. would you like to create " + localdir + " as a new directory?\n")
| |
| 357 | crlocaldir = raw_input("enter 1 to create new directory or 2 to enter another location. --> ")
| |
| 358 | - | raw_input("file copy complete. press ENTER to continue...")
|
| 358 | + | while not re.search(r'^[12]$', crlocaldir): |
| 359 | crlocaldir = raw_input("invalid selection. please enter 1 to create directory, or 2 to enter another location. --> ")
| |
| 360 | if crlocaldir == '1': | |
| 361 | os.makedirs(localdir, 0755) | |
| 362 | else: | |
| 363 | localdir = raw_input("please enter relative path for local directory to sync device with --> ")
| |
| 364 | localsyncdir = os.path.join(localdir, syncdir) | |
| 365 | while not os.path.exists(localsyncdir): | |
| 366 | - | # obj.pull(getpullfile, getpulllocal) |
| 366 | + | os.makedirs(localsyncdir, 0755) |
| 367 | - | def getprogress(n): |
| 367 | + | print(localsyncdir + " created\n") |
| 368 | - | tenths = n/10 |
| 368 | + | |
| 369 | - | for i in range(n): |
| 369 | + | localdir = "none" |
| 370 | - | obj.pull(getpullfile, getpulllocal) |
| 370 | + | obj.sync(localdir, syncdir) |
| 371 | - | if i%tenths == 0: |
| 371 | + | if "none" not in localdir: |
| 372 | - | print(str(i) + "% ") |
| 372 | + | print("\033[32mfile(s) in sync directory:\n")
|
| 373 | - | sys.stdout.flush() |
| 373 | + | for fn in next(os.walk(localdir))[2]: |
| 374 | - | print("\n\033[0m ..TRANSFER COMPLETE!")
|
| 374 | + | fullpath = os.path.join(localdir, fn) |
| 375 | - | print("transferring files... \033[37m"),
|
| 375 | + | if os.path.getmtime(fullpath) >= os.path.getctime(localdir): |
| 376 | - | sys.stdout.flush() |
| 376 | + | print(fullpath) |
| 377 | - | getprogress(100) |
| 377 | + | print("\033[0m\n")
|
| 378 | - | print("\033[32mfile\(s\) in destination directory:\n\033[0m")
|
| 378 | + | |
| 379 | elif syncargs == '2': | |
| 380 | # obj.sync() | |
| 381 | - | print(fullpath) |
| 381 | + | localargs = raw_input("enter 1 to set local sync directory, or 2 to use default ANDROID_PRODUCT_OUT --> ")
|
| 382 | - | raw_input("file copy complete. press ENTER to continue...")
|
| 382 | + | while not re.search(r'^[12]$',localargs): |
| 383 | localargs = raw_input("invalid selection. enter 1 to set local sync directory or 2 to use default ANDROID_PRODUCT_OUT --> ")
| |
| 384 | if localargs == '1': | |
| 385 | localdir = raw_input("please enter relative path for local directory to sync device --> ")
| |
| 386 | while not os.path.exists(localdir): | |
| 387 | print("the path you entered does not exist. would you like to create " + localdir + " as a new directory?\n")
| |
| 388 | crlocaldir = raw_input("enter 1 to create new directory or 2 to enter another location. --> ")
| |
| 389 | - | syncdir = raw_input("please enter relative path for local directory to sync device with --> ")
|
| 389 | + | while not re.search(r'^[12]$', crlocaldir): |
| 390 | - | while not os.path.exists(syncdir): |
| 390 | + | crlocaldir = raw_input("invalid selection. please enter 1 to create directory, or 2 to enter another location. --> ")
|
| 391 | - | print("the path you entered does not exist. would you like to create " + syncdir + " as a new directory?\n")
|
| 391 | + | if crlocaldir == '1': |
| 392 | - | crsyncdir = raw_input("enter 1 to create new directory or 2 to enter another location. --> ")
|
| 392 | + | os.makedirs(localdir, 0755) |
| 393 | - | while not re.search(r'^[12]$', crsyncdir): |
| 393 | + | |
| 394 | - | crsyncdir = raw_input("invalid selection. please enter 1 to create directory, or 2 to enter another location. --> ")
|
| 394 | + | localdir = raw_input("please enter relative path for local directory to sync device with --> ")
|
| 395 | - | if crsyncdir == '1': |
| 395 | + | |
| 396 | - | os.makedirs(syncdir, 0755) |
| 396 | + | localdir = "none" |
| 397 | obj.sync(localdir, "none") | |
| 398 | - | syncdir = raw_input("please enter relative path for local directory to sync device with --> ")
|
| 398 | + | |
| 399 | - | obj.sync(syncdir) |
| 399 | + | |
| 400 | print("could not connect to device.\n")
| |
| 401 | ||
| 402 | - | obj.sync() |
| 402 | + | |
| 403 | print("could not connect to device.\n")
| |
| 404 | ||
| 405 | time.sleep(0.9) | |
| 406 | main() | |
| 407 | ||
| 408 | elif option == '6': #backup | |
| 409 | whichbackup = raw_input("to backup, enter 1. to restore, enter 2 --> ")
| |
| 410 | while not re.search(r'^[12]$', whichbackup): | |
| 411 | whichbackup = raw_input("invalid selection. please enter 1 to backup or 2 to restore. --> ")
| |
| 412 | if whichbackup == '1': | |
| 413 | fullbackup = raw_input("would you like to do a full backup, including system apps and sdcard contents? enter Y or N --> ")
| |
| 414 | while not re.search(r'^[yYnN]$', fullbackup): | |
| 415 | fullbackup = raw_input("invalid selection. please enter Y for full backup or N for other options --> ")
| |
| 416 | if fullbackup.lower() == 'y': | |
| 417 | backapk = "apk" | |
| 418 | backobb = "obb" | |
| 419 | - | obj.backup(backupfile) |
| 419 | + | backshared = "shared" |
| 420 | backall = "full" | |
| 421 | backsys = "sys" | |
| 422 | else: | |
| 423 | checkapk = raw_input("enter 1 to include APK files, or 2 to exclude --> ")
| |
| 424 | while not re.search(r'^[12]$', checkapk): | |
| 425 | checkapk = raw_input("invalid selection. enter 1 to include APK files, or 2 to exclude --> ")
| |
| 426 | if checkapk == '1': | |
| 427 | backapk = "apk" | |
| 428 | checkobb = raw_input("enter 1 to include APK expansion files, or 2 to exclude --> ")
| |
| 429 | while not re.search(r'^[12]$', checkobb): | |
| 430 | checkobb = raw_input("invalid selection. enter 1 to include APK expansion files, or 2 to exclude --> ")
| |
| 431 | if checkobb == '1': | |
| 432 | backobb = "obb" | |
| 433 | else: | |
| 434 | backobb = "no" | |
| 435 | else: | |
| 436 | backapk = "no" | |
| 437 | checkshared = raw_input("enter 1 to backup sdcard [userdata] contents, or 2 to exclude --> ")
| |
| 438 | while not re.search(r'^[12]$', checkshared): | |
| 439 | checkshared = raw_input("invalid selection. enter 1 to backup sdcard contents, or 2 to exclude --> ")
| |
| 440 | if checkshared == '1': | |
| 441 | backshared = "shared" | |
| 442 | checkall = raw_input("enter 1 to backup all installed applications, or 2 to exclude --> ")
| |
| 443 | while not re.search(r'^[12]$', checkall): | |
| 444 | checkall = raw_input("invalid selection. enter 1 to backup all installed applications, or 2 to exclude --> ")
| |
| 445 | if checkall == '1': | |
| 446 | backall = "all" | |
| 447 | else: | |
| 448 | backall = "no" | |
| 449 | else: | |
| 450 | backshared = "no" | |
| 451 | backall = "all" | |
| 452 | checksys = raw_input("enter 1 to backup system apps, or 2 to exclude --> ")
| |
| 453 | while not re.search(r'^[12]$',checksys): | |
| 454 | checksys = raw_input("invalid selection. enter 1 to backup system apps, or 2 to exclude --> ")
| |
| 455 | if checksys == '1': | |
| 456 | backsys = "sys" | |
| 457 | else: | |
| 458 | backsys = "no" | |
| 459 | backupfile = 'backup-' + str(datetime.date.today()) + '.ab' | |
| 460 | raw_input("to continue with backup, press ENTER. then check device and follow prompts to continue. the backup process may take awhile.")
| |
| 461 | obj.backup(backupfile, backapk, backobb, backshared, backall, backsys) | |
| 462 | raw_input("backup complete! backup file saved as: \033[35m" + backupfile + "\033[0m. press ENTER to return to main menu.")
| |
| 463 | elif whichbackup == '2': | |
| 464 | restorefile = raw_input("please enter path to backup file on your computer [ex. \'backup-yyyy-mm-dd.ab\'] --> ")
| |
| 465 | while not os.path.isfile(restorefile): | |
| 466 | restorefile = raw_input("file does not exist. please enter valid path --> ")
| |
| 467 | obj.restore(restorefile) | |
| 468 | raw_input("restore complete! press ENTER to reboot and continue..")
| |
| 469 | obj.reboot("android")
| |
| 470 | else: | |
| 471 | print("unable to connect to device. returning to main menu..")
| |
| 472 | time.sleep(0.9) | |
| 473 | - | superSU = 'UPDATE-SuperSU-v2.02.zip' |
| 473 | + | |
| 474 | ||
| 475 | - | URLsuperSU = "http://download.chainfire.eu/452/SuperSU/UPDATE-SuperSU-v2.02.zip?retrieve_file=1" |
| 475 | + | |
| 476 | ||
| 477 | def twrpdl(): # DOWNLOAD TWRP CUSTOM RECOVERY | |
| 478 | TWRPurl = "http://notworth.it/opo/twrp.img" | |
| 479 | dl = urllib.URLopener() | |
| 480 | dl.retrieve(TWRPurl, "twrp.img") | |
| 481 | site = urllib.urlopen(TWRPurl) | |
| 482 | meta = site.info() | |
| 483 | dlsize = meta.getheaders("Content-Length")[0]
| |
| 484 | fsize = os.path.getsize("twrp.img")
| |
| 485 | print("file size: \033[33m")
| |
| 486 | print(dlsize) | |
| 487 | print("\n\033[0mbytes downloaded: \033[33m")
| |
| 488 | print(fsize) | |
| 489 | print("\033[0m\n")
| |
| 490 | ||
| 491 | def recovdl(recovimg): # DOWNLOAD IMAGE FROM SITE | |
| 492 | recovurl = "http://notworth.it/opo/" + recovimg | |
| 493 | dl = urllib.URLopener() | |
| 494 | dl.retrieve(recovurl, recovimg) | |
| 495 | site = urllib.urlopen(recovurl) | |
| 496 | meta = site.info() | |
| 497 | dlsize = meta.getheaders("Content-Length")[0]
| |
| 498 | fsize = os.path.getsize(recovimg) | |
| 499 | print("file size: \033[33m")
| |
| 500 | print(dlsize) | |
| 501 | print("\n\033[0mbytes downloaded: \033[33m")
| |
| 502 | print(fsize) | |
| 503 | print("\033[0m\n")
| |
| 504 | ||
| 505 | def chooserec(): # CHOOSE WHICH CUSTOM RECOVERY TO BOOT INTO ONCE | |
| 506 | - | remotesuperSU = '/sdcard/UPDATE-SuperSU-v2.02.zip' |
| 506 | + | |
| 507 | pickrecov = raw_input("press 1 to flash superSU in TWRP Recovery, 2 to use Philz Recovery, or 3 to use CWM. --> ")
| |
| 508 | while not re.search(r'^[123]$', pickrecov): | |
| 509 | pickrecov = raw_input("invalid selection. press 1 to flash superSU in TWRP Recovery, 2 for Philz, or 3 for CWM. --> ")
| |
| 510 | if pickrecov == '1': # SUPERSU TWRP | |
| 511 | recovimg = "twrp.img" | |
| 512 | elif pickrecov == '2': # SUPERSU PHILZ | |
| 513 | recovimg = "philz.img" | |
| 514 | elif pickrecov == '3': # SUPERSU CWM | |
| 515 | recovimg = "cwm.img" | |
| 516 | else: | |
| 517 | print("unable to connect to device. returning to main menu..\n")
| |
| 518 | return recovimg | |
| 519 | ||
| 520 | superSU = 'UPDATE-SuperSU-v2.16.zip' | |
| 521 | def sudl(): # DOWNLOAD SUPERSU ZIP | |
| 522 | URLsuperSU = "http://download.chainfire.eu/452/SuperSU/UPDATE-SuperSU-v2.16.zip?retrieve_file=1" | |
| 523 | ||
| 524 | dl = urllib.URLopener() | |
| 525 | dl.retrieve(URLsuperSU, superSU) | |
| 526 | ||
| 527 | site = urllib.urlopen(URLsuperSU) | |
| 528 | meta = site.info() | |
| 529 | dlsize = meta.getheaders("Content-Length")[0]
| |
| 530 | fsize = os.path.getsize(superSU) | |
| 531 | print("file size: \033[33m")
| |
| 532 | print(dlsize) | |
| 533 | print("\n\033[0mbytes downloaded: \033[33m")
| |
| 534 | print(fsize) | |
| 535 | print("\033[0m\n")
| |
| 536 | if dlsize != fsize: | |
| 537 | with open(superSU, "r+b") as f: | |
| 538 | f.write(site.read()) | |
| 539 | f.flush() | |
| 540 | os.fsync(f.fileno()) | |
| 541 | f.close() | |
| 542 | ||
| 543 | def suroot(recovimg): | |
| 544 | while not os.path.isfile(superSU): | |
| 545 | print("file \033[32m" + superSU + " \033[0mnot found. attempting download...\n")
| |
| 546 | sudl() | |
| 547 | print("file \033[32m" + superSU + " \033[0mfound!\n")
| |
| 548 | while not os.path.isfile(recovimg): | |
| 549 | print("file \033[32m" + recovimg + " \033[0mnot found. attempting download...\n")
| |
| 550 | recovdl(recovimg) | |
| 551 | print("file \033[32m" + recovimg + " \033[0mfound!\n")
| |
| 552 | raw_input("press ENTER to copy file to device, then reboot into bootloader.")
| |
| 553 | remotesuperSU = '/sdcard/UPDATE-SuperSU-v2.16.zip' | |
| 554 | obj.push(superSU, remotesuperSU) | |
| 555 | obj.reboot("bootloader")
| |
| 556 | raw_input("press ENTER to boot into custom recovery.")
| |
| 557 | obj.bootimg(recovimg) | |
| 558 | print("check that device is connected and booted into custom recovery. on device, choose the ADB SIDELOAD option [sometimes under ADVANCED].\n")
| |
| 559 | raw_input("press ENTER to continue with flashing superSU file via ADB sideload.")
| |
| 560 | obj.sideload(superSU) | |
| 561 | sidefail = raw_input("if install failed, press 1 to attempt install from device. else, reboot into system from device recovery menu and press ENTER. --> ")
| |
| 562 | if sidefail == '1': | |
| 563 | print("on device recovery menu, choose INSTALL, then select file \033[36m" + superSU + "\033[0m from the \033[36m/SDCARD\033[0m root directory.\n")
| |
| 564 | raw_input("swipe to install - this may take a moment. if install is successful, select REBOOT from recovery menu. press ENTER to continue.")
| |
| 565 | obj.reboot("android")
| |
| 566 | ||
| 567 | superusr = 'Superuser-3.1.3-arm-signed.zip' | |
| 568 | def susrdl(): # DOWNLOAD SUPERUSER ZIP | |
| 569 | URLsuperusr = "http://notworth.it/opo/Superuser-3.1.3-arm-signed.zip" | |
| 570 | dl = urllib.URLopener() | |
| 571 | dl.retrieve(URLsuperusr, superusr) | |
| 572 | site = urllib.urlopen(URLsupusr) | |
| 573 | meta = site.info() | |
| 574 | dlsize = meta.getheaders("Content-Length")[0]
| |
| 575 | fsize = os.path.getsize(superusr) | |
| 576 | - | print("\033[36m\nif APK installed successfully, locate TR [towelroot] in app drawer on device and run.\n\033[0m")
|
| 576 | + | |
| 577 | print(dlsize) | |
| 578 | print("\n\033[0mbytes downloaded: \033[33m")
| |
| 579 | - | print("\033[36mif the firmware release date for your device is before june 2014, there is a chance the towelroot exploit may work.\n")
|
| 579 | + | |
| 580 | - | print("\033[35mhowever, superSU is a safer and more widely confirmed root method for the ONEPLUS ONE. ATTEMPT AT YOUR OWN RISK!\033[0m\n\n")
|
| 580 | + | |
| 581 | - | rootcheck = raw_input("which root method would you like to try? enter 1 for towelroot or 2 for superSU [recommended for oneplus one], or 3 for Superuser. --> ")
|
| 581 | + | |
| 582 | - | while not re.search(r'^[123]$', rootcheck): |
| 582 | + | |
| 583 | - | rootcheck = raw_input("invalid selection. enter 1 to install towelroot exploit, 2 to install superSU package, or 3 to install Superuser package. --> ")
|
| 583 | + | |
| 584 | print("file \033[32m" + superusr + " \033[0mnot found. attempting download...\n")
| |
| 585 | susrdl() | |
| 586 | print("file \033[32m" + superusr + " \033[0mfound!\n")
| |
| 587 | while not os.path.isfile(recovimg): | |
| 588 | print("file \033[32m" + recovimg + " \033[0mnot found. attempting download...\n")
| |
| 589 | recovdl(recovimg) | |
| 590 | print("file \033[32m" + recovimg + " \033[0mfound!\n")
| |
| 591 | raw_input("press ENTER to copy file to device and reboot into bootloader.")
| |
| 592 | remotesuperusr = '/sdcard/Superuser-3.1.3-arm-signed.zip' | |
| 593 | obj.push(superusr, remotesuperusr) | |
| 594 | obj.reboot("bootloader")
| |
| 595 | raw_input("press ENTER to boot into custom recovery.")
| |
| 596 | obj.bootimg(recovimg) | |
| 597 | print("on device, choose INSTALL from recovery menu, then select file \033[36m" + superusr + "\033[0m in the \033[36m/sdcard\033[0m directory.\n")
| |
| 598 | raw_input("if install is successful, select REBOOT from recovery menu on device. press ENTER to continue.")
| |
| 599 | ||
| 600 | trfile = 'apps/tr.apk' | |
| 601 | def trdl(): # DOWNLOAD TOWELROOT APK | |
| 602 | dl = urllib.URLopener() | |
| 603 | dl.retrieve("https://towelroot.com/tr.apk", trfile)
| |
| 604 | site = urllib.urlopen("https://towelroot.com/tr.apk")
| |
| 605 | meta = site.info() | |
| 606 | dlsize = meta.getheaders("Content-Length")[0]
| |
| 607 | fsize = os.path.getsize(trfile) | |
| 608 | print("file size: \033[33m")
| |
| 609 | print(dlsize) | |
| 610 | print("\033[0m\nbytes downloaded: \033[33m")
| |
| 611 | print(fsize) | |
| 612 | print("\033[0m\n")
| |
| 613 | ||
| 614 | def towroot(): # INSTALL TOWELROOT APK | |
| 615 | if not os.path.exists('apps'):
| |
| 616 | os.makedirs('apps', 0755)
| |
| 617 | while not os.path.isfile(trfile): | |
| 618 | print("file \033[32m" + trfile + " \033[0mnot found. attempting download...\n")
| |
| 619 | trdl() | |
| 620 | print("file \033[32m" + trfile + " \033[0mfound!\n")
| |
| 621 | raw_input("press ENTER to install..")
| |
| 622 | obj.install(trfile) | |
| 623 | obj.shell('am start -n com.geohot.towelroot/com.geohot.towelroot.TowelRoot')
| |
| 624 | - | obj.sideload("UPDATE-SuperSU-v2.02.zip")
|
| 624 | + | print("if APK installed successfully, it should automatically launch on your device.")
|
| 625 | raw_input("tap on MAKE IT RAIN. the results should appear shortly. follow instructions on device, then press ENTER to continue..")
| |
| 626 | ||
| 627 | print("\033[36mif the firmware release date for your device is before june 2014, there is a chance the towelroot exploit may work.")
| |
| 628 | print("\033[35mhowever, superSU is a safer and more widely confirmed root method for the ONEPLUS ONE. ATTEMPT AT YOUR OWN RISK!\033[0m\n")
| |
| 629 | rootcheck = raw_input("which root method would you like to try? enter 1 for towelroot, 2 for superSU [recommended for oneplus one], 3 for Superuser, or 4 to install custom ZIP file. --> ")
| |
| 630 | while not re.search(r'^[1-4]$', rootcheck): | |
| 631 | rootcheck = raw_input("invalid selection. enter 1 to install towelroot exploit, 2 to install superSU package, 3 to install Superuser, or 4 to install custom ZIP file. --> ")
| |
| 632 | ||
| 633 | if rootcheck == '1': # TOWELROOT | |
| 634 | towroot() | |
| 635 | trysuroot = raw_input("if towelroot failed, press 1 to launch superSU method. otherwise, press ENTER to return to main menu. --> ")
| |
| 636 | if trysuroot == '1': # SUPERSU | |
| 637 | recovimg = chooserec() | |
| 638 | suroot(recovimg) # SUPERSU CUSTOM RECOVERY | |
| 639 | time.sleep(0.9) | |
| 640 | main() | |
| 641 | else: | |
| 642 | time.sleep(0.9) | |
| 643 | main() | |
| 644 | ||
| 645 | elif rootcheck == '2': # SUPERSU | |
| 646 | bootcustom = raw_input("press 1 to install superSU in custom recovery, or 2 to install in fastboot [lower success rate]. --> ")
| |
| 647 | while not re.search(r'^[12]$', bootcustom): | |
| 648 | bootcustom = raw_input("invalid choice. please enter 1 to load custom recovery or 2 for fastboot. --> ")
| |
| 649 | if bootcustom == '1': # SUPERSU TWRP | |
| 650 | recovimg = chooserec() | |
| 651 | suroot(recovimg) # SUPERSU CUSTOM RECOVERY | |
| 652 | time.sleep(0.9) | |
| 653 | main() | |
| 654 | elif bootcustom == '2': # SUPERSU FASTBOOT | |
| 655 | updatewhich = raw_input("to try installing superSU in fastboot, press 1. else, enter name of ZIP file to install --> ")
| |
| 656 | if updatewhich == '1': # SUPERSU FASTBOOT | |
| 657 | while not os.path.isfile(superSU): | |
| 658 | print("file \033[32m" + superSU + " \033[0mnot found. attempting download...\n\n")
| |
| 659 | sudl() | |
| 660 | raw_input("press ENTER to reboot into bootloader.")
| |
| 661 | obj.reboot("bootloader")
| |
| 662 | print("\033[35mattempting to install superSU via fastboot...\n\033[0m")
| |
| 663 | obj.update(superSU) | |
| 664 | failsu = raw_input("if installation failed, press 1 to try sideload method. otherwise, press ENTER to continue...")
| |
| 665 | if failsu == '1': # SUPERSU SIDELOAD | |
| 666 | - | updatewhich = raw_input("to try installing Superuser in fastboot, press 1. else, enter name of ZIP file to install --> ")
|
| 666 | + | |
| 667 | - | if updatewhich == '1': |
| 667 | + | |
| 668 | - | while not os.path.isfile(superusr): |
| 668 | + | |
| 669 | - | print("file \033[32m" + superusr + " \033[0mnot found. attempting download...\n\n")
|
| 669 | + | |
| 670 | obj.reboot("recovery")
| |
| 671 | raw_input("in recovery menu on device, please select APPLY UPDATE, then APPLY FROM ADB. press ENTER when ready.")
| |
| 672 | obj.sideload("UPDATE-SuperSU-v2.16.zip")
| |
| 673 | - | print("\033[35mattempting to install Superuser via fastboot...\n\033[0m")
|
| 673 | + | |
| 674 | - | obj.update(superusr) |
| 674 | + | |
| 675 | if superfail == '1': # SUPERSU TWRP | |
| 676 | - | if failsu == '1': |
| 676 | + | |
| 677 | elif superfail == '2': # SUPERSU PHILZ | |
| 678 | suroot("philz.img")
| |
| 679 | else: | |
| 680 | obj.get_state() | |
| 681 | time.sleep(0.9) | |
| 682 | main() | |
| 683 | - | obj.sideload(superusr) |
| 683 | + | |
| 684 | - | superfail = raw_input("choose REBOOT SYSTEM from device menu. if update successful, press ENTER. else, press 1 to install Superuser via TWRP or 2 to install Superuser via Philz. --> " )
|
| 684 | + | |
| 685 | - | if superfail == '1': |
| 685 | + | |
| 686 | - | susrroot("twrp.img")
|
| 686 | + | |
| 687 | - | elif superfail == '2': |
| 687 | + | |
| 688 | - | susrroot("philz.img")
|
| 688 | + | |
| 689 | if failupd == '1': | |
| 690 | obj.fastreboot("android")
| |
| 691 | time.sleep(0.9) | |
| 692 | print("\033[32mmake sure your computer is authorized to access your device over ADB.\033[0m\n")
| |
| 693 | raw_input("press ENTER to continue..")
| |
| 694 | obj.reboot("recovery")
| |
| 695 | raw_input("in recovery menu on device, please select APPLY UPDATE, then APPLY FROM ADB. press ENTER when ready.")
| |
| 696 | obj.sideload(updatewhich) # CUSTOM SIDELOAD | |
| 697 | raw_input("please follow reboot prompts on device recovery menu, then press ENTER to continue...")
| |
| 698 | - | obj.update(updatewhich) |
| 698 | + | |
| 699 | - | raw_input("please press ENTER to continue...")
|
| 699 | + | |
| 700 | time.sleep(0.9) | |
| 701 | main() | |
| 702 | else: | |
| 703 | print("failed to connect to device. returning to main menu.. \n\n")
| |
| 704 | ||
| 705 | elif rootcheck == '3': # SUPERUSER or CUSTOM ZIP FILE | |
| 706 | bootcustom = raw_input("press 1 to install Superuser in TWRP recovery, 2 to install in Philz recovery, or 3 to install in fastboot [lowest success rate]. --> ")
| |
| 707 | while not re.search(r'^[123]$', bootcustom): | |
| 708 | bootcustom = raw_input("invalid choice. please enter 1 to load TWRP, 2 for Philz, or 3 for fastboot. --> ")
| |
| 709 | if bootcustom == '1': | |
| 710 | susrroot("twrp.img")
| |
| 711 | elif bootcustom == '2': | |
| 712 | susrroot("philz.img")
| |
| 713 | elif bootcustom == '3': | |
| 714 | while not os.path.isfile(superusr): | |
| 715 | print("file \033[32m" + superusr + " \033[0mnot found. attempting download...\n\n")
| |
| 716 | sudl() | |
| 717 | raw_input("press ENTER to reboot into bootloader.")
| |
| 718 | obj.reboot("bootloader")
| |
| 719 | print("\033[35mattempting to install Superuser via fastboot...\n\033[0m")
| |
| 720 | obj.update(superusr) | |
| 721 | failsu = raw_input("if installation failed, press 1 to try sideload method. otherwise, press ENTER to continue...")
| |
| 722 | if failsu == '1': | |
| 723 | obj.fastreboot("android")
| |
| 724 | time.sleep(0.9) | |
| 725 | print("\033[32mmake sure your computer is authorized to access your device over ADB.\033[0m\n")
| |
| 726 | raw_input("press ENTER to continue..")
| |
| 727 | obj.reboot("recovery")
| |
| 728 | raw_input("in recovery menu on device, please select APPLY UPDATE, then APPLY FROM ADB. press ENTER when ready.")
| |
| 729 | obj.sideload(superusr) | |
| 730 | - | flashsel = raw_input("invalid selection. please choose an option between 0 through 9 --> ")
|
| 730 | + | superfail = raw_input("choose REBOOT SYSTEM from device menu. if update successful, press ENTER. else, press 1 to install Superuser via TWRP or 2 to install Superuser via Philz. --> " )
|
| 731 | if superfail == '1': | |
| 732 | susrroot("twrp.img")
| |
| 733 | elif superfail == '2': | |
| 734 | susrroot("philz.img")
| |
| 735 | else: | |
| 736 | obj.get_state() | |
| 737 | time.sleep(0.9) | |
| 738 | main() | |
| 739 | ||
| 740 | elif rootcheck == '4': | |
| 741 | updatefile = raw_input("please enter path of ZIP file to install --> ")
| |
| 742 | while not os.path.isfile(updatefile): | |
| 743 | updatefile = raw_input("invalid file path. please enter correct path of ZIP file to install --> ")
| |
| 744 | raw_input("press ENTER to reboot into bootloader.")
| |
| 745 | obj.reboot("bootloader")
| |
| 746 | print("attempting to install " + updatefile + "...\n")
| |
| 747 | obj.update(updatefile) | |
| 748 | raw_input("press ENTER to continue...")
| |
| 749 | obj.fastreboot("android")
| |
| 750 | time.sleep(0.9) | |
| 751 | main() | |
| 752 | ||
| 753 | else: | |
| 754 | print("failed to connect to device. returning to main menu.. \n\n")
| |
| 755 | ||
| 756 | else: | |
| 757 | print("failed to connect to device. returning to main menu.. \n\n")
| |
| 758 | ||
| 759 | time.sleep(0.9) | |
| 760 | main() | |
| 761 | ||
| 762 | elif option == '8': #flash stock images/partitions | |
| 763 | ||
| 764 | def flashmenu(): | |
| 765 | print ('''\n\033[36mSTOCK IMAGES AVAILABLE TO FLASH - THIS WILL REPLACE YOUR CURRENT PARTITION!
| |
| 766 | \033[37mFLASH IN SEQUENTIAL ORDER IF POSSIBLE - BOOT.IMG SHOULD GO FIRST | |
| 767 | \033[33;1m***LATEST UPDATE FILES IN YELLOW***\n\033[0m | |
| 768 | -\033[31m[1]\033[37m XNPH25R stock BOOT.IMG \033[0m -or- \033[33m XNPH30O stock BOOT.IMG \033[0m | |
| 769 | -\033[31m[2]\033[37m XNPH25R stock USERDATA(_64).IMG \033[35m[WIPES USER DATA!]\033[0m | |
| 770 | -\033[31m[3]\033[37m XNPH25R stock SYSTEM.IMG \033[0m | |
| 771 | -\033[31m[4]\033[37m XNPH25R stock RECOVERY.IMG \033[0m | |
| 772 | -\033[31m[5]\033[37m XNPH25R stock CACHE.IMG \033[0m | |
| 773 | -\033[31m[6]\033[37m XNPH25R stock radio, modem, aboot, & more \033[34m[flash-radio.sh]\033[0m | |
| 774 | -\033[31m[7]\033[37m XNPH30O stock radio, modem, sbl1, aboot \033[34m[flash-extras.sh]\033[0m | |
| 775 | -\033[31m[8]\033[33m XNPH30O stock OTA UPDATES #1 and #2 \033[0m-or- \033[33;1mXNPH33R stock OTA UPDATE\033[0m | |
| 776 | -\033[31m[9]\033[37m FLASH ENTIRE STOCK OR CUSTOM ROM IMAGE \033[0m | |
| 777 | -\033[31m[0]\033[37m return to main menu\033[0m\n | |
| 778 | \033[35mCHECK THAT DEVICE IS UNLOCKED AND COMPUTER IS AUTHORIZED FOR ADB ACCESS.\n\033[0m''') | |
| 779 | ||
| 780 | flashsel = raw_input("\033[32mselect an option between 0 through 9 from menu \033[0m--> ")
| |
| 781 | while not re.search(r'^[0-9]$', flashsel): | |
| 782 | flashsel = raw_input("invalid selection. please choose an option between 0 through 9 --> ")
| |
| 783 | ||
| 784 | def dlimg(imgfile): | |
| 785 | dlfile = "http://notworth.it/opo/" + imgfile | |
| 786 | dl = urllib.URLopener() | |
| 787 | dl.retrieve(dlfile, imgfile) | |
| 788 | site = urllib.urlopen(dlfile) | |
| 789 | meta = site.info() | |
| 790 | dlsize = meta.getheaders("Content-Length")[0]
| |
| 791 | fsize = os.path.getsize(imgfile) | |
| 792 | print("file size: \033[33m")
| |
| 793 | print(dlsize) | |
| 794 | print("\n\033[0mbytes downloaded: \033[33m")
| |
| 795 | print(fsize) | |
| 796 | print("\033[0m\n")
| |
| 797 | ||
| 798 | if re.search(r'^[1-7]$', flashsel): | |
| 799 | print("\n\033[34mrebooting into bootloader...\033[0m\n")
| |
| 800 | obj.reboot("bootloader")
| |
| 801 | ||
| 802 | if flashsel == '1': | |
| 803 | whichboot = raw_input("enter 1 to flash boot.img from XNPH25R. enter 2 for boot.img from XNPH30O. --> ")
| |
| 804 | while not re.search(r'^[12]$', whichboot): | |
| 805 | whichboot = raw_input("invalid selection. enter 1 for XNPH25R boot.img, or 2 for XNPH30O boot.img --> ")
| |
| 806 | if whichboot == '1': | |
| 807 | imgfile = "XNPH25R/boot.img" | |
| 808 | while not os.path.isfile(imgfile): | |
| 809 | if not os.path.exists('XNPH25R'):
| |
| 810 | os.makedirs('XNPH25R', 0755)
| |
| 811 | print("downloading XNPH25R/boot.img...\n")
| |
| 812 | dlimg(imgfile) | |
| 813 | obj.flashf("boot", imgfile)
| |
| 814 | elif whichboot == '2': | |
| 815 | imgfile = "XNPH30O/boot.img" | |
| 816 | while not os.path.isfile(imgfile): | |
| 817 | if not os.path.exists('XNPH30O'):
| |
| 818 | os.makedirs('XNPH30O', 0755)
| |
| 819 | print("downloading XNPH30O/boot.img..\n")
| |
| 820 | dlimg(imgfile) | |
| 821 | obj.flashf("boot", imgfile)
| |
| 822 | else: | |
| 823 | print("an error has occurred. returning to flash menu..\n")
| |
| 824 | flashmenu() | |
| 825 | raw_input("press ENTER key to continue...")
| |
| 826 | flashmenu() | |
| 827 | ||
| 828 | elif flashsel == '2': | |
| 829 | whichsize = raw_input("IMPORTANT!! choose correct storage capacity: enter 1 for 16gb device, or 2 for 64gb device. --> ")
| |
| 830 | while not re.search(r'^[12]$', whichsize): | |
| 831 | whichsize = raw_input("invalid selection. enter 1 for 16gb device, or 2 for 64gb device. --> ")
| |
| 832 | if whichsize == '1': | |
| 833 | imgfile = "XNPH25R/userdata.img" | |
| 834 | while not os.path.isfile(imgfile): | |
| 835 | if not os.path.exists('XNPH25R'):
| |
| 836 | os.makedirs('XNPH25R', 0755)
| |
| 837 | print("downloading XNPH25R/userdata.img..\n")
| |
| 838 | dlimg(imgfile) | |
| 839 | obj.flashf("userdata", "XNPH25R/userdata.img")
| |
| 840 | elif whichsize == '2': | |
| 841 | imgfile = "XNPH25R/userdata_64G.img" | |
| 842 | while not os.path.isfile(imgfile): | |
| 843 | if not os.path.exists('XNPH25R'):
| |
| 844 | os.makedirs('XNPH25R', 0755)
| |
| 845 | print("downloading XNPH25R/userdata_64G.img..\n")
| |
| 846 | dlimg(imgfile) | |
| 847 | obj.flashf("userdata", "XNPH25R/userdata_64G.img")
| |
| 848 | else: | |
| 849 | print("ERROR: unable to connect to device.\n")
| |
| 850 | raw_input("press ENTER key to return to flash menu...")
| |
| 851 | flashmenu() | |
| 852 | ||
| 853 | elif flashsel == '3': | |
| 854 | imgfile = "XNPH25R/system.img" | |
| 855 | while not os.path.isfile(imgfile): | |
| 856 | if not os.path.exists('XNPH25R'):
| |
| 857 | os.makedirs('XNPH25R', 0755)
| |
| 858 | print("downloading XNPH25R/system.img..\n")
| |
| 859 | dlimg(imgfile) | |
| 860 | obj.flashf("system", "XNPH25R/system.img")
| |
| 861 | raw_input("press ENTER key to continue...")
| |
| 862 | flashmenu() | |
| 863 | ||
| 864 | elif flashsel == '4': | |
| 865 | imgfile = "XNPH25R/recovery.img" | |
| 866 | while not os.path.isfile(imgfile): | |
| 867 | if not os.path.exists('XNPH25R'):
| |
| 868 | os.makedirs('XNPH25R', 0755)
| |
| 869 | print("downloading XNPH25R/recovery.img..\n")
| |
| 870 | dlimg(imgfile) | |
| 871 | obj.flashf("recovery", "XNPH25R/recovery.img")
| |
| 872 | raw_input("press ENTER key to continue...")
| |
| 873 | flashmenu() | |
| 874 | ||
| 875 | elif flashsel == '5': | |
| 876 | imgfile = "XNPH25R/cache.img" | |
| 877 | while not os.path.isfile(imgfile): | |
| 878 | if not os.path.exists('XNPH25R'):
| |
| 879 | os.makedirs('XNPH25R', 0755)
| |
| 880 | print("downloading XNPH25R/cache.img..\n")
| |
| 881 | dlimg(imgfile) | |
| 882 | obj.flashf("cache", "XNPH25R/cache.img")
| |
| 883 | raw_input("press ENTER key to continue...")
| |
| 884 | flashmenu() | |
| 885 | ||
| 886 | elif flashsel == '6': | |
| 887 | if not os.path.exists('XNPH25R'):
| |
| 888 | os.makedirs('XNPH25R', 0755)
| |
| 889 | imgfile = "XNPH25R/flash-radio.sh" | |
| 890 | while not os.path.isfile("XNPH25R/flash-radio.sh"):
| |
| 891 | print("downloading XNPH25R/flash-radio.sh..\n")
| |
| 892 | dlimg("XNPH25R/flash-radio.sh")
| |
| 893 | os.chmod("XNPH25R/flash-radio.sh", 0755)
| |
| 894 | while not os.path.isfile("XNPH25R/boot.img"):
| |
| 895 | print("downloading XNPH25R/boot.img..\n")
| |
| 896 | dlimg("XNPH25R/boot.img")
| |
| 897 | while not os.path.isfile("XNPH25R/emmc_appsboot.mbn"):
| |
| 898 | print("downloading XNPH25R/emmc_appsboot.mbn..\n")
| |
| 899 | dlimg("XNPH25R/emmc_appsboot.mbn")
| |
| 900 | while not os.path.isfile("XNPH25R/NON-HLOS.bin"):
| |
| 901 | print("downloading XNPH25R/NON-HLOS.bin..\n")
| |
| 902 | dlimg("XNPH25R/NON-HLOS.bin")
| |
| 903 | while not os.path.isfile("XNPH25R/rpm.mbn"):
| |
| 904 | print("downloading XNPH25R/rpm.mbn..\n")
| |
| 905 | dlimg("XNPH25R/rpm.mbn")
| |
| 906 | while not os.path.isfile("XNPH25R/sbl1.mbn"):
| |
| 907 | print("downloading XNPH25R/sbl1.mbn..\n")
| |
| 908 | dlimg("XNPH25R/sbl1.mbn")
| |
| 909 | while not os.path.isfile("XNPH25R/sdi.mbn"):
| |
| 910 | print("downloading XNPH25R/sdi.mbn..\n")
| |
| 911 | dlimg("XNPH25R/sdi.mbn")
| |
| 912 | while not os.path.isfile("XNPH25R/tz.mbn"):
| |
| 913 | print("downloading XNPH25R/tz.mbn..\n")
| |
| 914 | dlimg("XNPH25R/tz.mbn")
| |
| 915 | while not os.path.isfile("XNPH25R/logo.bin"):
| |
| 916 | print("downloading XNPH25R/logo.bin..\n")
| |
| 917 | dlimg("XNPH25R/logo.bin")
| |
| 918 | subprocess.call(['./flash-radio.sh'], cwd='XNPH25R', shell=True) | |
| 919 | raw_input("press ENTER key to continue...")
| |
| 920 | flashmenu() | |
| 921 | ||
| 922 | elif flashsel == '7': | |
| 923 | if not os.path.exists('XNPH30O'):
| |
| 924 | os.makedirs('XNPH30O', 0755)
| |
| 925 | while not os.path.isfile("XNPH30O/boot.img"):
| |
| 926 | print("downloading XNPH30O/boot.img..\n")
| |
| 927 | dlimg("XNPH30O/boot.img")
| |
| 928 | while not os.path.isfile("XNPH30O/emmc_appsboot.mbn"):
| |
| 929 | print("downloading XNPH30O/emmc_appsboot.mbn..\n")
| |
| 930 | dlimg("XNPH30O/emmc_appsboot.mbn")
| |
| 931 | while not os.path.isfile("XNPH30O/NON-HLOS.bin"):
| |
| 932 | print("downloading XNPH30O/NON-HLOS.bin..\n")
| |
| 933 | dlimg("XNPH30O/NON-HLOS.bin")
| |
| 934 | while not os.path.isfile("XNPH30O/rpm.mbn"):
| |
| 935 | print("downloading XNPH30O/rpm.mbn..\n")
| |
| 936 | dlimg("XNPH30O/rpm.mbn")
| |
| 937 | while not os.path.isfile("XNPH30O/sbl1.mbn"):
| |
| 938 | print("downloading XNPH30O/sbl1.mbn..\n")
| |
| 939 | dlimg("XNPH30O/sbl1.mbn")
| |
| 940 | while not os.path.isfile("XNPH30O/flash-extras.sh"):
| |
| 941 | print("downloading XNPH30O/flash-extras.sh..\n")
| |
| 942 | dlimg("XNPH30O/flash-extras.sh")
| |
| 943 | os.chmod("XNPH30O/flash-extras.sh", 0755)
| |
| 944 | subprocess.call(['./flash-extras.sh'], cwd='XNPH30O', shell=True) | |
| 945 | raw_input("press ENTER key to continue...")
| |
| 946 | obj.fastreboot("android")
| |
| 947 | flashmenu() | |
| 948 | ||
| 949 | elif flashsel == '8': | |
| 950 | whichupdate = raw_input("enter 1 for XNPH30O update #1, 2 for XNPH30O update #2, 3 for XNPH33R update, or 4 to return to flash menu --> ")
| |
| 951 | while not re.search(r'^[1-4]$', whichupdate): | |
| 952 | whichupdate = raw_input("invalid selection. enter 1 for XNPH30O update #1, 2 for XNPH30O update #2, 3 for XNPH33R update, or 4 to return to flash menu --> ")
| |
| 953 | ||
| 954 | imgfile = "XNPH33R-update1-signed.zip" | |
| 955 | ||
| 956 | if whichupdate == '1': # XNPH30O update 1 | |
| 957 | imgfile = "XNPH30O-update1-signed.zip" | |
| 958 | while not os.path.isfile(imgfile): | |
| 959 | print("\033[35mdownloading XNPH30O-update1-signed.zip...\033[0m\n")
| |
| 960 | dlimg(imgfile) | |
| 961 | print("file \033[32m" + imgfile + " \033[0mfound!\n")
| |
| 962 | ||
| 963 | elif whichupdate == '2': # XNPH30O update 2 | |
| 964 | imgfile = "XNPH30O-update2-signed.zip" | |
| 965 | while not os.path.isfile(imgfile): | |
| 966 | print("\033[35mdownloading XNPH30O-update2-signed.zip...\033[0m\n")
| |
| 967 | dlimg(imgfile) | |
| 968 | print("file \033[32m" + imgfile + " \033[0mfound!\n")
| |
| 969 | ||
| 970 | elif whichupdate == '3': # XNPH33R update 1 | |
| 971 | imgfile = "XNPH33R-update1-signed.zip" | |
| 972 | while not os.path.isfile(imgfile): | |
| 973 | print("\033[35mdownloading XNPH33R-update1-signed.zip...\033[0m\n")
| |
| 974 | dlimg(imgfile) | |
| 975 | print("file \033[32m" + imgfile + " \033[0mfound!\n")
| |
| 976 | ||
| 977 | elif whichupdate == '4': # return to flash menu | |
| 978 | time.sleep(0.9) | |
| 979 | flashmenu() | |
| 980 | ||
| 981 | else: # error, return to flash menu | |
| 982 | print("unable to connect to device. returning to flash menu..\n")
| |
| 983 | time.sleep(0.9) | |
| 984 | flashmenu() | |
| 985 | ||
| 986 | # choose which recovery [installed or custom] to flash update "imgfile" | |
| 987 | recflupd = raw_input("enter 1 to flash update in installed recovery [may lose root], or 2 to flash in custom recovery [keep root prompt]. --> ")
| |
| 988 | while not re.search(r'^[12]$', recflupd): | |
| 989 | recflupd = raw_input("invalid selection. enter 1 to flash in installed recovery, or 2 to flash in custom recovery. --> ")
| |
| 990 | ||
| 991 | # copy update to device | |
| 992 | raw_input("make sure device is unlocked and PC is authenticated for ADB access. press ENTER to copy update to device.")
| |
| 993 | rimgfile = "/sdcard/" + imgfile | |
| 994 | print("\033[32mpushing update file to device..\033[0m\n")
| |
| 995 | obj.push(imgfile, rimgfile) | |
| 996 | ||
| 997 | # flash update in installed recovery | |
| 998 | if recflupd == '1': | |
| 999 | raw_input("press ENTER to reboot into recovery.")
| |
| 1000 | obj.reboot("recovery")
| |
| 1001 | print("choose APPLY UPDATE from recovery menu and select APPLY FROM ADB.\n")
| |
| 1002 | raw_input("press ENTER to install update now.")
| |
| 1003 | obj.sideload(imgfile) | |
| 1004 | failside = raw_input("if update did not succeed, press 1 to install from device. else, push POWER button on device to reboot, then press ENTER to continue..")
| |
| 1005 | if failside == '1': | |
| 1006 | print("choose APPLY UPDATE from recovery menu, then select CHOOSE FROM INTERNAL STORAGE.\n")
| |
| 1007 | print("select \033[32m" + imgfile + " \033[0mfrom root of SDCARD directory and install file.\n")
| |
| 1008 | print("\033[35mif update failed, return to main menu and select option 3 to boot into custom recovery.\033[0m\n\n")
| |
| 1009 | menusel = raw_input("enter 1 to return to flash menu, or 2 to return to main menu.")
| |
| 1010 | while not re.search(r'^[12]$',menusel): | |
| 1011 | menusel = raw_input("invalid selection. enter 1 for flash menu, or 2 to return to main menu.")
| |
| 1012 | if menusel == '1': | |
| 1013 | time.sleep(0.9) | |
| 1014 | flashmenu() | |
| 1015 | elif menusel == '2': | |
| 1016 | time.sleep(0.9) | |
| 1017 | main() | |
| 1018 | else: | |
| 1019 | print("error connecting to device. returning to main menu...\n")
| |
| 1020 | time.sleep(0.9) | |
| 1021 | main() | |
| 1022 | else: | |
| 1023 | print("\033[32mreturning to flash menu..\033[0m\n\n")
| |
| 1024 | ||
| 1025 | # flash update in custom recovery | |
| 1026 | elif recflupd == '2': | |
| 1027 | whichcustrec = raw_input("\033[36;1mselect custom recovery:\033[36m 1 for TWRP, 2 for Philz, 3 for CWM \033[0m--> ")
| |
| 1028 | while not re.search(r'^[12]$', whichcustrec): | |
| 1029 | whichcustrec = raw_input("invalid selection. enter 1 for TWRP, 2 for Philz, 3 for CWM --> ")
| |
| 1030 | v | |
| 1031 | # TWRP | |
| 1032 | if whichcustrec == '1': | |
| 1033 | custimgfile = "twrp.img" | |
| 1034 | ||
| 1035 | # PHILZ | |
| 1036 | elif whichcustrec == '2': | |
| 1037 | custimgfile = "philz.img" | |
| 1038 | ||
| 1039 | # CWM | |
| 1040 | else: | |
| 1041 | custimgfile = "cwm.img" | |
| 1042 | ||
| 1043 | while not os.path.isfile(custimgfile): | |
| 1044 | print("file \033[32m" + custimgfile + " \033[0mnot found. attempting download...\n")
| |
| 1045 | dlimg(custimgfile) | |
| 1046 | print("file \033[32m" + custimgfile + " \033[0mfound!\n")
| |
| 1047 | ||
| 1048 | raw_input("press ENTER to reboot to bootloader.")
| |
| 1049 | obj.reboot("bootloader")
| |
| 1050 | ||
| 1051 | raw_input("press ENTER to continue booting into custom recovery..")
| |
| 1052 | obj.bootimg(custimgfile) | |
| 1053 | ||
| 1054 | print("choose INSTALL UPDATE from recovery menu and select APPLY FROM ADB SIDELOAD.\n")
| |
| 1055 | raw_input("press ENTER to install update now.")
| |
| 1056 | obj.sideload(imgfile) | |
| 1057 | ||
| 1058 | failside = raw_input("if update did not succeed, press 1 to install from device. else, select REBOOT into SYSTEM from TWRP menu on device, then press ENTER..")
| |
| 1059 | if failside == '1': | |
| 1060 | print("on device, choose INSTALL from recovery menu, then select \033[32m" + imgfile + " \033[0mfrom SDCARD root and swipe to install file.\n")
| |
| 1061 | print("\033[35mwhen finished, select REBOOT into SYSTEM from recovery options on device.\033[0m\n\n")
| |
| 1062 | menusel = raw_input("enter 1 to return to flash menu, or 2 to return to main menu.")
| |
| 1063 | while not re.search(r'^[12]$',menusel): | |
| 1064 | menusel = raw_input("invalid selection. enter 1 for flash menu, or 2 to return to main menu.")
| |
| 1065 | if menusel == '1': | |
| 1066 | time.sleep(0.9) | |
| 1067 | flashmenu() | |
| 1068 | elif menusel == '2': | |
| 1069 | time.sleep(0.9) | |
| 1070 | main() | |
| 1071 | else: | |
| 1072 | print("error connecting to device. returning to main menu...\n")
| |
| 1073 | time.sleep(0.9) | |
| 1074 | main() | |
| 1075 | else: | |
| 1076 | print("\033[32mreturning to flash menu..\033[0m\n\n")
| |
| 1077 | else: | |
| 1078 | print("\033[32mreturning to flash menu..\033[0m\n\n")
| |
| 1079 | ||
| 1080 | time.sleep(0.9) | |
| 1081 | flashmenu() | |
| 1082 | ||
| 1083 | elif flashsel == '9': | |
| 1084 | romsel = raw_input("enter 1 to flash XNPH30O stock ROM, 2 to flash XNPH25R stock ROM, or 3 to flash custom ROM. --> ")
| |
| 1085 | while not re.search(r'^[1-3]$', romsel): | |
| 1086 | romsel = raw_input("invalid selection. enter 1 to flash XNPH30O stock ROM, 2 to flash XNPH25R stock ROM, or 3 to flash custom ROM. --> ")
| |
| 1087 | if romsel != '3': | |
| 1088 | if romsel == '1': | |
| 1089 | imgfile = "XNPH30O/cm-11.0-XNPH30O-bacon-signed-fastboot.zip" | |
| 1090 | if not os.path.exists('XNPH30O'):
| |
| 1091 | os.makedirs('XNPH30O', 0755)
| |
| 1092 | if romsel == '2': | |
| 1093 | imgfile = "XNPH25R/cm-11.0-XNPH25R-bacon-signed-fastboot.zip" | |
| 1094 | if not os.path.exists('XNPH25R'):
| |
| 1095 | os.makedirs('XNPH25R', 0755)
| |
| 1096 | while not os.path.isfile(imgfile): | |
| 1097 | print("file \033[32m" + imgfile + " \033[0mnot found. attempting download...\n")
| |
| 1098 | dlimg(imgfile) | |
| 1099 | print("file \033[32m" + imgfile + " \033[0mfound!\n")
| |
| 1100 | raw_input("press ENTER to reboot into bootloader..")
| |
| 1101 | obj.reboot("bootloader")
| |
| 1102 | obj.update(imgfile) | |
| 1103 | failupd = raw_input("if update failed, press 1. otherwise, press ENTER key to continue. --> ")
| |
| 1104 | if failupd == '1': | |
| 1105 | obj.fastreboot("android")
| |
| 1106 | raw_input("check that device is unlocked and computer is authorized for ADB access. press ENTER to continue..")
| |
| 1107 | imgfileonly = imgfile[8:] | |
| 1108 | rimgfile = "/sdcard/" + imgfileonly | |
| 1109 | obj.push(imgfile, rimgfile) | |
| 1110 | raw_input("press ENTER to reboot into recovery.")
| |
| 1111 | obj.reboot("recovery")
| |
| 1112 | print("choose APPLY UPDATE from recovery menu and select APPLY FROM ADB.\n")
| |
| 1113 | raw_input("press ENTER to install from stock image now.")
| |
| 1114 | obj.sideload(imgfile) | |
| 1115 | failside = raw_input("if update failed, press 1 to update from device storage. else, push POWER button on device to reboot, then press ENTER to continue. --> ")
| |
| 1116 | if failside == '1': | |
| 1117 | print("choose APPLY UPDATE from recovery menu, then select CHOOSE FROM INTERNAL STORAGE.\n")
| |
| 1118 | print("select file \033[32m" + imgfileonly + " \033[0mfrom root of SDCARD directory and install.\n")
| |
| 1119 | print("\033[35mif update fails again, return to main menu and choose option 3 to reboot into custom recovery.\033[0m\n\n")
| |
| 1120 | menusel = raw_input("enter 1 to return to flash menu, or 2 to return to main menu. --> ")
| |
| 1121 | while not re.search(r'^[12]$',menusel): | |
| 1122 | menusel = raw_input("invalid selection. press 1 for flash menu, or 2 to return to main menu. --> ")
| |
| 1123 | if menusel == '1': | |
| 1124 | time.sleep(0.9) | |
| 1125 | flashmenu() | |
| 1126 | elif menusel == '2': | |
| 1127 | time.sleep(0.9) | |
| 1128 | main() | |
| 1129 | else: | |
| 1130 | print("error connecting to device. returning to main menu...\n")
| |
| 1131 | time.sleep(0.9) | |
| 1132 | main() | |
| 1133 | else: | |
| 1134 | print("\033[32mreturning to flash menu..\033[0m\n\n")
| |
| 1135 | time.sleep(0.9) | |
| 1136 | flashmenu() | |
| 1137 | else: | |
| 1138 | print("\033[32mreturning to flash menu..\033[0m\n\n")
| |
| 1139 | time.sleep(0.9) | |
| 1140 | flashmenu() | |
| 1141 | else: | |
| 1142 | print("\033[31mmake sure device is unlocked and PC is authenticated for ADB access.\033[0m\n")
| |
| 1143 | romname = raw_input("place ROM file into same directory as the script home, then enter filename --> ")
| |
| 1144 | while not os.path.isfile(romname): | |
| 1145 | romname = raw_input("invalid filename. make sure ROM ZIP file to flash is in correct location, then enter filename --> ")
| |
| 1146 | rimgfile = "/sdcard/" + romname | |
| 1147 | print("\033[32mpushing update file to device..\033[0m\n")
| |
| 1148 | obj.push(romname, rimgfile) | |
| 1149 | raw_input("press ENTER to reboot to bootloader.")
| |
| 1150 | obj.reboot("bootloader")
| |
| 1151 | while not os.path.isfile("twrp.img"):
| |
| 1152 | print("file \033[32mtwrp.img \033[0mnot found. attempting download...\n")
| |
| 1153 | dlimg("twrp.img")
| |
| 1154 | print("file \033[32mtwrp.img \033[0mfound!\n")
| |
| 1155 | raw_input("press ENTER to continue booting into TWRP recovery.")
| |
| 1156 | obj.bootimg("twrp.img")
| |
| 1157 | print("on device, choose ADVANCED from TWRP menu, then select INSTALL ZIP and to APPLY VIA ADB SIDELOAD.\n")
| |
| 1158 | raw_input("press ENTER to install the zip file you specified.")
| |
| 1159 | obj.sideload(imgfile) | |
| 1160 | failside = raw_input("if update failed, enter 1 to try installing from device storage. otherwise, push select REBOOT from device recovery menu, reboot into system, and press ENTER to continue. --> ")
| |
| 1161 | if failside == '1': | |
| 1162 | print("select INSTALL on device TWRP menu, then find your file \033[32m" + romname + " \033[0min device SDCARD root and swipe to install file.\n")
| |
| 1163 | menusel = raw_input("when flash complete, select REBOOT into SYSTEM from recovery options on device. then enter 1 to return to flash menu, or 2 for main menu.")
| |
| 1164 | while not re.search(r'^[12]$',menusel): | |
| 1165 | menusel = raw_input("invalid selection. enter 1 for flash menu, or 2 to return to main menu.")
| |
| 1166 | if menusel == '1': | |
| 1167 | time.sleep(0.9) | |
| 1168 | flashmenu() | |
| 1169 | elif menusel == '2': | |
| 1170 | time.sleep(0.9) | |
| 1171 | main() | |
| 1172 | else: | |
| 1173 | print("error connecting to device. returning to main menu...\n")
| |
| 1174 | time.sleep(0.9) | |
| 1175 | main() | |
| 1176 | ||
| 1177 | elif flashsel == '0': | |
| 1178 | checkreboot = raw_input("press 1 to reboot device into system, or ENTER to continue.. --> ")
| |
| 1179 | if checkreboot == '1': | |
| 1180 | obj.fastreboot("android")
| |
| 1181 | main() | |
| 1182 | else: | |
| 1183 | print("unable to connect to device.\n")
| |
| 1184 | ||
| 1185 | def recovflash(): | |
| 1186 | print("\n")
| |
| 1187 | flashcont = raw_input("select 1 to continue flashing recovery. select 2 to flash a stock or custom image. select 3 to return to flash menu. --> ")
| |
| 1188 | while not re.search(r'^[123]$', flashcont): | |
| 1189 | flashcont = raw_input("invalid selection. select 1 to continue flashing recovery. select 2 to flash a stock partition image. select 3 to return to flash menu. --> ")
| |
| 1190 | if flashcont == '1': | |
| 1191 | recovchoice = raw_input("enter 1 for TWRP, 2 for ClockworkMod, or 3 for Philz recovery --> ")
| |
| 1192 | while not re.search(r'^[1-3]$', recovchoice): | |
| 1193 | recovchoice = raw_input("invalid selection. please choose 1 for TWRP, 2 for CWM, or 3 for Philz --> ")
| |
| 1194 | obj.reboot("bootloader")
| |
| 1195 | if recovchoice == '1': | |
| 1196 | recovfile = "twrp.img" | |
| 1197 | while not os.path.isfile(recovfile): | |
| 1198 | print("file \033[32mtwrp.img \033[0mnot found. attempting download...\n")
| |
| 1199 | dlrecov(recovfile) | |
| 1200 | print("file \033[32mtwrp.img \033[0mfound!\n")
| |
| 1201 | raw_input("press ENTER to flash twrp.img over current recovery.")
| |
| 1202 | obj.flashf("recovery","twrp.img")
| |
| 1203 | elif recovchoice == '2': | |
| 1204 | recovfile = "cwm.img" | |
| 1205 | while not os.path.isfile(recovfile): | |
| 1206 | print("file \033[32mcwm.img \033[0mnot found. attempting download...\n")
| |
| 1207 | dlrecov(recovfile) | |
| 1208 | print("file \033[32mcwm.img \033[0mfound!\n")
| |
| 1209 | raw_input("press ENTER to flash cwm.img over current recovery.")
| |
| 1210 | obj.flashf("recovery","cwm.img")
| |
| 1211 | elif recovchoice == '3': | |
| 1212 | recovfile = "philz.img" | |
| 1213 | while not os.path.isfile(recovfile): | |
| 1214 | print("file \033[32mphilz.img \033[0mnot found. attempting download...\n")
| |
| 1215 | dlrecov(recovfile) | |
| 1216 | print("file \033[32mphilz.img \033[0mfound!\n")
| |
| 1217 | raw_input("press ENTER to flash philz.img over current recovery.")
| |
| 1218 | obj.flashf("recovery","philz.img")
| |
| 1219 | else: | |
| 1220 | print("unable to connect to device.\n")
| |
| 1221 | ||
| 1222 | elif flashcont == '2': | |
| 1223 | flashmenu() | |
| 1224 | ||
| 1225 | elif flashcont == '3': | |
| 1226 | main() | |
| 1227 | ||
| 1228 | else: | |
| 1229 | print("unable to connect to device.\n")
| |
| 1230 | ||
| 1231 | time.sleep(0.9) | |
| 1232 | - | main() |
| 1232 | + | |
| 1233 | ||
| 1234 | - | intro() |
| 1234 | + | |
| 1235 | - | os.system('cls' if os.name == 'nt' else 'clear')
|
| 1235 | + | |
| 1236 | print("\033[37mIF YOUR DEVICE HOLDS IMPORTANT DATA, BACK UP DEVICE BEFORE YOU CONTINUE!\033[0m\n")
| |
| 1237 | print("\033[35mIMPORTANT: if you have already unlocked your device and are re-unlocking, you MUST be running the XNPH25R stock firmware or older.\n")
| |
| 1238 | print("\033[32mRE-UNLOCK ATTEMPTS WILL FAIL on XNPH30O or newer. you must return to the previous menu and flash the XNPH25R images to your device.\033[0m\n")
| |
| 1239 | bunlock = raw_input("enter 1 to continue unlocking bootloader. enter 2 to skip to flashing custom recovery or images. enter 3 to re-lock bootloader. or enter 4 to return to menu. --> ")
| |
| 1240 | while not re.search(r'^[123]$', bunlock): | |
| 1241 | bunlock = raw_input("invalid selection. enter 1 to unlock bootloader and wipe device. enter 2 to skip to flashing custom recovery or images. enter 3 to re-lock bootloader. or enter 4 to return to menu. --> ")
| |
| 1242 | ||
| 1243 | if bunlock == '1': | |
| 1244 | obj.reboot("bootloader")
| |
| 1245 | obj.unlockboot() | |
| 1246 | print("your device should reboot after successfully unlocking the bootloader.\n")
| |
| 1247 | raw_input("press ENTER to continue...")
| |
| 1248 | recovflash() | |
| 1249 | ||
| 1250 | elif bunlock == '2': | |
| 1251 | recovflash() | |
| 1252 | ||
| 1253 | elif bunlock == '3': | |
| 1254 | print("\033[33mREMINDER: to unlock your device again, you MUST downgrade to firmware release XNPH25R or earlier!\033[0m\n")
| |
| 1255 | btlockconfirm = raw_input("press ENTER to continue, or 1 to exit to the previous menu --> ")
| |
| 1256 | if btlockconfirm == '1': | |
| 1257 | flashmenu() | |
| 1258 | else: | |
| 1259 | obj.reboot("bootloader")
| |
| 1260 | obj.lockboot() | |
| 1261 | raw_input("press ENTER to reboot your device")
| |
| 1262 | obj.fastreboot("android")
| |
| 1263 | ||
| 1264 | else: | |
| 1265 | flashmenu() | |
| 1266 | ||
| 1267 | time.sleep(0.9) | |
| 1268 | main() | |
| 1269 | ||
| 1270 | elif option == '9': #run shell command | |
| 1271 | shellcmd = raw_input("enter shell command --> ")
| |
| 1272 | while shellcmd: | |
| 1273 | obj.shell(shellcmd) | |
| 1274 | shellcmd = raw_input("enter another shell command, or press ENTER to continue --> ")
| |
| 1275 | time.sleep(0.9) | |
| 1276 | main() | |
| 1277 | ||
| 1278 | elif option is '10': #get bugreport | |
| 1279 | raw_input("please allow several minutes for process to complete. press ENTER to start generating bug report.")
| |
| 1280 | obj.bugreport() | |
| 1281 | raw_input("press ENTER to return to main menu.")
| |
| 1282 | time.sleep(0.9) | |
| 1283 | main() | |
| 1284 | ||
| 1285 | elif option == '11': #get logcat | |
| 1286 | print("logcat will open in a new window. close logcat window to return to menu.")
| |
| 1287 | if os.name == 'nt': | |
| 1288 | process = subprocess.Popen('start /wait adb logcat', shell=True, creationflags=subprocess.CREATE_NEW_CONSOLE, stdout=subprocess.PIPE)
| |
| 1289 | else: | |
| 1290 | process = subprocess.Popen(['xterm', '-e', 'adb', 'logcat', 'sleep 4'], stdout=subprocess.PIPE) | |
| 1291 | line = process.stdout.readline() | |
| 1292 | while line: | |
| 1293 | print line | |
| 1294 | line = process.stdout.readline() | |
| 1295 | time.sleep(0.9) | |
| 1296 | main() | |
| 1297 | ||
| 1298 | elif option == '0': #quit | |
| 1299 | print("thanks for using the HALF-ASSED ONEPLUS ONE TOOLKIT! bye!")
| |
| 1300 | sys.exit() | |
| 1301 | ||
| 1302 | else: | |
| 1303 | print '\n\033[32man unhandled exception occurred. returning to main menu..\033[0m\n' | |
| 1304 | time.sleep(0.9) | |
| 1305 | main() | |
| 1306 | ||
| 1307 | main() | |
| 1308 | sys.exit() |