Skip to content

Commit

Permalink
add new ERROR and WARNING to distgunish the issues priortity
Browse files Browse the repository at this point in the history
  • Loading branch information
BJNFNE committed Aug 6, 2024
1 parent be37c9c commit 773f284
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/MediaStation/Assets/Asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 3 additions & 3 deletions src/MediaStation/Assets/Movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
Expand All @@ -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).
Expand Down
6 changes: 3 additions & 3 deletions src/MediaStation/Context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.')

Expand Down Expand Up @@ -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):
Expand Down
10 changes: 5 additions & 5 deletions src/MediaStation/Engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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).
Expand All @@ -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}')
Expand Down Expand Up @@ -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}')
Expand Down
2 changes: 1 addition & 1 deletion src/MediaStation/Primitives/Datum.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ def __init__(self, stream):
self.d = Reference(stream)

else:
raise BinaryParsingError(f'Unknown datum type: 0x{self.t:04x}', stream)
raise BinaryParsingError(f'ERROR: Unknown datum type: 0x{self.t:04x}', stream)
2 changes: 1 addition & 1 deletion src/MediaStation/Riff/SubFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions tests/rip_media_station_iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions tests/test_game_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 773f284

Please sign in to comment.