From 773f28482ca59c0170346732c2f055f1184d638e Mon Sep 17 00:00:00 2001 From: Benjamin Funke <58399929+BJNFNE@users.noreply.github.com> Date: Tue, 6 Aug 2024 09:50:20 +0200 Subject: [PATCH] add new ERROR and WARNING to distgunish the issues priortity --- setup.py | 2 +- src/MediaStation/Assets/Asset.py | 4 ++-- src/MediaStation/Assets/Movie.py | 6 +++--- src/MediaStation/Context.py | 6 +++--- src/MediaStation/Engine.py | 10 +++++----- src/MediaStation/Primitives/Datum.py | 2 +- src/MediaStation/Riff/SubFile.py | 2 +- tests/rip_media_station_iso.sh | 6 +++--- tests/test_game_parsing.py | 6 +++--- 9 files changed, 22 insertions(+), 22 deletions(-) diff --git a/setup.py b/setup.py index 8c6b79c..567d343 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ ext_modules = [bitmap_decompression, ima_adpcm_decompression]) except: # RELY ON THE PYTHON FALLBACK. - warnings.warn('The C decompression binaries are not available on this installation. Sounds and bitmaps might not export.') + warnings.warn('WARNING: The C decompression binaries are not available on this installation. Sounds and bitmaps might not export.') setup(name = 'MediaStation') # BUILD THE IMA ADPCM DECOMPRESSOR. diff --git a/src/MediaStation/Assets/Asset.py b/src/MediaStation/Assets/Asset.py index 6b4ea6d..c8f4799 100644 --- a/src/MediaStation/Assets/Asset.py +++ b/src/MediaStation/Assets/Asset.py @@ -453,7 +453,7 @@ def _read_section(self, section_type, chunk): try: self.sound_encoding = Sound.Encoding(raw_sound_encoding) except: - raise ValueError(f'Received unknown sound encoding specifier: 0x{raw_sound_encoding:04x}') + raise ValueError(f'ERROR: Received unknown sound encoding specifier: 0x{raw_sound_encoding:04x}') else: - raise BinaryParsingError(f'Unknown section type: 0x{section_type:0>4x}', chunk.stream) + raise BinaryParsingError(f'ERROR: Unknown section type: 0x{section_type:0>4x}', chunk.stream) diff --git a/src/MediaStation/Assets/Movie.py b/src/MediaStation/Assets/Movie.py index 291cea5..08638d0 100644 --- a/src/MediaStation/Assets/Movie.py +++ b/src/MediaStation/Assets/Movie.py @@ -172,7 +172,7 @@ def add_still(self, chunk): frame.set_footer(footer) else: - raise BinaryParsingError(f'Unknown header type in movie still area: 0x{section_type.d:02x}', chunk.stream) + raise BinaryParsingError(f'ERROR: Unknown header type in movie still area: 0x{section_type.d:02x}', chunk.stream) ## Reads the data in a subfile from the binary stream at its current position. ## The subfile's metadata must have already been read. @@ -217,7 +217,7 @@ def add_subfile(self, subfile, chunk): footers.append(footer) else: - raise TypeError(f'Unknown movie chunk tag: 0x{section_type:04x}') + raise TypeError(f'ERROR: Unknown movie chunk tag: 0x{section_type:04x}') # READ THE NEXT CHUNK. chunk = subfile.get_next_chunk() @@ -239,7 +239,7 @@ def add_subfile(self, subfile, chunk): assert_equal(chunk.length, 0x04, "frameset delimiter size") chunk.read(chunk.length) else: - raise BinaryParsingError(f'Unknown delimiter at end of movie frameset: {subfile.current_chunk.fourcc}', chunk.stream) + raise BinaryParsingError(f'ERROR: Unknown delimiter at end of movie frameset: {subfile.current_chunk.fourcc}', chunk.stream) # SET THE REQUIRED FOOTERS. # Most keyframes don't have any different metadata from regular frames (aside from duration). diff --git a/src/MediaStation/Context.py b/src/MediaStation/Context.py index 792b3b6..546d190 100644 --- a/src/MediaStation/Context.py +++ b/src/MediaStation/Context.py @@ -434,7 +434,7 @@ def read_header_section(self, chunk, reading_stage = False): )) else: - raise ValueError(f'Unknown section type: {section_type:04x}') + raise ValueError(f'ERROR: Unknown section type: {section_type:04x}') return True @@ -457,7 +457,7 @@ def read_asset_in_first_subfile(self, chunk): if header is None: # This should never actually be an error condition in valid contexts, because the asset headers are also in the first subfile. raise ValueError( - f'Asset FourCC {chunk.fourcc} was encountered in the first subfile, but no asset header read thus far has declared this FourCC.\n\n' + f'ERROR: Asset FourCC {chunk.fourcc} was encountered in the first subfile, but no asset header read thus far has declared this FourCC.\n\n' 'This is expected if you are trying to extract assets from an INSTALL.CXT while excluding other CXTs, as INSTALL.CXT does not contain any asset headers.\n' 'Try running the extraction again on the entire game directory.') @@ -489,7 +489,7 @@ def read_asset_in_first_subfile(self, chunk): header.movie.add_still(chunk) else: - raise BinaryParsingError(f'Unknown asset type in first subfile: 0x{header.type:02x}', chunk.stream) + raise BinaryParsingError(f'ERROR: Unknown asset type in first subfile: 0x{header.type:02x}', chunk.stream) ## Reads an asset from a subfile after the first subfile. def read_asset_from_later_subfile(self, subfile, chunk = None): diff --git a/src/MediaStation/Engine.py b/src/MediaStation/Engine.py index 07788cf..5dce85b 100644 --- a/src/MediaStation/Engine.py +++ b/src/MediaStation/Engine.py @@ -87,7 +87,7 @@ def correlate_asset_ids_to_names(self): # between the two. We will check to ensure this isn't the case. if corresponding_asset.name is not None: if corresponding_asset.name != asset_entry.name: - self.logger.warning(f'Asset names disagree. Name in asset: {corresponding_asset.name}. Name in PROFILE._ST: {asset_entry.name}.') + self.logger.warning(f'WARNING: Asset names disagree. Name in asset: {corresponding_asset.name}. Name in PROFILE._ST: {asset_entry.name}.') continue corresponding_asset.name = asset_entry.name @@ -104,7 +104,7 @@ def correlate_asset_ids_to_names(self): corresponding_context.parameters.name = asset_entry.name continue - self.logger.warning(f'Asset {asset_entry.id} present in PROFILE._ST but not found in parsed assets: {asset_entry._raw_entry}') + self.logger.warning(f'WARNING: Asset {asset_entry.id} present in PROFILE._ST but not found in parsed assets: {asset_entry._raw_entry}') def process(self, input_paths): # READ THE STARTUP FILE (BOOT.STM). @@ -113,10 +113,10 @@ def process(self, input_paths): # TODO: I really wanted to support extracting individual CXTs, but # I think that will be too complex and the potential use cases are # too small. - self.logger.error("BOOT.STM is missing from the input path(s). This file contains vital information for processing Media Station games, and assets cannot be extracted without it. ") + self.logger.error("ERROR: BOOT.STM is missing from the input path(s). This file contains vital information for processing Media Station games, and assets cannot be extracted without it. ") exit(1) if len(matched_boot_stm_files) > 1: - self.logger.error('Found more than one BOOT.STM file in the given path(s). You are likely trying to process more than one Media Station title at once, which is not supported.') + self.logger.error('WARNING: Found more than one BOOT.STM file in the given path(s). You are likely trying to process more than one Media Station title at once, which is not supported.') exit(1) system_filepath = matched_boot_stm_files[0] self.logger.info(f'Processing {system_filepath}') @@ -150,7 +150,7 @@ def process(self, input_paths): # This seems to legitimately happen for 1095.CXT and 1097.CXT in Lion King, # which are both only 16 bytes and don't appear at all in BOOT.STM # TODO: Don't issue a warning for these files. - self.logger.warning(f'File declaration for {matched_cxt_filepath} not found in BOOT.STM. This file will not be processed or exported.') + self.logger.warning(f'WARNING: File declaration for {matched_cxt_filepath} not found in BOOT.STM. This file will not be processed or exported.') self.contexts: List[Context] = [] for cxt_filepath in [*cdrom_context_filepaths, *other_context_filepaths]: self.logger.info(f'Processing {cxt_filepath}') diff --git a/src/MediaStation/Primitives/Datum.py b/src/MediaStation/Primitives/Datum.py index cfafedd..3764a5f 100644 --- a/src/MediaStation/Primitives/Datum.py +++ b/src/MediaStation/Primitives/Datum.py @@ -94,4 +94,4 @@ def __init__(self, stream): self.d = Reference(stream) else: - raise BinaryParsingError(f'Unknown datum type: 0x{self.t:04x}', stream) \ No newline at end of file + raise BinaryParsingError(f'ERROR: Unknown datum type: 0x{self.t:04x}', stream) \ No newline at end of file diff --git a/src/MediaStation/Riff/SubFile.py b/src/MediaStation/Riff/SubFile.py index 996f4f2..81b11de 100644 --- a/src/MediaStation/Riff/SubFile.py +++ b/src/MediaStation/Riff/SubFile.py @@ -80,7 +80,7 @@ def get_next_chunk(self, fourcc_length = 4, called_from_init = False) -> Optiona if attempted_read_past_end_of_subfile: bytes_past_chunk_end = new_end_pointer - self.root_chunk.end_pointer raise BinaryParsingError( - f'Attempted to read a new chunk past the end of the subfile whose data starts at 0x{self.root_chunk.data_start_pointer:02x} and ends at 0x{self.root_chunk.end_pointer:02x}.', + f'ERROR: Attempted to read a new chunk past the end of the subfile whose data starts at 0x{self.root_chunk.data_start_pointer:02x} and ends at 0x{self.root_chunk.end_pointer:02x}.', self.stream) # GET THE NEXT CHUNK. diff --git a/tests/rip_media_station_iso.sh b/tests/rip_media_station_iso.sh index df13a0e..756a4f6 100755 --- a/tests/rip_media_station_iso.sh +++ b/tests/rip_media_station_iso.sh @@ -64,10 +64,10 @@ mount -t cd9660 "$disk_identifier" "$mount_point" echo "BOOT.STM" bootstm_path=$(find "$mount_point" -iname "boot.stm" -print) if [ -z "$bootstm_path" ]; then - echo "Error: BOOT.STM not found on CD-ROM. This is likely not a Media Sation title, or it uses some format we're not aware of yet." + echo "ERROR: BOOT.STM not found on CD-ROM. This is likely not a Media Sation title, or it uses some format we're not aware of yet." exit 1 elif [ $(echo "$bootstm_path" | wc -l) -gt 1 ]; then - echo "Warning: Multiple BOOT.STMs found: $bootstm_path. Using the first one." + echo "ERROR: Multiple BOOT.STMs found: $bootstm_path. Using the first one." bootstm_path=$(echo "$bootstm_path" | head -n 1) fi xxd -l 256 "$bootstm_path" @@ -79,7 +79,7 @@ if [ -z "$profilest_path" ]; then echo "No profile._st found." else if [ $(echo "$profilest_path" | wc -l) -gt 1 ]; then - echo "Warning: Multiple PROFILE._STs found: $profilest_path. Using the first one." + echo "WARNING: Multiple PROFILE._STs found: $profilest_path. Using the first one." profilest_path=$(echo "$profilest_path" | head -n 1) fi xxd -l 256 "$profilest_path" diff --git a/tests/test_game_parsing.py b/tests/test_game_parsing.py index 8180e9f..c0f73d1 100644 --- a/tests/test_game_parsing.py +++ b/tests/test_game_parsing.py @@ -19,7 +19,7 @@ GAME_ROOT_DIRECTORY = 'tests/test_data/Extracted Folders' game_directories = [] if not os.path.exists(os.path.realpath(GAME_ROOT_DIRECTORY)): - warnings.warn('No test data present, game parsing tests will be skipped.') + warnings.warn('WARNING: No test data present, game parsing tests will be skipped.') else: for filename in os.listdir(os.path.realpath(GAME_ROOT_DIRECTORY)): filepath = os.path.join(GAME_ROOT_DIRECTORY, filename) @@ -49,10 +49,10 @@ def test_script_is_runnable(): # VERIFY THE SCRIPT RAN SUCCESSFULLY. # A BOOT.STM is *required* so, the script will refuse to run far. # However, we can still tell if the script has been successfully invoked. - script_invoked_successfully = ('BOOT.STM is missing' in result.stderr) and (result.returncode == 1) + script_invoked_successfully = ('ERROR: BOOT.STM is missing' in result.stderr) and (result.returncode == 1) if not script_invoked_successfully: raise AssertionError( - f'Received a bad exit code when running `{CALLABLE_SCRIPT_NAME}` from command line!' + f'ERROR: Received a bad exit code when running `{CALLABLE_SCRIPT_NAME}` from command line!' f'\nstdout: {result.stdout}' f'\n\nstderr: {result.stderr}') finally: