Skip to content

Commit

Permalink
Merge pull request #6 from Fittiboy/KeyboardInterrupt
Browse files Browse the repository at this point in the history
Cleanup partial files on `KeyboardInterrupt`
  • Loading branch information
Fittiboy authored Jul 1, 2021
2 parents 52371a9 + 15c5fc2 commit f6b5473
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions clipper.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def dl_progress(count, block_size, total_size):
Include the quotation marks and curly brackets!"""
raise FileNotFoundError(e_msg)

failed = 0
game_ids = {}
b_ids = {}
start = None
Expand Down Expand Up @@ -303,7 +304,14 @@ def dl_progress(count, block_size, total_size):
upload.Upload()
remove(fullpath)
print()
except KeyboardInterrupt:
if isfile(fullpath):
remove(fullpath)
sys.exit("Exiting...")
except Exception as e:
if isfile(fullpath):
remove(fullpath)
failed += 1
print(e)
if not isfile(base_path + "failed.txt"):
with open("failed.txt", "w"):
Expand All @@ -313,3 +321,7 @@ def dl_progress(count, block_size, total_size):
print(file_name + ": FAILED!")

start += timedelta(days=1)

if failed:
print(f"\n{str(failed)} clips not downloaded!"
" Check failed.txt and try downloading them manually.")

0 comments on commit f6b5473

Please sign in to comment.