MQL5-Google-Onedrive/scripts/fix_profiles.py
google-labs-jules[bot] 878e4e5d83 feat: Secure bridge integration, refactor EAs, and add profile maintenance script
- Created `mt5/MQL5/Include/ZoloBridge.mqh` for shared, secure (HTTPS) bridge logic with proper JSON sanitization.
- Created `ExpertMACD_Enhanced.mq5`, `ExpertMAMA_Enhanced.mq5`, and `ExpertMAPSAR_Enhanced.mq5` using standard library and ZOLO bridge.
- Refactored `EXNESS_GenX_Trader.mq5` and `SMC_TrendBreakout_MTF_EA.mq5` to use `ZoloBridge.mqh` and updated default URL to `https://genx-fx.com/api/signal`.
- Updated `scripts/deploy_docker_hub.sh` and `scripts/update_vps.sh` to support `DOCKER_USERNAME` and `DOCKER_PASSWORD` environment variables.
- Added `scripts/fix_profiles.py` to copy defaults to empty profile directories.
- Added `SECRETS_TEMPLATE.md` for credential management guidance.
- Updated EA link properties to Forge URL.
2026-01-22 01:08:24 +00:00

77 lines
2.4 KiB
Python
Executable file

#!/usr/bin/env python3
import os
import shutil
import sys
from pathlib import Path
def fix_profiles(mql5_dir):
"""
Copies files from 'Default' profile to other profiles if they are empty.
"""
mql5_path = Path(mql5_dir)
# Handle case where user passes the root folder containing MQL5
if (mql5_path / "MQL5").exists():
mql5_path = mql5_path / "MQL5"
charts_dir = mql5_path / "Profiles" / "Charts"
if not charts_dir.exists():
print(f"❌ Profiles/Charts directory not found at {charts_dir}")
print("Please provide the path to the MQL5 data folder.")
return
default_dir = charts_dir / "Default"
if not default_dir.exists():
print(f"'Default' profile not found at {default_dir}. Cannot restore defaults.")
return
print(f"✅ Using 'Default' profile source: {default_dir}")
# Iterate over all subdirectories in Charts
count_fixed = 0
for profile_dir in charts_dir.iterdir():
if not profile_dir.is_dir():
continue
if profile_dir.name.lower() == "default":
continue
# Check if empty (no files)
# We look for any file to be safe, or maybe specific .chr files
has_files = any(f.is_file() for f in profile_dir.iterdir())
if not has_files:
print(f"⚠️ Profile '{profile_dir.name}' is empty. Copying defaults...")
try:
# Copy all files from Default to this profile
for item in default_dir.iterdir():
if item.is_file():
shutil.copy2(item, profile_dir)
print(f" ✅ Restored defaults for '{profile_dir.name}'")
count_fixed += 1
except Exception as e:
print(f" ❌ Failed to restore '{profile_dir.name}': {e}")
else:
# print(f" Profile '{profile_dir.name}' is intact.")
pass
if count_fixed == 0:
print("All profiles are intact. No changes made.")
else:
print(f"Fixed {count_fixed} profiles.")
if __name__ == "__main__":
if len(sys.argv) > 1:
target = sys.argv[1]
else:
# Try to guess
cwd = Path.cwd()
if (cwd / "mt5" / "MQL5").exists():
target = cwd / "mt5"
elif (cwd / "MQL5").exists():
target = cwd
else:
target = cwd
print(f"Running Profile Fixer on: {target}")
fix_profiles(target)