Updated to use pathlib instead of os

This commit is contained in:
peterbousaada
2024-06-13 08:59:16 -04:00
committed by Travis Abendshien
parent e0cc0dd5a7
commit a074912ac8

View File

@@ -1,5 +1,5 @@
import logging
import os.path
import pathlib
import subprocess
import sys
import traceback
@@ -15,12 +15,13 @@ logging.basicConfig(format="%(message)s", level=logging.INFO)
def delete_file(path: str | Path, callback: Callable):
_path = str(path)
_file = Path(_path)
logging.info(f"Deleting file: {_path}")
if not os.path.exists(_path):
if not _file.exists():
logging.error(f"File not found: {_path}")
return
try:
os.remove(path)
_file.unlink()
callback()
except:
traceback.print_exc()