Skip to content

Commit

Permalink
Merge 'Error if Decompress or Compress fails' (OoTRandomizer#2229)
Browse files Browse the repository at this point in the history
  • Loading branch information
fenhl committed Dec 12, 2024
2 parents b499369 + 9e95df8 commit e180707
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def compress_rom(input_file: str, output_file: str, delete_input: bool = False)
logger.info("OS not supported for ROM compression.")
raise Exception("This operating system does not support ROM compression. You may only output patch files or uncompressed ROMs.")

run_process(logger, [compressor_path, input_file, output_file])
run_process(logger, [compressor_path, input_file, output_file], check=True)
if delete_input:
os.remove(input_file)

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ issue. You should always Hard Reset to avoid this issue entirely.
* Fix importing settings from older versions on web.
* Fix a Mac-specific issue when loading track .meta files.
* Fix an error in the easy bite fishing hack.
* The randomizer no longer ignores errors when decompressing the base rom or compressing the randomized rom.

#### New Speedups
* The first text box from each carpenter in the Thieves' Hideout is skipped.
Expand Down
2 changes: 1 addition & 1 deletion Rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def decompress_rom(self, input_file: str, output_file: str, verify_crc: bool = T
else:
raise RuntimeError('Unsupported operating system for decompression. Please supply an already decompressed ROM.')

subprocess.call(subcall, **subprocess_args())
subprocess.check_call(subcall, **subprocess_args())
self.read_rom(output_file, verify_crc=verify_crc)

def write_byte(self, address: int, value: int) -> None:
Expand Down
11 changes: 4 additions & 7 deletions Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,23 +199,20 @@ def subprocess_args(include_stdout: bool = True) -> dict[str, Any]:
return ret


def run_process(logger: logging.Logger, args: Sequence[str], stdin: Optional[AnyStr] = None) -> None:
def run_process(logger: logging.Logger, args: Sequence[str], stdin: Optional[AnyStr] = None, *, check: bool = False) -> None:
process = subprocess.Popen(args, bufsize=1, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
filecount = None
if stdin is not None:
process.communicate(input=stdin)
else:
while True:
line = process.stdout.readline()
if line != b'':
find_index = line.find(b'files remaining')
if find_index > -1:
files = int(line[:find_index].strip())
if filecount is None:
filecount = files
logger.info(line.decode('utf-8').strip('\n'))
else:
break
process.communicate()
if check and process.returncode != 0:
raise subprocess.CalledProcessError(process.returncode, args)


# https://stackoverflow.com/a/23146126
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '8.2.37'
__version__ = '8.2.38'

# This is a supplemental version number for branches based off of main dev.
supplementary_version = 0
Expand Down

0 comments on commit e180707

Please sign in to comment.