import json from datetime import datetime import config import os # Import os for path handling # Initialize Nextcloud client # nc = Nextcloud( # nextcloud_url=config.NEXTCLOUD_URL, # nc_auth_user=config.NEXTCLOUD_USERNAME, # nc_auth_pass=config.NEXTCLOUD_PASSWORD # ) NEXTCLOUD_NOTES_PATH = "/gpu_poor_release_notes.json" LOCAL_CACHE_FILE = "release_notes.json" def load_release_notes(): """Load release notes from Nextcloud with local file fallback.""" nc = config.get_nextcloud_client() # Use the singleton client try: # Try to load from Nextcloud remote_data = nc.files.download(NEXTCLOUD_NOTES_PATH) if remote_data: notes = json.loads(remote_data.decode('utf-8')) # Ensure the directory for the local cache file exists os.makedirs(os.path.dirname(LOCAL_CACHE_FILE) or '.', exist_ok=True) # Update local cache with open(LOCAL_CACHE_FILE, 'w') as f: json.dump(notes, f, indent=2) return notes except Exception as e: print(f"Could not load release notes from Nextcloud: {e}") # Try local cache try: with open(LOCAL_CACHE_FILE, 'r') as f: return json.load(f) except Exception as e: print(f"Could not load from local cache: {e}") # Return empty notes if both attempts fail return { "last_updated": datetime.now().isoformat(), "notes": [] } def get_release_notes_html(): """Generate HTML display of release notes.""" notes_data = load_release_notes() html = f"""