Spaces:
Running
Running
Update release_notes.py
Browse files- release_notes.py +10 -6
release_notes.py
CHANGED
|
@@ -1,24 +1,28 @@
|
|
| 1 |
import json
|
| 2 |
from datetime import datetime
|
| 3 |
import config
|
| 4 |
-
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
NEXTCLOUD_NOTES_PATH = "/gpu_poor_release_notes.json"
|
| 8 |
LOCAL_CACHE_FILE = "release_notes.json"
|
| 9 |
|
| 10 |
def load_release_notes():
|
| 11 |
"""Load release notes from Nextcloud with local file fallback."""
|
|
|
|
| 12 |
try:
|
| 13 |
-
nc = Nextcloud(
|
| 14 |
-
nextcloud_url=config.NEXTCLOUD_URL,
|
| 15 |
-
nc_auth_user=config.NEXTCLOUD_USERNAME,
|
| 16 |
-
nc_auth_pass=config.NEXTCLOUD_PASSWORD
|
| 17 |
-
)
|
| 18 |
# Try to load from Nextcloud
|
| 19 |
remote_data = nc.files.download(NEXTCLOUD_NOTES_PATH)
|
| 20 |
if remote_data:
|
| 21 |
notes = json.loads(remote_data.decode('utf-8'))
|
|
|
|
|
|
|
| 22 |
# Update local cache
|
| 23 |
with open(LOCAL_CACHE_FILE, 'w') as f:
|
| 24 |
json.dump(notes, f, indent=2)
|
|
|
|
| 1 |
import json
|
| 2 |
from datetime import datetime
|
| 3 |
import config
|
| 4 |
+
import os # Import os for path handling
|
| 5 |
|
| 6 |
+
# Initialize Nextcloud client
|
| 7 |
+
# nc = Nextcloud(
|
| 8 |
+
# nextcloud_url=config.NEXTCLOUD_URL,
|
| 9 |
+
# nc_auth_user=config.NEXTCLOUD_USERNAME,
|
| 10 |
+
# nc_auth_pass=config.NEXTCLOUD_PASSWORD
|
| 11 |
+
# )
|
| 12 |
|
| 13 |
NEXTCLOUD_NOTES_PATH = "/gpu_poor_release_notes.json"
|
| 14 |
LOCAL_CACHE_FILE = "release_notes.json"
|
| 15 |
|
| 16 |
def load_release_notes():
|
| 17 |
"""Load release notes from Nextcloud with local file fallback."""
|
| 18 |
+
nc = config.get_nextcloud_client() # Use the singleton client
|
| 19 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
# Try to load from Nextcloud
|
| 21 |
remote_data = nc.files.download(NEXTCLOUD_NOTES_PATH)
|
| 22 |
if remote_data:
|
| 23 |
notes = json.loads(remote_data.decode('utf-8'))
|
| 24 |
+
# Ensure the directory for the local cache file exists
|
| 25 |
+
os.makedirs(os.path.dirname(LOCAL_CACHE_FILE) or '.', exist_ok=True)
|
| 26 |
# Update local cache
|
| 27 |
with open(LOCAL_CACHE_FILE, 'w') as f:
|
| 28 |
json.dump(notes, f, indent=2)
|