|
28 | 28 | import random |
29 | 29 | import uuid |
30 | 30 | import platform |
| 31 | +from tkinter import Tk |
| 32 | +from tkinter.filedialog import askopenfilename |
| 33 | + |
31 | 34 | sys.path.append('./resources/python') |
32 | 35 | from cpydColours import color |
33 | 36 | try: |
|
37 | 40 | global FEATURE_LEVEL |
38 | 41 | global repoDir |
39 | 42 | global nrsDir |
| 43 | +global newGenDialogs |
40 | 44 |
|
41 | 45 | script = "autopilot.py" |
42 | 46 | scriptName = "AutoPilot" |
|
50 | 54 | parser.add_argument("--disable-blob-check", dest="disableBlobCheck", help="Bypasses checking of blob integrity",action="store_true") |
51 | 55 | parser.add_argument("--disable-progress", dest="disableProgress", help="Disable progress bar UI displays",action="store_true") |
52 | 56 | parser.add_argument("--disable-percentage", dest="disablePercentage", help="Disable progress bar percentages and data labels",action="store_true") |
| 57 | +parser.add_argument("--disable-new-dialogs", dest="disableDialogs", help="Disable the GUI file picker dialogs",action="store_true") |
53 | 58 | parser.add_argument("--skip-summary", dest="skipSummary", help="Starts the AutoPilot flow immediately after questioning",action="store_true") |
54 | 59 | parser.add_argument("--skip-notices", dest="skipNotices", help="Don't download and load notices",action="store_true") |
55 | 60 | parser.add_argument("--no-auto-download", dest="customDownload", help="Asks the user what to download during run",action="store_true") |
|
117 | 122 | else: |
118 | 123 | enablePercentage = True |
119 | 124 |
|
| 125 | +if args.disableDialogs == True: |
| 126 | + newGenDialogs = 0 |
| 127 | +else: |
| 128 | + newGenDialogs = 1 |
| 129 | + |
120 | 130 | version = open(repoDir+"/.version") |
121 | 131 | version = version.read() |
122 | 132 |
|
@@ -421,6 +431,7 @@ def autopilot(): |
421 | 431 | global USR_TARGET_OS_NAME |
422 | 432 | global FEATURE_LEVEL |
423 | 433 | global USR_CREATE_XML |
| 434 | + global newGenDialogs |
424 | 435 | global startTime |
425 | 436 |
|
426 | 437 | USR_CPU_SOCKS = 1 |
@@ -1010,6 +1021,7 @@ def stage13(): |
1010 | 1021 | def stage12(): |
1011 | 1022 | global customValue |
1012 | 1023 | global currentStage |
| 1024 | + global newGenDialogs |
1013 | 1025 | global USR_BOOT_FILE |
1014 | 1026 | defaultValue = "BaseSystem.img" |
1015 | 1027 | currentStage = 12 |
@@ -1068,11 +1080,28 @@ def stage12(): |
1068 | 1080 |
|
1069 | 1081 |
|
1070 | 1082 | if customValue == 1: |
| 1083 | + |
| 1084 | + |
| 1085 | + |
1071 | 1086 | cpydLog("info",str("Custom value requested, setting up")) |
1072 | 1087 | # print(color.BOLD+color.PURPLE+"\n FORMAT:"+color.YELLOW+""+color.END+color.BOLD,"<file>"+color.YELLOW+".img"+color.END+"\n Enter a custom value.\n \n ") |
1073 | | - print(color.BOLD+color.PURPLE+"\n FORMAT:",color.YELLOW+""+color.END+color.BOLD+"<file>"+color.YELLOW+".img"+color.END+"\n Enter the full path to a bootable macOS Recovery image file.\n It will be automatically copied into the root repo directory, or you\n can place it there now and type \"BaseSystem.img\" without a path.\n You",color.UNDERLINE+color.BOLD+"must"+color.END,"include any text in"+color.YELLOW,"yellow"+color.END+".\n\n "+color.BOLD+"TIP:"+color.END,"You can drag and drop a file onto this window.\n \n ") |
1074 | 1088 | cpydLog("wait",("Waiting for user input")) |
1075 | | - customInput = str(input(color.BOLD+"Value> "+color.END)) |
| 1089 | + |
| 1090 | + if newGenDialogs == 1: |
| 1091 | + print(color.BOLD+color.PURPLE+"\n Using filesystem dialog..."+"\n "+color.END) |
| 1092 | + cpydLog("info",str("New gen dialogs enabled, using GUI filepicker")) |
| 1093 | + Tk().withdraw() |
| 1094 | + customInput = askopenfilename() |
| 1095 | + if len(customInput) < 3: |
| 1096 | + cpydLog("error",str("Never received a response from the GUI dialog! Did we break? Falling back!")) |
| 1097 | + customValue = 0 |
| 1098 | + stage12() |
| 1099 | + else: |
| 1100 | + cpydLog("ok",str("Successfully got response from GUI dialog")) |
| 1101 | + else: |
| 1102 | + print(color.BOLD+color.PURPLE+"\n FORMAT:",color.YELLOW+""+color.END+color.BOLD+"<file>"+color.YELLOW+".img"+color.END+"\n Enter the full path to a bootable macOS Recovery image file.\n It will be automatically copied into the root repo directory, or you\n can place it there now and type \"BaseSystem.img\" without a path.\n You",color.UNDERLINE+color.BOLD+"must"+color.END,"include any text in"+color.YELLOW,"yellow"+color.END+".\n\n "+color.BOLD+"TIP:"+color.END,"You can drag and drop a file onto this window.\n \n ") |
| 1103 | + |
| 1104 | + customInput = str(input(color.BOLD+"Value> "+color.END)) |
1076 | 1105 | cpydLog("ok",("User input received")) |
1077 | 1106 |
|
1078 | 1107 | USR_BOOT_FILE = customInput |
@@ -1544,6 +1573,7 @@ def stage8(): |
1544 | 1573 | global USR_HDD_ISPHYSICAL |
1545 | 1574 | global customValue |
1546 | 1575 | global currentStage |
| 1576 | + global newGenDialogs |
1547 | 1577 | currentStage = 8 |
1548 | 1578 |
|
1549 | 1579 | global stageHooks |
@@ -1625,9 +1655,21 @@ def stage8(): |
1625 | 1655 | elif customValue == 2: |
1626 | 1656 | cpydLog("info",str("Custom value requested, setting up")) |
1627 | 1657 | # print(color.BOLD+color.PURPLE+"\n FORMAT:"+color.YELLOW+""+color.END+color.BOLD,"<>"+color.YELLOW+""+color.END+"\n Enter a custom value.\n \n ") |
1628 | | - print(color.BOLD+color.PURPLE+"\n FORMAT:",color.YELLOW+""+color.END+color.BOLD+"<full path to HDD file>"+color.END+"\n Drag the *.qcow2 file onto this window (or type the path) and hit ENTER.\n"+color.END+"\n ") |
1629 | 1658 | cpydLog("wait",("Waiting for user input")) |
1630 | | - customInput = str(input(color.BOLD+"File> "+color.END)) |
| 1659 | + if newGenDialogs == 1: |
| 1660 | + print(color.BOLD+color.PURPLE+"\n Using filesystem dialog..."+"\n "+color.END) |
| 1661 | + cpydLog("info",str("New gen dialogs enabled, using GUI filepicker")) |
| 1662 | + Tk().withdraw() |
| 1663 | + customInput = askopenfilename() |
| 1664 | + if len(customInput) < 3: |
| 1665 | + cpydLog("error",str("Never received a response from the GUI dialog! Did we break? Falling back!")) |
| 1666 | + customValue = 0 |
| 1667 | + stage8() |
| 1668 | + else: |
| 1669 | + cpydLog("ok",str("Successfully got response from GUI dialog")) |
| 1670 | + else: |
| 1671 | + print(color.BOLD+color.PURPLE+"\n FORMAT:",color.YELLOW+""+color.END+color.BOLD+"<full path to HDD file>"+color.END+"\n Drag the *.qcow2 file onto this window (or type the path) and hit ENTER.\n"+color.END+"\n ") |
| 1672 | + customInput = str(input(color.BOLD+"File> "+color.END)) |
1631 | 1673 | cpydLog("ok",("User input received")) |
1632 | 1674 | USR_HDD_PATH = customInput |
1633 | 1675 | USR_HDD_PATH = USR_HDD_PATH.replace("'","") |
@@ -1743,6 +1785,8 @@ def stage7(): |
1743 | 1785 | currentStage = 7 |
1744 | 1786 | defaultValue = "4G" |
1745 | 1787 |
|
| 1788 | + if USR_TARGET_OS >= 15 and USR_TARGET_OS < 99: defaultValue = "8G" |
| 1789 | + |
1746 | 1790 | global stageHooks |
1747 | 1791 | global activeNotice |
1748 | 1792 | global notices |
|
0 commit comments