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.
This commit is contained in:
parent
8158f5793d
commit
d4052ab60a
|
@ -3,6 +3,7 @@ import os
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
import textwrap
|
import textwrap
|
||||||
|
import sys
|
||||||
|
|
||||||
from Main import main
|
from Main import main
|
||||||
from Gui import guiMain
|
from Gui import guiMain
|
||||||
|
@ -191,11 +192,11 @@ if __name__ == '__main__':
|
||||||
# ToDo: Validate files further than mere existance
|
# ToDo: Validate files further than mere existance
|
||||||
if not args.jsonout and not os.path.isfile(args.rom):
|
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)
|
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 args.sprite is not None and not os.path.isfile(args.sprite):
|
||||||
if not args.jsonout:
|
if not args.jsonout:
|
||||||
input('Could not find link sprite sheet at given location. \nPress Enter to exit.' % args.sprite)
|
input('Could not find link sprite sheet at given location. \nPress Enter to exit.' % args.sprite)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
raise IOError('Cannot find sprite file at %s' % args.sprite)
|
raise IOError('Cannot find sprite file at %s' % args.sprite)
|
||||||
|
|
||||||
|
|
16
Plando.py
16
Plando.py
|
@ -1,7 +1,7 @@
|
||||||
from BaseClasses import World
|
from BaseClasses import World
|
||||||
from Regions import create_regions
|
from Regions import create_regions
|
||||||
from EntranceShuffle import link_entrances, connect_entrance, connect_two_way, connect_exit
|
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 Rules import set_rules
|
||||||
from Dungeons import create_dungeons
|
from Dungeons import create_dungeons
|
||||||
from Items import ItemFactory
|
from Items import ItemFactory
|
||||||
|
@ -12,6 +12,7 @@ import logging
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import sys
|
||||||
|
|
||||||
__version__ = '0.2-dev'
|
__version__ = '0.2-dev'
|
||||||
|
|
||||||
|
@ -161,9 +162,10 @@ def fill_world(world, plando, text_patches):
|
||||||
elif line.startswith('!text_'):
|
elif line.startswith('!text_'):
|
||||||
textname, text = line.split(':', 1)
|
textname, text = line.split(':', 1)
|
||||||
text_patches.append([textname.lstrip('!text_').strip(), 'text', text.strip()])
|
text_patches.append([textname.lstrip('!text_').strip(), 'text', text.strip()])
|
||||||
elif line.startswith('!credits_'):
|
#temporarilly removed. New credits system not ready to handle this.
|
||||||
textname, text = line.split(':', 1)
|
#elif line.startswith('!credits_'):
|
||||||
text_patches.append([textname.lstrip('!credits_').strip(), 'credits', text.strip()])
|
# textname, text = line.split(':', 1)
|
||||||
|
# text_patches.append([textname.lstrip('!credits_').strip(), 'credits', text.strip()])
|
||||||
continue
|
continue
|
||||||
|
|
||||||
locationstr, itemstr = line.split(':', 1)
|
locationstr, itemstr = line.split(':', 1)
|
||||||
|
@ -214,13 +216,13 @@ if __name__ == '__main__':
|
||||||
# ToDo: Validate files further than mere existance
|
# ToDo: Validate files further than mere existance
|
||||||
if not os.path.isfile(args.rom):
|
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)
|
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):
|
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)
|
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):
|
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)
|
input('Could not find link sprite sheet at given location. \nPress Enter to exit.' % args.sprite)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# set up logger
|
# set up logger
|
||||||
loglevel = {'error': logging.ERROR, 'info': logging.INFO, 'warning': logging.WARNING, 'debug': logging.DEBUG}[args.loglevel]
|
loglevel = {'error': logging.ERROR, 'info': logging.INFO, 'warning': logging.WARNING, 'debug': logging.DEBUG}[args.loglevel]
|
||||||
|
|
Loading…
Reference in New Issue