diff --git a/romloader.example.yaml b/romloader.example.yaml index 563b3c5..3ecdb93 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: "C:/Users/Username/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..143e014 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: @@ -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: @@ -70,7 +72,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 +80,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(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 +162,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 )