46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
"""Migrate flash_profiles.json from single binary_path to golden/user binary paths.
|
|
|
|
This script updates the JSON file to match the new FlashTarget structure.
|
|
"""
|
|
import json
|
|
from pathlib import Path
|
|
|
|
|
|
def migrate_profiles_json():
|
|
"""Migrate flash_profiles.json to new format."""
|
|
json_path = Path("flash_profiles.json")
|
|
|
|
if not json_path.exists():
|
|
print("flash_profiles.json not found")
|
|
return
|
|
|
|
# Load existing data
|
|
with open(json_path, 'r', encoding='utf-8') as f:
|
|
data = json.load(f)
|
|
|
|
# Migrate targets
|
|
migrated_count = 0
|
|
for target_id, target in data.get('targets', {}).items():
|
|
# Check if migration needed
|
|
if 'binary_path' in target and 'golden_binary_path' not in target:
|
|
# Move binary_path to user_binary_path (default)
|
|
old_binary = target.pop('binary_path')
|
|
target['golden_binary_path'] = None
|
|
target['user_binary_path'] = old_binary
|
|
migrated_count += 1
|
|
print(f"Migrated {target_id}: binary_path -> user_binary_path")
|
|
|
|
if migrated_count > 0:
|
|
# Save updated data
|
|
with open(json_path, 'w', encoding='utf-8') as f:
|
|
json.dump(data, f, indent=2)
|
|
|
|
print(f"\n✅ Migrated {migrated_count} targets successfully")
|
|
print(f"Updated file: {json_path}")
|
|
else:
|
|
print("No migration needed - file is already up to date")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
migrate_profiles_json()
|