From 01678f0f547c0b51e94688cfd9a48788a732e613 Mon Sep 17 00:00:00 2001 From: Christopher Heuer Date: Tue, 30 Nov 2021 18:40:25 -0700 Subject: [PATCH 1/3] added title output --- romloader.example.yaml | 5 +++++ romloader.py | 22 ++++++++++++++++++---- romloader.spec | 17 +++++++++++++---- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/romloader.example.yaml b/romloader.example.yaml index 563b3c5..e3f2bf1 100644 --- a/romloader.example.yaml +++ b/romloader.example.yaml @@ -7,6 +7,11 @@ ### Make sure this directory exists on your SD card (will try to create it if /romloader) default_destination: "/romloader" +### uncomment to have romloader write the name of the selected MSU pack to a file +# title_output_file: "./romloader.txt" +### default title to write for non-msu packs +# default_title: "Not an MSU pack" + ### a set of rules to use to put certain ROMs in certain locations, such as your randomizer ROMs, useful for MSU1 users rules: alttpr: diff --git a/romloader.py b/romloader.py index 560404c..6cbdfd4 100644 --- a/romloader.py +++ b/romloader.py @@ -27,7 +27,7 @@ def show_exception_and_exit(exc_type, exc_value, tb): try: with open(scriptpath + "\\romloader.yaml") as configfile: try: - config = yaml.load(configfile) + config = yaml.safe_load(configfile) print("loading config file at " + os.path.abspath(scriptpath + "\\romloader.yaml")) except yaml.YAMLError as e: @@ -37,7 +37,7 @@ def show_exception_and_exit(exc_type, exc_value, tb): try: with open("romloader.yaml") as configfile: try: - config = yaml.load(configfile) + config = yaml.safe_load(configfile) print("loading config file at " + os.path.abspath("romloader.yaml")) except yaml.YAMLError as e: @@ -70,7 +70,7 @@ async def main(): path = '/romloader' romname = filename else: - path, romname = get_destination(rule, filename) + path, romname, title = get_destination(rule, filename) else: try: path = config['default_destination'] @@ -78,6 +78,18 @@ async def main(): path = '/romloader' romname = filename + if not title: + if "default_title" in config: + title = config['default_title'] + else: + title = 'Not an MSU pack' + + if "title_output_file" in config: + title_output_file = os.path.abspath(scriptpath + config['title_output_file']) + with open(title_output_file, 'w') as file: + file.write(title) + print('Pack selection written to ' + title_output_file) + # initiate connection to the websocket server snes = py2snes.snes() @@ -148,9 +160,11 @@ def get_destination(rule, romname): path = config['rules'][rule]['destinations'][int(dst_idx)]['path'] try: name = config['rules'][rule]['destinations'][int(dst_idx)]['romname'] + title = config['rules'][rule]['destinations'][int(dst_idx)]['name'] except KeyError: name = romname - return path, name + title = None + return path, name, title def get_comm_device(devicelist): diff --git a/romloader.spec b/romloader.spec index 23a155c..4689d59 100644 --- a/romloader.spec +++ b/romloader.spec @@ -1,13 +1,16 @@ -# -*- mode: python -*- +# -*- mode: python ; coding: utf-8 -*- + block_cipher = None + a = Analysis(['romloader.py'], - pathex=['D:\\Code\\RomLoader'], + pathex=[], binaries=[], datas=[], hiddenimports=[], hookspath=[], + hooksconfig={}, runtime_hooks=[], excludes=[], win_no_prefer_redirects=False, @@ -16,16 +19,22 @@ a = Analysis(['romloader.py'], noarchive=False) pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) + exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, - a.datas, + a.datas, [], name='romloader', debug=False, bootloader_ignore_signals=False, strip=False, upx=True, + upx_exclude=[], runtime_tmpdir=None, - console=True ) + console=True, + disable_windowed_traceback=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None ) From e56d6796057dab8f91ddc30ff82a45a5390e3cd3 Mon Sep 17 00:00:00 2001 From: Christopher Heuer Date: Mon, 25 Apr 2022 16:59:48 -0600 Subject: [PATCH 2/3] fix error with non-matching rules --- romloader.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/romloader.py b/romloader.py index 6cbdfd4..e808551 100644 --- a/romloader.py +++ b/romloader.py @@ -54,6 +54,8 @@ async def main(): raise Exception('We need a path to the ROM file to load.') sys.exit(1) filename = os.path.basename(rompath) + + title = None rule = matchrule(filename) if rule: From 1d16b095e1e2d3ba71bd52ead655093432fd2dd6 Mon Sep 17 00:00:00 2001 From: Christopher Heuer Date: Wed, 7 Sep 2022 17:56:36 -0600 Subject: [PATCH 3/3] don't use relative path --- romloader.example.yaml | 2 +- romloader.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/romloader.example.yaml b/romloader.example.yaml index e3f2bf1..3ecdb93 100644 --- a/romloader.example.yaml +++ b/romloader.example.yaml @@ -8,7 +8,7 @@ default_destination: "/romloader" ### uncomment to have romloader write the name of the selected MSU pack to a file -# title_output_file: "./romloader.txt" +# title_output_file: "C:/Users/Username/romloader.txt" ### default title to write for non-msu packs # default_title: "Not an MSU pack" diff --git a/romloader.py b/romloader.py index e808551..143e014 100644 --- a/romloader.py +++ b/romloader.py @@ -87,7 +87,7 @@ async def main(): title = 'Not an MSU pack' if "title_output_file" in config: - title_output_file = os.path.abspath(scriptpath + config['title_output_file']) + title_output_file = os.path.abspath(config['title_output_file']) with open(title_output_file, 'w') as file: file.write(title) print('Pack selection written to ' + title_output_file)