Files
SemesterapparatsManager/src/backend/delete_temp_contents.py

25 lines
571 B
Python

import os
from pathlib import Path
from src import settings
database = settings.database
def delete_temp_contents():
"""
delete_temp_contents deletes the contents of the temp directory.
"""
path = database.temp
path = path.replace("~", str(Path.home()))
path = Path(path)
path = path.resolve()
for root, dirs, files in os.walk(path):
for file in files:
os.remove(os.path.join(root, file))
for dir in dirs:
os.rmdir(os.path.join(root, dir))
if __name__ == "__main__":
delete_temp_contents()