Files
Key-service-Server/Inventarsystem-Lizenz-Verwaltung/backup.py
T
Maximilian G. 316581dd8f feat: Add mobile compatibility utilities and enhance UI templates
- Introduced mobile compatibility utilities in mobile_compatibility.js for better handling of file uploads and image previews on mobile devices.
- Created base.html as a foundational template with responsive design and mobile compatibility features.
- Developed login.html for user authentication with a password toggle feature.
- Added main.html for displaying license keys and HWIDs with options to generate new keys and upload backups.
- Implemented a test script (test.sh) for validating license information via API.
- Created verify.py for license key validation and management, including functions for loading, checking, and registering keys.
- Added version.txt to track the current version of the application.
2026-03-23 12:39:44 +00:00

43 lines
1.1 KiB
Python

import os
import json
from pathlib import Path
LICENSES_FILE = os.path.abspath(os.path.join(os.path.dirname(__file__),"licenses.json"))
def load_licenses() -> dict:
"""Load licenses.json file and return its content."""
try:
with open(LICENSES_FILE, "r") as f:
return json.load(f)
except (FileNotFoundError, json.JSONDecodeError):
return []
def save_licenses(data: dict) -> bool:
"""Save licenses data to licenses.json file."""
try:
os.makedirs(os.path.dirname(LICENSES_FILE), exist_ok=True)
with open(LICENSES_FILE, "w") as f:
json.dump(data, f, indent=2)
return True
except Exception as e:
print(f"Error saving licenses: {e}")
return False
def export_backup() -> dict:
"""Export current licenses.json content."""
return load_licenses()
def import_backup(data: dict) -> bool:
"""Import and restore licenses from backup data."""
try:
if not isinstance(data, list):
return False
save_licenses(data)
return True
except Exception as e:
print(f"Error importing backup: {e}")
return False