From d4052ab60a983674d71a6cf41a483ac66edc3535 Mon Sep 17 00:00:00 2001 From: Kevin Cathcart Date: Sun, 19 Nov 2017 16:00:26 -0500 Subject: [PATCH] Use sys.exit instead of exit The global exit function is designed only for the interpreter, so use the correct one. Also fix the plandomizer so it does not immediately error when run. --- EntranceRandomizer.py | 5 +++-- Plando.py | 16 +++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/EntranceRandomizer.py b/EntranceRandomizer.py index 54d7288c..17fb6896 100644 --- a/EntranceRandomizer.py +++ b/EntranceRandomizer.py @@ -3,6 +3,7 @@ import os import logging import random import textwrap +import sys from Main import main from Gui import guiMain @@ -191,11 +192,11 @@ if __name__ == '__main__': # ToDo: Validate files further than mere existance if not args.jsonout and not os.path.isfile(args.rom): input('Could not find valid base rom for patching at expected path %s. Please run with -h to see help for further information. \nPress Enter to exit.' % args.rom) - exit(1) + sys.exit(1) if args.sprite is not None and not os.path.isfile(args.sprite): if not args.jsonout: input('Could not find link sprite sheet at given location. \nPress Enter to exit.' % args.sprite) - exit(1) + sys.exit(1) else: raise IOError('Cannot find sprite file at %s' % args.sprite) diff --git a/Plando.py b/Plando.py index a013c398..ddcc4d8d 100644 --- a/Plando.py +++ b/Plando.py @@ -1,7 +1,7 @@ from BaseClasses import World from Regions import create_regions from EntranceShuffle import link_entrances, connect_entrance, connect_two_way, connect_exit -from Rom import patch_rom, LocalRom, write_string_to_rom, write_credits_string_to_rom +from Rom import patch_rom, LocalRom, write_string_to_rom from Rules import set_rules from Dungeons import create_dungeons from Items import ItemFactory @@ -12,6 +12,7 @@ import logging import argparse import os import hashlib +import sys __version__ = '0.2-dev' @@ -161,9 +162,10 @@ def fill_world(world, plando, text_patches): elif line.startswith('!text_'): textname, text = line.split(':', 1) text_patches.append([textname.lstrip('!text_').strip(), 'text', text.strip()]) - elif line.startswith('!credits_'): - textname, text = line.split(':', 1) - text_patches.append([textname.lstrip('!credits_').strip(), 'credits', text.strip()]) + #temporarilly removed. New credits system not ready to handle this. + #elif line.startswith('!credits_'): + # textname, text = line.split(':', 1) + # text_patches.append([textname.lstrip('!credits_').strip(), 'credits', text.strip()]) continue locationstr, itemstr = line.split(':', 1) @@ -214,13 +216,13 @@ if __name__ == '__main__': # ToDo: Validate files further than mere existance if not os.path.isfile(args.rom): input('Could not find valid base rom for patching at expected path %s. Please run with -h to see help for further information. \nPress Enter to exit.' % args.rom) - exit(1) + sys.exit(1) if not os.path.isfile(args.plando): input('Could not find Plandomizer distribution at expected path %s. Please run with -h to see help for further information. \nPress Enter to exit.' % args.plando) - exit(1) + sys.exit(1) if args.sprite is not None and not os.path.isfile(args.rom): input('Could not find link sprite sheet at given location. \nPress Enter to exit.' % args.sprite) - exit(1) + sys.exit(1) # set up logger loglevel = {'error': logging.ERROR, 'info': logging.INFO, 'warning': logging.WARNING, 'debug': logging.DEBUG}[args.loglevel]