Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
lempira committed Nov 22, 2024
1 parent 8f7cccd commit 0618237
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions template_content/post_init.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import shutil
import sys
from pathlib import Path
import os


def main():
Expand All @@ -21,9 +22,19 @@ def main():

if project_dir.exists():
try:
# Change working directory to parent before deletion
os.chdir(project_dir.parent)
shutil.rmtree(project_dir)
except:
pass
except PermissionError as e:
print(f"Failed to clean up {project_dir}: Unable to remove directory due to permissions: {e}", file=sys.stderr)
print("Please ensure no files are open in the directory and try again.", file=sys.stderr)
sys.exit(1)
except OSError as e:
print(f"Failed to clean up {project_dir}: {str(e)}", file=sys.stderr)
print("Please ensure no files are open in the directory and try again.", file=sys.stderr)
sys.exit(1)
except Exception as e:
print(f"Failed to clean up {project_dir}: {str(e)}", file=sys.stderr)

sys.exit(1)

Expand Down

0 comments on commit 0618237

Please sign in to comment.