delete file

This commit is contained in:
WorldTeacher
2024-06-13 10:04:26 +02:00
parent 4280a05c7d
commit d3f9cfd177

View File

@@ -1,57 +0,0 @@
import os
from pathlib import Path
from omegaconf import OmegaConf
from src.backend.database import Database
db = Database()
config = OmegaConf.load("config.yaml")
def main():
_selected_doc_name = "sap71.csv"
_selected_doc_location = "Database"
_selected_doc_filetype = "csv"
print(_selected_doc_name, _selected_doc_filetype)
if not _selected_doc_location == "Database":
path = Path(_selected_doc_location)
path: Path = path + "/" + _selected_doc_name
if os.getenv("OS") == "Windows_NT":
path = path.resolve()
os.startfile(path)
else:
path = path.resolve()
os.system(f"open {path}")
else:
try:
_selected_doc_name = db.recreateFile(
_selected_doc_name, "71", filetype=_selected_doc_filetype
)
except Exception as e:
print(e)
path = config.database.tempdir + _selected_doc_name
# if ~ in path, replace it with the home directory
if "~" in path:
path = path.replace("~", str(Path.home()))
path = Path(path)
if os.getenv("OS") == "Windows_NT":
path = path.resolve()
os.startfile(path)
else:
path = path.resolve()
os.system(f"open {path}")
# filebytes = self.db.get_blob(
# _selected_doc_name,
# self.active_apparat(),
# )
# # use io.BytesIO to create a file-like object from the bytes and open it in the respective program
# file = io.BytesIO(filebytes)
# file.name = _selected_doc_name
# QtGui.QDesktopServices.openUrl(QtCore.QUrl(file))
# print(type(filebytes))
if __name__ == "__main__":
main()