Skip to content

Commit

Permalink
Add exception capture to the OS operation in the run method of the Cl…
Browse files Browse the repository at this point in the history
…ean class in the setup. py file

Signed-off-by: mataotao <[email protected]>
  • Loading branch information
mataotao committed Sep 3, 2024
1 parent f1ed1f8 commit a6afd0a
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 a6afd0a

Please sign in to comment.