Log downloaded files as you go

This commit is contained in:
CorpNewt 2018-09-26 05:01:35 -05:00 committed by GitHub
parent ccdb3d4d9a
commit 651303f0a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -169,12 +169,14 @@ class gibMacOS:
self.u.grab("Press [enter] to return...") self.u.grab("Press [enter] to return...")
return return
c = 0 c = 0
failed = [] done = []
succeeded = []
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("") print("")
if len(done):
print("\n".join(["{} --> {}".format(x["name"], "Succeeded" if x["status"] else "Failed") for x in done]))
print("")
if dmg: if dmg:
print("NOTE: Only Downloading DMG Files") print("NOTE: Only Downloading DMG Files")
print("") print("")
@ -182,25 +184,30 @@ class gibMacOS:
print("") print("")
try: try:
self.d.stream_to_file(x, os.path.join(os.getcwd(), self.saves, self.current_catalog, name, os.path.basename(x))) self.d.stream_to_file(x, os.path.join(os.getcwd(), self.saves, self.current_catalog, name, os.path.basename(x)))
succeeded.append(os.path.basename(x)) done.append({"name":os.path.basename(x), "status":True})
except: except:
failed.append(os.path.basename(x)) done.append({"name":os.path.basename(x), "status":False})
succeeded = [x for x in done if 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("")
print("Succeeded:") print("Succeeded:")
if len(succeeded): if len(succeeded):
for x in succeeded: for x in succeeded:
print(" {}".format(x)) print(" {}".format(x["name"]))
else: else:
print(" None") print(" None")
print("") print("")
print("Failed:") print("Failed:")
if len(failed): if len(failed):
for x in failed: for x in failed:
print(" {}".format(x)) print(" {}".format(x["name"]))
else: else:
print(" None") print(" None")
print("") print("")
print("Files saved to:")
print(" {}".format(os.path.join(os.getcwd(), self.saves, self.current_catalog, name)))
print("")
self.u.grab("Press [enter] to return...") self.u.grab("Press [enter] to return...")
def main(self, dmg = False): def main(self, dmg = False):