Update app.py
Browse files
app.py
CHANGED
@@ -29,12 +29,17 @@ from dotenv import load_dotenv
|
|
29 |
|
30 |
nltk_data_path = "/app/nltk_data"
|
31 |
|
32 |
-
# Überprüfen, ob der Pfad eine Datei
|
33 |
if os.path.exists(nltk_data_path):
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
os.
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
# Verzeichnis erneut erstellen
|
40 |
os.makedirs(nltk_data_path, exist_ok=True)
|
@@ -50,7 +55,6 @@ print(nltk.data.path)
|
|
50 |
|
51 |
# Lade Umgebungsvariablen (falls benötigt)
|
52 |
load_dotenv()
|
53 |
-
|
54 |
# Logging Konfiguration mit sicherer Pfadangabe
|
55 |
logging.basicConfig(
|
56 |
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
|
|
29 |
|
30 |
nltk_data_path = "/app/nltk_data"
|
31 |
|
32 |
+
# Überprüfen, ob der Pfad eine Datei oder ein Verzeichnis ist
|
33 |
if os.path.exists(nltk_data_path):
|
34 |
+
try:
|
35 |
+
if os.path.isdir(nltk_data_path):
|
36 |
+
shutil.rmtree(nltk_data_path) # Falls es ein Verzeichnis ist, lösche es
|
37 |
+
elif os.path.isfile(nltk_data_path):
|
38 |
+
os.remove(nltk_data_path) # Falls es eine Datei ist, lösche sie
|
39 |
+
except PermissionError as e:
|
40 |
+
print(f"Zugriffsfehler: {e}. Kann das Verzeichnis oder die Datei nicht löschen.")
|
41 |
+
else:
|
42 |
+
print(f"{nltk_data_path} existiert nicht.")
|
43 |
|
44 |
# Verzeichnis erneut erstellen
|
45 |
os.makedirs(nltk_data_path, exist_ok=True)
|
|
|
55 |
|
56 |
# Lade Umgebungsvariablen (falls benötigt)
|
57 |
load_dotenv()
|
|
|
58 |
# Logging Konfiguration mit sicherer Pfadangabe
|
59 |
logging.basicConfig(
|
60 |
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|