From a581bba757b00c84e6d9fc3b1da6c85a0bdbc638 Mon Sep 17 00:00:00 2001 From: Frisk Date: Tue, 10 Jan 2023 17:12:50 +0100 Subject: [PATCH] Updated migrations to not have static settings name --- src/migrations/11311.py | 5 +++-- src/migrations/falsytypes.py | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/migrations/11311.py b/src/migrations/11311.py index a7fb960..182ab8a 100644 --- a/src/migrations/11311.py +++ b/src/migrations/11311.py @@ -1,4 +1,5 @@ from src.configloader import settings, load_settings +from src.argparser import command_args import logging import shutil import time @@ -33,8 +34,8 @@ def run(): except KeyError: logger.exception("Failed to migrate appearance embed.") sys.exit(1) - shutil.copy("settings.json", "settings.json.{}.bak".format(int(time.time()))) - with open("settings.json", "w", encoding="utf-8") as new_write: + shutil.copy(command_args.settings, command_args.settings+".{}.bak".format(int(time.time()))) + with open(command_args.settings, "w", encoding="utf-8") as new_write: new_write.write(json.dumps(new_settings, indent=4)) load_settings() logger.info("Migration 1.13.1.1 has been successful.") diff --git a/src/migrations/falsytypes.py b/src/migrations/falsytypes.py index 521647a..736cca7 100644 --- a/src/migrations/falsytypes.py +++ b/src/migrations/falsytypes.py @@ -1,4 +1,5 @@ from src.configloader import settings, load_settings +from src.argparser import command_args import logging import shutil import time @@ -8,6 +9,7 @@ import sys logger = logging.getLogger("rcgcdw.migrations.falsytypes") new_settings = settings.copy() + def run(): change = False try: @@ -28,8 +30,8 @@ def run(): sys.exit(1) if change: logger.info("Running migration falsytypes") - shutil.copy("settings.json", "settings.json.{}.bak".format(int(time.time()))) - with open("settings.json", "w", encoding="utf-8") as new_write: + shutil.copy(command_args.settings, command_args.settings+".{}.bak".format(int(time.time()))) + with open(command_args.settings, "w", encoding="utf-8") as new_write: new_write.write(json.dumps(new_settings, indent=4)) load_settings() logger.info("Migration falsytypes has been successful.")