mirror of
https://github.com/corpnewt/gibMacOS.git
synced 2024-09-20 09:30:34 +00:00
Deduplicate printing empty line after head
This commit is contained in:
parent
1e82ba0813
commit
dfc6e2feb8
2 changed files with 1 additions and 16 deletions
|
@ -239,6 +239,7 @@ class Utils:
|
||||||
middle = middle[:-di] + "...#"
|
middle = middle[:-di] + "...#"
|
||||||
print(middle)
|
print(middle)
|
||||||
print("#"*width)
|
print("#"*width)
|
||||||
|
print("")
|
||||||
|
|
||||||
def resize(self, width, height):
|
def resize(self, width, height):
|
||||||
print('\033[8;{};{}t'.format(height, width))
|
print('\033[8;{};{}t'.format(height, width))
|
||||||
|
|
16
gibMacOS.py
16
gibMacOS.py
|
@ -106,7 +106,6 @@ class gibMacOS:
|
||||||
message += "Please ensure you have a working internet connection."
|
message += "Please ensure you have a working internet connection."
|
||||||
raise ProgramError(message, title="Catalog Data Error")
|
raise ProgramError(message, title="Catalog Data Error")
|
||||||
self.u.head("Parsing Data")
|
self.u.head("Parsing Data")
|
||||||
print("")
|
|
||||||
print("Scanning products after catalog download...\n")
|
print("Scanning products after catalog download...\n")
|
||||||
self.mac_prods = self.get_dict_for_prods(self.get_installers())
|
self.mac_prods = self.get_dict_for_prods(self.get_installers())
|
||||||
|
|
||||||
|
@ -151,7 +150,6 @@ class gibMacOS:
|
||||||
# Gets the data based on our current_catalog
|
# Gets the data based on our current_catalog
|
||||||
url = self.build_url(catalog=self.current_catalog, version=self.current_macos)
|
url = self.build_url(catalog=self.current_catalog, version=self.current_macos)
|
||||||
self.u.head("Downloading Catalog")
|
self.u.head("Downloading Catalog")
|
||||||
print("")
|
|
||||||
if local:
|
if local:
|
||||||
print("Checking locally for {}".format(self.plist))
|
print("Checking locally for {}".format(self.plist))
|
||||||
cwd = os.getcwd()
|
cwd = os.getcwd()
|
||||||
|
@ -307,7 +305,6 @@ class gibMacOS:
|
||||||
done = []
|
done = []
|
||||||
if self.print_urls:
|
if self.print_urls:
|
||||||
self.u.head("Download Links")
|
self.u.head("Download Links")
|
||||||
print("")
|
|
||||||
print("{}:\n".format(name))
|
print("{}:\n".format(name))
|
||||||
print("\n".join([" - {} \n --> {}".format(os.path.basename(x), x) for x in dl_list]))
|
print("\n".join([" - {} \n --> {}".format(os.path.basename(x), x) for x in dl_list]))
|
||||||
if self.interactive:
|
if self.interactive:
|
||||||
|
@ -320,7 +317,6 @@ class gibMacOS:
|
||||||
if os.path.exists(os.path.join(os.getcwd(), self.saves, self.current_catalog, name)):
|
if os.path.exists(os.path.join(os.getcwd(), self.saves, self.current_catalog, name)):
|
||||||
while True:
|
while True:
|
||||||
self.u.head("Already Exists")
|
self.u.head("Already Exists")
|
||||||
print("")
|
|
||||||
print("It looks like you've already downloaded {}".format(name))
|
print("It looks like you've already downloaded {}".format(name))
|
||||||
print("")
|
print("")
|
||||||
if not self.interactive:
|
if not self.interactive:
|
||||||
|
@ -339,7 +335,6 @@ class gibMacOS:
|
||||||
for x in dl_list:
|
for x in dl_list:
|
||||||
c += 1
|
c += 1
|
||||||
self.u.head("Downloading File {} of {}".format(c, len(dl_list)))
|
self.u.head("Downloading File {} of {}".format(c, len(dl_list)))
|
||||||
print("")
|
|
||||||
if len(done):
|
if len(done):
|
||||||
print("\n".join(["{} --> {}".format(y["name"], "Succeeded" if y["status"] else "Failed") for y in done]))
|
print("\n".join(["{} --> {}".format(y["name"], "Succeeded" if y["status"] else "Failed") for y in done]))
|
||||||
print("")
|
print("")
|
||||||
|
@ -356,7 +351,6 @@ class gibMacOS:
|
||||||
succeeded = [x for x in done if x["status"]]
|
succeeded = [x for x in done if x["status"]]
|
||||||
failed = [x for x in done if not x["status"]]
|
failed = [x for x in done if not x["status"]]
|
||||||
self.u.head("Downloaded {} of {}".format(len(succeeded), len(dl_list)))
|
self.u.head("Downloaded {} of {}".format(len(succeeded), len(dl_list)))
|
||||||
print("")
|
|
||||||
print("Succeeded:")
|
print("Succeeded:")
|
||||||
if len(succeeded):
|
if len(succeeded):
|
||||||
for x in succeeded:
|
for x in succeeded:
|
||||||
|
@ -382,7 +376,6 @@ class gibMacOS:
|
||||||
def show_catalog_url(self):
|
def show_catalog_url(self):
|
||||||
self.resize()
|
self.resize()
|
||||||
self.u.head()
|
self.u.head()
|
||||||
print("")
|
|
||||||
print("Current Catalog: {}".format(self.current_catalog))
|
print("Current Catalog: {}".format(self.current_catalog))
|
||||||
print("Max macOS Version: {}".format(self.num_to_macos(self.current_macos,for_url=False)))
|
print("Max macOS Version: {}".format(self.num_to_macos(self.current_macos,for_url=False)))
|
||||||
print("")
|
print("")
|
||||||
|
@ -394,7 +387,6 @@ class gibMacOS:
|
||||||
def pick_catalog(self):
|
def pick_catalog(self):
|
||||||
self.resize()
|
self.resize()
|
||||||
self.u.head("Select SU Catalog")
|
self.u.head("Select SU Catalog")
|
||||||
print("")
|
|
||||||
count = 0
|
count = 0
|
||||||
for x in self.catalog_suffix:
|
for x in self.catalog_suffix:
|
||||||
count += 1
|
count += 1
|
||||||
|
@ -427,7 +419,6 @@ class gibMacOS:
|
||||||
def pick_macos(self):
|
def pick_macos(self):
|
||||||
self.resize()
|
self.resize()
|
||||||
self.u.head("Select Max macOS Version")
|
self.u.head("Select Max macOS Version")
|
||||||
print("")
|
|
||||||
print("Currently set to {}".format(self.num_to_macos(self.current_macos,for_url=False)))
|
print("Currently set to {}".format(self.num_to_macos(self.current_macos,for_url=False)))
|
||||||
print("")
|
print("")
|
||||||
print("M. Main Menu")
|
print("M. Main Menu")
|
||||||
|
@ -501,7 +492,6 @@ class gibMacOS:
|
||||||
elif menu[0].lower() == "l" and sys.platform.lower() == "darwin":
|
elif menu[0].lower() == "l" and sys.platform.lower() == "darwin":
|
||||||
# Clear the software update catalog
|
# Clear the software update catalog
|
||||||
self.u.head("Clearing SU CatalogURL")
|
self.u.head("Clearing SU CatalogURL")
|
||||||
print("")
|
|
||||||
print("sudo softwareupdate --clear-catalog")
|
print("sudo softwareupdate --clear-catalog")
|
||||||
self.r.run({"args":["softwareupdate","--clear-catalog"],"sudo":True})
|
self.r.run({"args":["softwareupdate","--clear-catalog"],"sudo":True})
|
||||||
print("")
|
print("")
|
||||||
|
@ -510,7 +500,6 @@ class gibMacOS:
|
||||||
elif menu[0].lower() == "s" and sys.platform.lower() == "darwin":
|
elif menu[0].lower() == "s" and sys.platform.lower() == "darwin":
|
||||||
# Set the software update catalog to our current catalog url
|
# Set the software update catalog to our current catalog url
|
||||||
self.u.head("Setting SU CatalogURL")
|
self.u.head("Setting SU CatalogURL")
|
||||||
print("")
|
|
||||||
url = self.build_url(catalog=self.current_catalog, version=self.current_macos)
|
url = self.build_url(catalog=self.current_catalog, version=self.current_macos)
|
||||||
print("Setting catalog URL to:\n{}".format(url))
|
print("Setting catalog URL to:\n{}".format(url))
|
||||||
print("")
|
print("")
|
||||||
|
@ -525,7 +514,6 @@ class gibMacOS:
|
||||||
if menu[0].lower() in ["m","c","r"]:
|
if menu[0].lower() in ["m","c","r"]:
|
||||||
self.resize()
|
self.resize()
|
||||||
self.u.head("Parsing Data")
|
self.u.head("Parsing Data")
|
||||||
print("")
|
|
||||||
print("Re-scanning products after url preference toggled...\n")
|
print("Re-scanning products after url preference toggled...\n")
|
||||||
self.mac_prods = self.get_dict_for_prods(self.get_installers())
|
self.mac_prods = self.get_dict_for_prods(self.get_installers())
|
||||||
return
|
return
|
||||||
|
@ -541,7 +529,6 @@ class gibMacOS:
|
||||||
|
|
||||||
def get_latest(self, device_id = None, dmg = False):
|
def get_latest(self, device_id = None, dmg = False):
|
||||||
self.u.head("Downloading Latest")
|
self.u.head("Downloading Latest")
|
||||||
print("")
|
|
||||||
prods = sorted(self.mac_prods, key=lambda x:x['version'], reverse=True)
|
prods = sorted(self.mac_prods, key=lambda x:x['version'], reverse=True)
|
||||||
if device_id:
|
if device_id:
|
||||||
prod = next(p for p in prods if device_id.lower() in p["device_ids"])
|
prod = next(p for p in prods if device_id.lower() in p["device_ids"])
|
||||||
|
@ -553,7 +540,6 @@ class gibMacOS:
|
||||||
|
|
||||||
def get_for_product(self, prod, dmg = False):
|
def get_for_product(self, prod, dmg = False):
|
||||||
self.u.head("Downloading for {}".format(prod))
|
self.u.head("Downloading for {}".format(prod))
|
||||||
print("")
|
|
||||||
for p in self.mac_prods:
|
for p in self.mac_prods:
|
||||||
if p["product"] == prod:
|
if p["product"] == prod:
|
||||||
self.download_prod(p, dmg)
|
self.download_prod(p, dmg)
|
||||||
|
@ -562,7 +548,6 @@ class gibMacOS:
|
||||||
|
|
||||||
def get_for_version(self, vers, build = None, device_id = None, dmg = False):
|
def get_for_version(self, vers, build = None, device_id = None, dmg = False):
|
||||||
self.u.head("Downloading for {} {}".format(vers, build or ""))
|
self.u.head("Downloading for {} {}".format(vers, build or ""))
|
||||||
print("")
|
|
||||||
# Map the versions to their names
|
# Map the versions to their names
|
||||||
v = self.version_names.get(vers.lower(),vers.lower())
|
v = self.version_names.get(vers.lower(),vers.lower())
|
||||||
v_dict = {}
|
v_dict = {}
|
||||||
|
@ -657,7 +642,6 @@ if __name__ == '__main__':
|
||||||
g.main(args.dmg)
|
g.main(args.dmg)
|
||||||
except ProgramError as e:
|
except ProgramError as e:
|
||||||
g.u.head(e.title)
|
g.u.head(e.title)
|
||||||
print("")
|
|
||||||
print(str(e))
|
print(str(e))
|
||||||
print("")
|
print("")
|
||||||
g.u.grab("Press [enter] to return...")
|
g.u.grab("Press [enter] to return...")
|
||||||
|
|
Loading…
Reference in a new issue