Skip to content

Commit

Permalink
Try modifying permission inline
Browse files Browse the repository at this point in the history
  • Loading branch information
mackenly committed Nov 28, 2023
1 parent f76bc1e commit 8aaa8fb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion script/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import json
import shutil
import stat
import subprocess
import sys
from tkinter import Tk
Expand Down Expand Up @@ -83,9 +84,16 @@
elif i.name == "icons":
icons_path = i.path


def remove_readonly(func, path, _):
""" Clear the readonly bit and reattempt the removal """
os.chmod(path, stat.S_IWRITE)
func(path)


# remove the old files
try:
shutil.rmtree(os.getcwd().replace("\\script", "\\out"))
shutil.rmtree(os.getcwd().replace("\\script", "\\out"), onerror=remove_readonly)
print("Removed old files.")
except FileNotFoundError:
print("No old files to remove, continuing...")
Expand Down

0 comments on commit 8aaa8fb

Please sign in to comment.