Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions dev/breeze/src/airflow_breeze/utils/path_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,22 +418,26 @@ def cleanup_python_generated_files():
if get_verbose():
console_print("[info]Cleaning .pyc and __pycache__")
permission_errors = []
for path in AIRFLOW_ROOT_PATH.rglob("*.pyc"):
try:
path.unlink()
except FileNotFoundError:
# File has been removed in the meantime.
pass
except PermissionError:
permission_errors.append(path)
for path in AIRFLOW_ROOT_PATH.rglob("__pycache__"):
try:
shutil.rmtree(path)
except FileNotFoundError:
# File has been removed in the meantime.
pass
except PermissionError:
permission_errors.append(path)
for dirpath, dirnames, filenames in os.walk(AIRFLOW_ROOT_PATH):
# Skip node_modules and hidden directories (.*) — modify in place to prune os.walk
dirnames[:] = [d for d in dirnames if d != "node_modules" and not d.startswith(".")]
for filename in filenames:
if filename.endswith(".pyc"):
path = Path(dirpath) / filename
try:
path.unlink()
except FileNotFoundError:
pass
except PermissionError:
permission_errors.append(path)
if Path(dirpath).name == "__pycache__":
try:
shutil.rmtree(dirpath)
except FileNotFoundError:
pass
except PermissionError:
permission_errors.append(Path(dirpath))
dirnames.clear()
if permission_errors:
if platform.uname().system.lower() == "linux":
console_print("[warning]There were files that you could not clean-up:\n")
Expand Down
Loading