now sieloader can automatically tell SIERRA to lunch universal addon

This commit is contained in:
2025-01-02 06:29:52 +03:00
parent ce729db0a1
commit ed11ccc53e
2 changed files with 14 additions and 3 deletions

View File

@@ -9,6 +9,8 @@ if os.name == "nt":
sierra_path = sierra_search()
else:
sierra_path = None
sierra_config_path = os.path.expanduser("~") + "/SIERRA_CONF.json"
addons_dir = f"{os.getcwd()}/addons/"
# second, check if addons folder exist, and if is, load addons from there
@@ -21,10 +23,10 @@ if os.path.isdir(addons_dir):
# after we're done running installation scripts, we make universal addon file which user will load
# and to make it easier, we will also open where file stored
universal_addon_file = generate_addon_file(addons_dir, addons)
edit_sierra_config(sierra_config_path, universal_addon_file)
if os.name == "nt":
subprocess.Popen([os.path.join(os.getenv('WINDIR'), 'explorer.exe'), '/select,', os.path.abspath(universal_addon_file)], start_new_session=True)
subprocess.Popen([os.path.join(sierra_path, 'SIERRA.exe')], start_new_session=True)
else:
showinfo('Thank you for using sieloader', 'Your universal addon file is ready, you can find it in sieloader program folder called sieloader_addons.yaml. Thank you for using sieloader!')
showinfo('Thank you for using sieloader', 'Your universal addon file is ready, SIERRA configured to lunch it on next start. Thank you for using sieloader!')
else:
os.mkdir(addons_dir)

View File

@@ -1,5 +1,7 @@
import io
import json
import os
if os.name == "nt":
import winreg
@@ -50,6 +52,13 @@ def run_install_script(addons_dir, addon):
pass
def edit_sierra_config(config_file, addon_file):
data = json.loads("{}")
with open(config_file, "w") as file:
data['IVK_CFG_PATH'] = addon_file
json.dump(data, file)
def generate_addon_file(addons_path, addons):
paths = []
scripts = []
@@ -61,4 +70,4 @@ def generate_addon_file(addons_path, addons):
with io.open(f"sieloader_addons.yaml", 'w', encoding='utf8') as file:
data = {"PATHS": paths, 'SCRIPTS': scripts}
yaml.dump(data, file, default_flow_style=False, allow_unicode=True)
return f"sieloader_addons.yaml"
return os.path.abspath("sieloader_addons.yaml")