Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions MakeInstall.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from Scripts import utils, diskwin, downloader, run
import os, sys, tempfile, shutil, zipfile, platform, json, time
import os, sys, tempfile, shutil, zipfile, platform, json, time, string

class WinUSB:

Expand Down Expand Up @@ -36,8 +36,6 @@ def __init__(self):
self.diskpart = os.path.join(os.environ['SYSTEMDRIVE'] + "\\", "Windows", "System32", "diskpart.exe")
# From Tim Sutton's brigadier: https://github.com/timsutton/brigadier/blob/master/brigadier
self.z_path = None
self.z_path64 = os.path.join(os.environ['SYSTEMDRIVE'] + "\\", "Program Files", "7-Zip", "7z.exe")
self.z_path32 = os.path.join(os.environ['SYSTEMDRIVE'] + "\\", "Program Files (x86)", "7-Zip", "7z.exe")
self.recovery_suffixes = (
"recoveryhdupdate.pkg",
"recoveryhdmetadmg.pkg"
Expand Down Expand Up @@ -108,9 +106,13 @@ def check_dd(self):
return os.path.exists(os.path.join(self.s_path, self.dd_name))

def check_7z(self):
self.z_path = self.z_path64 if os.path.exists(self.z_path64) else self.z_path32 if os.path.exists(self.z_path32) else None
if self.z_path:
return True
all_drives = ["{}:".format(d) for d in string.ascii_uppercase if os.path.exists("{}:".format(d))]
for drive in all_drives:
z_path64 = os.path.join(drive + "\\", "Program Files", "7-Zip", "7z.exe")
z_path32 = os.path.join(drive + "\\", "Program Files (x86)", "7-Zip", "7z.exe")
self.z_path = z_path64 if os.path.exists(z_path64) else z_path32 if os.path.exists(z_path32) else None
if self.z_path:
return True
print("Didn't locate {} - downloading...".format(self.z_name))
# Didn't find it - let's do some stupid stuff
# First we get our json response - or rather, try to, then parse it
Expand All @@ -128,6 +130,7 @@ def check_7z(self):
temp = tempfile.mkdtemp()
dl_file = self.dl.stream_to_file(dl_url, os.path.join(temp, self.z_name))
if not dl_file: # Didn't download right
print("Error downloading 7zip...")
shutil.rmtree(temp,ignore_errors=True)
return False
print("")
Expand All @@ -141,7 +144,12 @@ def check_7z(self):
self.u.grab("Press [enter] to exit...")
exit(1)
print("")
self.z_path = self.z_path64 if os.path.exists(self.z_path64) else self.z_path32 if os.path.exists(self.z_path32) else None
for drive in all_drives:
z_path64 = os.path.join(drive + "\\", "Program Files", "7-Zip", "7z.exe")
z_path32 = os.path.join(drive + "\\", "Program Files (x86)", "7-Zip", "7z.exe")
self.z_path = z_path64 if os.path.exists(z_path64) else z_path32 if os.path.exists(z_path32) else None
if self.z_path:
return True
return self.z_path and os.path.exists(self.z_path)

def check_bi(self):
Expand Down