mirror of
https://github.com/platomav/BIOSUtilities.git
synced 2025-05-15 15:44:53 -04:00
BIOSUtilities v24.10.23
New "package" flow, arguments now provided during utility call (README) New "main" flow, using old "run_utility" method of BIOSUtility (README) Removed "run_utility" and "show_version" methods from base BIOSUtility Removed argparse argument parsing logic from base BIOSUtility class Removed notion of "pause" (i.e. user action) from BIOSUtility logic Adjusted the README with usage info for "main" and "package" flows
This commit is contained in:
parent
35455f735c
commit
d8e23f9ef3
24 changed files with 561 additions and 652 deletions
|
@ -23,29 +23,29 @@ class ToshibaComExtract(BIOSUtility):
|
|||
|
||||
TITLE: str = 'Toshiba BIOS COM Extractor'
|
||||
|
||||
def check_format(self, input_object: str | bytes | bytearray) -> bool:
|
||||
def check_format(self) -> bool:
|
||||
""" Check if input is Toshiba BIOS COM image """
|
||||
|
||||
input_buffer: bytes = file_to_bytes(in_object=input_object)
|
||||
input_buffer: bytes = file_to_bytes(in_object=self.input_object)
|
||||
|
||||
return bool(PAT_TOSHIBA_COM.search(input_buffer, 0, 0x100))
|
||||
|
||||
def parse_format(self, input_object: str | bytes | bytearray, extract_path: str, padding: int = 0) -> bool:
|
||||
def parse_format(self) -> bool:
|
||||
""" Parse & Extract Toshiba BIOS COM image """
|
||||
|
||||
make_dirs(in_path=extract_path, delete=True)
|
||||
make_dirs(in_path=self.extract_path, delete=True)
|
||||
|
||||
if isinstance(input_object, str) and is_file(in_path=input_object):
|
||||
input_path: str = input_object
|
||||
if isinstance(self.input_object, str) and is_file(in_path=self.input_object):
|
||||
input_path: str = self.input_object
|
||||
else:
|
||||
input_path = os.path.join(extract_path, 'toshiba_bios.com')
|
||||
input_path = os.path.join(self.extract_path, 'toshiba_bios.com')
|
||||
|
||||
with open(input_path, 'wb') as input_buffer:
|
||||
input_buffer.write(file_to_bytes(in_object=input_object))
|
||||
input_buffer.write(file_to_bytes(in_object=self.input_object))
|
||||
|
||||
output_name: str = f'{safe_name(in_name=path_stem(in_path=input_path))}_extracted.bin'
|
||||
|
||||
output_path: str = os.path.join(extract_path, output_name)
|
||||
output_path: str = os.path.join(self.extract_path, output_name)
|
||||
|
||||
try:
|
||||
subprocess.run([comextract_path(), input_path, output_path], check=True, stdout=subprocess.DEVNULL)
|
||||
|
@ -53,17 +53,14 @@ class ToshibaComExtract(BIOSUtility):
|
|||
if not is_file(in_path=output_path):
|
||||
raise FileNotFoundError('EXTRACTED_FILE_MISSING')
|
||||
except Exception as error: # pylint: disable=broad-except
|
||||
printer(message=f'Error: ToshibaComExtractor could not extract {input_path}: {error}!', padding=padding)
|
||||
printer(message=f'Error: ToshibaComExtractor could not extract {input_path}: {error}!',
|
||||
padding=self.padding)
|
||||
|
||||
return False
|
||||
|
||||
if input_path != input_object:
|
||||
if input_path != self.input_object:
|
||||
os.remove(input_path)
|
||||
|
||||
printer(message='Successful extraction via ToshibaComExtractor!', padding=padding)
|
||||
printer(message='Successful extraction via ToshibaComExtractor!', padding=self.padding)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
ToshibaComExtract().run_utility()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue