Skip to content

Commit

Permalink
Merge pull request #6016 from faker-king/mtt
Browse files Browse the repository at this point in the history
Add exception capture to the OS operation in the run method of the Cl…
  • Loading branch information
richtja committed Sep 3, 2024
2 parents f1ed1f8 + a6afd0a commit a2e1ca5
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,19 @@ def run(self):
cleaning_list += list(Path("./docs/source/api/").rglob("*.rst"))

for e in cleaning_list:
if not os.path.exists(e):
continue
if os.path.isfile(e):
os.remove(e)
if os.path.isdir(e):
shutil.rmtree(e)
try:
if not os.path.exists(e):
continue
if os.path.isfile(e):
os.remove(e)
if os.path.isdir(e):
shutil.rmtree(e)
except FileNotFoundError:
print(f"File not found: {e}, unable to delete.")
except PermissionError:
print(f"Permission denied for {e}, unable to delete.")
except Exception as ex:
print(f"An error occurred while deleting {e}: {ex}")

self.clean_optional_plugins()

Expand Down

0 comments on commit a2e1ca5

Please sign in to comment.