Skip to content

Commit

Permalink
Update progress bars, add download speed to DLOSX
Browse files Browse the repository at this point in the history
Co-authored-by: eversiege <eversiege@users.noreply.github.com>
  • Loading branch information
Coopydood and eversiege committed Apr 26, 2024
1 parent 293c4ae commit 2c50d94
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 64 deletions.
5 changes: 5 additions & 0 deletions docs/changelogs/v0-11-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ This update includes the following features / fixes / changes:
- Added progress bars for AutoPilot stages
- Added a progress bar when downloading macOS with AutoPilot or standalone script
- Added a splash screen on program exit
- Updated the progress bar style in system check scripts
- Changed the colour of grey used throughout the project for better contrast
- Fixed logging of BaseSystem check in AutoPilot flow
- Fixed the BaseSystem integrity check in AutoPilot
- Fixed the infinite error loop on incompatible OS detection
- Fixed an issue where the OVMF EFI shell would load after applying Sonoma 14.4 patch
- Fixed an issue where AutoPilot menu flow would get trapped after screen resolution stage when custom resolutions are unsupported
- *now that is a hot looking progress bar innit*
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,6 @@ def clear(): print("\n" * 150)
print(" Have a nice night - "+color.CYAN+"and remember to sleep!"+color.END+" :]\n\n\n")
exit(0)

else:
elif detected != 2:
clear()
os.system('./main.py')
33 changes: 17 additions & 16 deletions scripts/autopilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class color:
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'
GRAY = '\u001b[38;5;245m'
GRAY = '\u001b[38;5;240m'


global logTime
Expand All @@ -131,7 +131,7 @@ class color:


os.system("echo ULTMOS AUTOPILOT LOG "+str(datetime.today().strftime('%d-%m-%Y %H:%M:%S'))+" > ./logs/APC_RUN_"+logTime+".log")
os.system("echo ──────────────────────────────────────────────────────────────"+" >> ./logs/APC_RUN_"+logTime+".log")
os.system("echo ───────────────────────────────────────────────────────────────────"+" >> ./logs/APC_RUN_"+logTime+".log")

def cpydLog(logStatus,logMsg,*args):
logFile = open("./logs/APC_RUN_"+logTime+".log","a")
Expand Down Expand Up @@ -268,10 +268,10 @@ def startup():
#print(color.BOLD+"\n"+" Profile:"+color.END,"https://github.com/Coopydood")
#print(color.BOLD+" Repo:"+color.END,"https://github.com/Coopydood/ultimate-macOS-KVM") # no shameless plugs anymore :[
if enableLog == False:
print("\n "+" "+color.BOLD+"──────────────────────────────────────────────────────────────",color.END)
print("\n "+" "+color.BOLD+"───────────────────────────────────────────────────────────────────",color.END)
print(" "+color.BOLD+color.YELLOW+" ⚠ "+color.END+color.BOLD+" LOGGING DISABLED"+color.END)
print(" "+color.END+" The logfile has been disabled. \n No diagnostic information will be recorded."+color.END)
print(" "+" "+color.BOLD+"──────────────────────────────────────────────────────────────",color.END)
print(" "+" "+color.BOLD+"───────────────────────────────────────────────────────────────────",color.END)

#print(color.YELLOW+"\n ⚠"+color.END+color.BOLD+" WARNING"+color.END)
#print(" Logging has been disabled")
Expand Down Expand Up @@ -495,8 +495,8 @@ def progressUpdate(progressVal,*args):
print(' \r {0} '.format((progressGUI+" "+color.END+color.BOLD+str(progress)+"% "+color.END),('')), end='')
sys.stdout.flush()
else:
print(' \r '.format((progressGUI+" "+color.END+color.BOLD+str(progress)+"% "+color.END),(' ────────────────────────────────────────────────────────────── ')), end='')
#print(' \r ──────────────────────────────────────────────────────────────')
print(' \r '.format((progressGUI+" "+color.END+color.BOLD+str(progress)+"% "+color.END),(' ─────────────────────────────────────────────────────────────────── ')), end='')
#print(' \r ───────────────────────────────────────────────────────────────────')



Expand Down Expand Up @@ -592,7 +592,7 @@ def stage15():
print(" "+"\n "+color.BOLD+"Ready to generate config file"+color.END)
#print(" "+"Review your preferences")
print(" "+"Review your preferences below and continue when ready."+color.END)
print(" "+"\n "+color.BOLD+"──────────────────────────────────────────────────────────────",color.END)
print(" "+"\n "+color.BOLD+"───────────────────────────────────────────────────────────────────",color.END)

if USR_CREATE_XML == "True":
print(" "+color.BOLD+color.PURPLE+"FILES ",color.END+color.END+USR_CFG+", "+USR_CFG_XML)
Expand Down Expand Up @@ -632,7 +632,7 @@ def stage15():
print(" "+color.BOLD+color.CYAN+"NETWORK ",color.END+color.END+USR_NETWORK_DEVICE+color.END+"")


print(" "+color.BOLD+"──────────────────────────────────────────────────────────────",color.END)
print(" "+color.BOLD+"───────────────────────────────────────────────────────────────────",color.END)
#if USR_BOOT_FILE == "-1":
print(color.BOLD+"\n 1. Start...")
print(color.END+" Begin the AutoPilot run using the above setup\n")
Expand Down Expand Up @@ -1004,10 +1004,10 @@ def stage12():
print("\n Choose a bootable image file the virtual machine should boot to. \n You need a macOS Recovery image (BaseSystem). You can either\n select an existing one or the wizard can download one for you.\n It must be in the *.img or *.dmg file format."+color.END)
print("\n "+color.BOLD+color.CYAN+"NOTE:",color.END+color.BOLD+"This stage is optional. You can skip it if\n you intend on using an existing HDD file."+color.END)
if customDownload == True:
print("\n "+" "+color.BOLD+"──────────────────────────────────────────────────────────────",color.END)
print("\n "+" "+color.BOLD+"───────────────────────────────────────────────────────────────────",color.END)
print(" "+color.BOLD+color.YELLOW+" ⚠ "+color.END+color.BOLD+" AUTO DOWNLOAD DISABLED"+color.END)
print(" "+color.END+" Automatic version download has been disabled. You will be\n asked to choose a download during the AutoPilot process."+color.END)
print(" "+" "+color.BOLD+"──────────────────────────────────────────────────────────────",color.END)
print(" "+" "+color.BOLD+"───────────────────────────────────────────────────────────────────",color.END)

if USR_TARGET_OS >= 100 and USR_TARGET_OS <= 1012:
print(color.YELLOW+"\n ⚠"+color.END+color.BOLD+" Download flow disabled for legacy versions.\n You must download an image manually."+color.END)
Expand Down Expand Up @@ -2792,7 +2792,7 @@ def refreshStatusGUI():
print(" "+"\n "+color.BOLD+"Status"+color.END)
print(" "+"AutoPilot is performing the requested actions.")
print(" "+"\n This may take a few moments."+color.END)
print(" "+"\n "+color.BOLD+"──────────────────────────────────────────────────────────────",color.END)
print(" "+"\n "+color.BOLD+"───────────────────────────────────────────────────────────────────",color.END)

if PROC_PREPARE == 0:
print(" "+color.BOLD+color.RED+"● ",color.END+color.END+"Preparing files"+color.END)
Expand Down Expand Up @@ -2875,10 +2875,10 @@ def refreshStatusGUI():
elif PROC_CLEANUP == 2:
print(" "+color.BOLD+color.GREEN+"● ",color.END+color.END+"Cleaning up"+color.END)

print(" "+color.BOLD+"──────────────────────────────────────────────────────────────",color.END)
print(" "+color.BOLD+"───────────────────────────────────────────────────────────────────",color.END)
progressUpdate(-1)
#print(' \r {0} '.format((progressGUI+" "+color.END+color.BOLD+str(progress)+"% "+color.END),(' ────────────────────────────────────────────────────────────── ')), end='')
#print("\n "+color.BOLD+"──────────────────────────────────────────────────────────────",color.END)
#print(' \r {0} '.format((progressGUI+" "+color.END+color.BOLD+str(progress)+"% "+color.END),(' ─────────────────────────────────────────────────────────────────── ')), end='')
#print("\n "+color.BOLD+"───────────────────────────────────────────────────────────────────",color.END)
#if PROC_FETCHDL != 1:
#print("\n\n\n")

Expand Down Expand Up @@ -3326,8 +3326,9 @@ def apcFetchDL(): # FETCH RECOVERY ONLINE
os.system("./scripts/dlosx.py")
#subprocess.Popen(cmd).wait()
#print(os.path.getsize("./BaseSystem.img"))
cpydLog("info",("Checking BaseSystem with a size of "+str(os.path.getsize("./BaseSystem.img"))))
if os.path.exists("./BaseSystem.img") and os.path.getsize("./BaseSystem.img") > 2401920:
if os.path.exists("./BaseSystem.img"):
cpydLog("info",("Checking BaseSystem with a size of "+str(os.path.getsize("./BaseSystem.img"))))
if os.path.exists("./BaseSystem.img") and os.path.getsize("./BaseSystem.img") > 314572800:
integrityImg = 1
cpydLog("ok",("Integrity check PASSED"))
else:
Expand Down
54 changes: 43 additions & 11 deletions scripts/dlosx-arg.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class color:
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'
GRAY = '\u001b[38;5;245m'
GRAY = '\u001b[38;5;240m'

try:
from urllib.request import Request, urlopen
Expand Down Expand Up @@ -189,16 +189,22 @@ def save_image(url, sess, filename='', directory=''):
#else:
#print("Note: The total download size is %0.2f MB" % total_size)
size = 0
#print(" ──────────────────────────────────────────────────────────────")
tmEnd = 0
tmStart = 0
smStart = 0
smEnd = 0
lastTime = 0
lastSize = 0
#print(" ───────────────────────────────────────────────────────────────────")
while True:
#print(" ──────────────────────────────────────────────────────────────")
chunk = response.read(2 ** 20)
#print(" ───────────────────────────────────────────────────────────────────")
chunk = response.read(1000000)
if not chunk:
break
fhandle.write(chunk)
size += len(chunk)

progress = (round(float(100 * size / (2 ** 20))/float(total_size)))
progress = (round(float(100 * size / (1048576))/float(total_size)))

if progress <= 5:
progressGUI = (color.BOLD+""+color.GRAY+"━━━━━━━━━━━━━━━━━━━━")
Expand Down Expand Up @@ -243,21 +249,47 @@ def save_image(url, sess, filename='', directory=''):
elif progress >= 100:
progressGUI = (color.GREEN+"━━━━━━━━━━━━━━━━━━━━"+color.GRAY+"")

if (int(time.time()) - lastTime) >= 0.1:
timeTaken = int(time.time()) - lastTime
speed = (((((size / 1048576) - (lastSize)) / (timeTaken))))
speed = round(speed,1)
#print("speed is: ",speed,"MB/s")
timeTaken = 0
lastSize = (size / 2 ** 20) # in MBs
lastTime = int(time.time())

print(' \r {2} {0:0.1f} MB / {1:0.1f} MB '.format((size / (2 ** 20)),(total_size),(progressGUI+" "+color.END+color.BOLD+str(progress)+"% "+color.END),(' ────────────────────────────────────────────────────────────── ')), end='')

#lastSize = size / (2 ** 20)
#

#timeTaken = tmEnd - tmStart
#loadedSize = smEnd - smStart

#speed = round((timeTaken * loadedSize)/ 60 * )

#print("speed is: ",speed,"MB/s")




print(' \r {2} {0:0.1f} MB / {1:0.1f} MB {3} '.format((size / (2 ** 20)),(total_size),(progressGUI+" "+color.END+color.BOLD+str(progress)+"% "+color.END),((str(speed))+" MB/s")), end='')
sys.stdout.flush()
#print(' \r ✓ {2} {0:0.1f} MB / {1:0.1f} MB '.format((size / (2 ** 20)),(total_size),(progressGUI+" "+color.END+color.BOLD+str(progress)+"% "+color.END),(' ────────────────────────────────────────────────────────────── ')), end='')
print(' \r {2} Download Complete '.format((size / (2 ** 20)),(total_size),(progressGUI+" "+color.END+color.BOLD+str(progress)+"% "+color.END),('\n ────────────────────────────────────────────────────────────── ')), end='')
#print(' \r ✓ {2} {0:0.1f} MB / {1:0.1f} MB '.format((size / (2 ** 20)),(total_size),(progressGUI+" "+color.END+color.BOLD+str(progress)+"% "+color.END),(' ─────────────────────────────────────────────────────────────────── ')), end='')
print(' \r {2} Download Complete '.format((size / (2 ** 20)),(total_size),(progressGUI+" "+color.END+color.BOLD+str(progress)+"% "+color.END),('\n ─────────────────────────────────────────────────────────────────── ')), end='')
time.sleep(3)


progressGUI = (color.GRAY+"━━━━━━━━━━━━━━━━━━━━"+color.GRAY+"")
print(' \r {2} Converting... '.format((size / (2 ** 20)),(total_size),(progressGUI+" "+color.END+color.BOLD+"⊚ "+color.END),('\n ────────────────────────────────────────────────────────────── ')), end='')
print(' \r {2} Converting... '.format((size / (2 ** 20)),(total_size),(progressGUI+" "+color.END+color.BOLD+"⊚ "+color.END),('\n ─────────────────────────────────────────────────────────────────── ')), end='')

passon()
progressGUI = (color.GREEN+"━━━━━━━━━━━━━━━━━━━━"+color.GRAY+"")
print(' \r {2} Conversion Complete '.format((size / (2 ** 20)),(total_size),(progressGUI+" "+color.END+color.BOLD+"100% "+color.END),('\n ────────────────────────────────────────────────────────────── ')), end='')

print(' \r {2} Conversion Complete '.format((size / (2 ** 20)),(total_size),(progressGUI+" "+color.END+color.BOLD+"100% "+color.END),('\n ─────────────────────────────────────────────────────────────────── ')), end='')
time.sleep(2)
#print('\r{} MBs downloaded...'.format(size / (2 ** 20)), end='')

#print('\rDownload complete!' + ' ' * 32)



def action_download(args):
Expand Down

0 comments on commit 2c50d94

Please sign in to comment.