cool commited on
Update upload_suggestions.py
Browse files- upload_suggestions.py +12 -4
upload_suggestions.py
CHANGED
|
@@ -1,7 +1,15 @@
|
|
| 1 |
import os
|
| 2 |
from huggingface_hub import HfApi
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
DEST_PATH_IN_REPO = "suggestions/suggestions.db"
|
| 6 |
REPO_ID = "axxam/LibreTranslate_Kabyle"
|
| 7 |
|
|
@@ -10,8 +18,8 @@ def upload_db():
|
|
| 10 |
if not token:
|
| 11 |
print("HF_TOKEN not set — skipping upload.")
|
| 12 |
return
|
| 13 |
-
if not
|
| 14 |
-
print(
|
| 15 |
return
|
| 16 |
|
| 17 |
api = HfApi()
|
|
@@ -23,7 +31,7 @@ def upload_db():
|
|
| 23 |
repo_type="space",
|
| 24 |
token=token
|
| 25 |
)
|
| 26 |
-
print("suggestions.db uploaded successfully
|
| 27 |
except Exception as e:
|
| 28 |
print("Upload failed:", e)
|
| 29 |
|
|
|
|
| 1 |
import os
|
| 2 |
from huggingface_hub import HfApi
|
| 3 |
|
| 4 |
+
# List of possible locations where suggestions.db might be created
|
| 5 |
+
possible_paths = [
|
| 6 |
+
"/app/.local/share/db/suggestions.db",
|
| 7 |
+
"/root/.local/share/db/suggestions.db",
|
| 8 |
+
"/home/libretranslate/.local/share/db/suggestions.db"
|
| 9 |
+
]
|
| 10 |
+
|
| 11 |
+
# Find the first existing path
|
| 12 |
+
SOURCE_DB = next((p for p in possible_paths if os.path.exists(p)), None)
|
| 13 |
DEST_PATH_IN_REPO = "suggestions/suggestions.db"
|
| 14 |
REPO_ID = "axxam/LibreTranslate_Kabyle"
|
| 15 |
|
|
|
|
| 18 |
if not token:
|
| 19 |
print("HF_TOKEN not set — skipping upload.")
|
| 20 |
return
|
| 21 |
+
if not SOURCE_DB:
|
| 22 |
+
print("suggestions.db not found in any known location — skipping upload.")
|
| 23 |
return
|
| 24 |
|
| 25 |
api = HfApi()
|
|
|
|
| 31 |
repo_type="space",
|
| 32 |
token=token
|
| 33 |
)
|
| 34 |
+
print(f"suggestions.db uploaded successfully from {SOURCE_DB}")
|
| 35 |
except Exception as e:
|
| 36 |
print("Upload failed:", e)
|
| 37 |
|