Update resizing code for Windows

This commit is contained in:
CorpNewt 2022-04-02 09:42:22 -05:00 committed by GitHub
parent 8f5fac9275
commit cd1a2cd866
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,10 @@ class gibMacOS:
self.r = run.Run() self.r = run.Run()
self.min_w = 80 self.min_w = 80
self.min_h = 24 self.min_h = 24
self.u.resize(self.min_w, self.min_h) if os.name == "nt":
self.min_w = 120
self.min_h = 30
self.resize()
self.catalog_suffix = { self.catalog_suffix = {
"public" : "beta", "public" : "beta",
@ -56,9 +59,6 @@ class gibMacOS:
) )
def resize(self, width=0, height=0): def resize(self, width=0, height=0):
if os.name=="nt":
# Winders resizing is dumb... bail
return
width = width if width > self.min_w else self.min_w width = width if width > self.min_w else self.min_w
height = height if height > self.min_h else self.min_h height = height if height > self.min_h else self.min_h
self.u.resize(width, height) self.u.resize(width, height)
@ -410,18 +410,13 @@ class gibMacOS:
self.get_catalog_data() self.get_catalog_data()
def main(self, dmg = False): def main(self, dmg = False):
self.u.head() lines = [""]
print("") lines.append("Available Products:")
print("Available Products:") lines.append("")
print("")
num = 0
w = 0
pad = 12
if not len(self.mac_prods): if not len(self.mac_prods):
print("No installers in catalog!") lines.append("No installers in catalog!")
print("") lines.append("")
for p in self.mac_prods: for num,p in enumerate(self.mac_prods,start=1):
num += 1
var1 = "{}. {} {}".format(num, p["title"], p["version"]) var1 = "{}. {} {}".format(num, p["title"], p["version"])
if p["build"].lower() != "unknown": if p["build"].lower() != "unknown":
var1 += " ({})".format(p["build"]) var1 += " ({})".format(p["build"])
@ -429,25 +424,22 @@ class gibMacOS:
if self.find_recovery and p["installer"]: if self.find_recovery and p["installer"]:
# Show that it's a full installer # Show that it's a full installer
var2 += " - FULL Install" var2 += " - FULL Install"
w = len(var1) if len(var1) > w else w lines.append(var1)
w = len(var2) if len(var2) > w else w lines.append(var2)
print(var1) lines.append("")
print(var2) lines.append("M. Change Max-OS Version (Currently {})".format(self.num_to_macos(self.current_macos,for_url=False)))
print("") lines.append("C. Change Catalog (Currently {})".format(self.current_catalog))
print("M. Change Max-OS Version (Currently {})".format(self.num_to_macos(self.current_macos,for_url=False))) lines.append("I. Only Print URLs (Currently {})".format(self.print_urls))
print("C. Change Catalog (Currently {})".format(self.current_catalog))
print("I. Only Print URLs (Currently {})".format(self.print_urls))
if sys.platform.lower() == "darwin": if sys.platform.lower() == "darwin":
pad += 2 lines.append("S. Set Current Catalog to SoftwareUpdate Catalog")
print("S. Set Current Catalog to SoftwareUpdate Catalog") lines.append("L. Clear SoftwareUpdate Catalog")
print("L. Clear SoftwareUpdate Catalog") lines.append("R. Toggle Recovery-Only (Currently {})".format("On" if self.find_recovery else "Off"))
print("R. Toggle Recovery-Only (Currently {})".format("On" if self.find_recovery else "Off")) lines.append("U. Show Catalog URL")
print("U. Show Catalog URL") lines.append("Q. Quit")
print("Q. Quit") self.resize(len(max(lines)), len(lines)+5)
self.resize(w, (num*2)+pad) self.u.head()
if os.name=="nt": if os.name=="nt": lines.append("") # Add a final newline on Windows for formatting differences
# Formatting differences.. print("\n".join(lines))
print("")
menu = self.u.grab("Please select an option: ") menu = self.u.grab("Please select an option: ")
if not len(menu): if not len(menu):
return return
@ -488,6 +480,7 @@ class gibMacOS:
elif menu[0].lower() == "r": elif menu[0].lower() == "r":
self.find_recovery ^= True self.find_recovery ^= True
if menu[0].lower() in ["m","c","r"]: if menu[0].lower() in ["m","c","r"]:
self.resize()
self.u.head("Parsing Data") self.u.head("Parsing Data")
print("") print("")
print("Re-scanning products after url preference toggled...") print("Re-scanning products after url preference toggled...")