Skip to content

Commit

Permalink
Handling exception for old files
Browse files Browse the repository at this point in the history
  • Loading branch information
mackenly committed Nov 29, 2023
1 parent 1222086 commit 435a0aa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion script/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@

# remove the old files
try:
os.chmod(os.getcwd().replace("\\script", "\\out"), 0o777)
shutil.rmtree(os.getcwd().replace("\\script", "\\out"))
print("Removed old files.")
except FileNotFoundError:
print("No old files to remove, continuing...")
except PermissionError:
print("Permission error on old files (they might not exist), continuing...")

# create directories
os.mkdir(os.getcwd().replace("\\script", "\\out"))
Expand Down

0 comments on commit 435a0aa

Please sign in to comment.