mirror of
https://gitlab.com/chicken-riders/RcGcDw.git
synced 2025-02-23 00:24:09 +00:00
#195 Add config mitigation for new settings
This commit is contained in:
parent
8abd8dfd23
commit
065d67c90c
23
src/migrations/1.13.1.1.py
Normal file
23
src/migrations/1.13.1.1.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
from src.configloader import settings
|
||||
import logging
|
||||
|
||||
from src.migrations.utils import return_example_file
|
||||
|
||||
logger = logging.getLogger("rcgcdw.migrations.1.13.1.1")
|
||||
base_file = return_example_file()
|
||||
new_settings = settings.copy()
|
||||
|
||||
|
||||
def run():
|
||||
if "event_appearance" not in settings:
|
||||
try:
|
||||
settings["event_appearance"] = {}
|
||||
struct = settings['appearance']['embed']
|
||||
for key, value in struct.items():
|
||||
settings["event_appearance"][key] = value
|
||||
settings["event_appearance"][key]["emoji"] = base_file["event_appearance"]
|
||||
except KeyError:
|
||||
logger.error("Failed to migrate appearance embed.")
|
||||
else: # Don't do migrations
|
||||
return
|
||||
|
0
src/migrations/__init__.py
Normal file
0
src/migrations/__init__.py
Normal file
18
src/migrations/utils.py
Normal file
18
src/migrations/utils.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import requests
|
||||
import logging
|
||||
import json
|
||||
|
||||
discussion_logger = logging.getLogger("rcgcdw.migrations.utils")
|
||||
|
||||
|
||||
def return_example_file() -> dict:
|
||||
try:
|
||||
with open('settings.json.example', 'r') as example_file:
|
||||
return json.loads(example_file.read())
|
||||
except FileNotFoundError:
|
||||
try:
|
||||
f = requests.get("https://gitlab.com/piotrex43/RcGcDw/-/raw/master/settings.json.example")
|
||||
except:
|
||||
raise
|
||||
return json.loads(f.text)
|
||||
|
Loading…
Reference in a new issue