Added relevant exit codes at utilities

Fixed missing output path value crash

Increased minimum Python version to 3.8
This commit is contained in:
platomav 2022-05-06 13:54:48 +03:00
parent 9b29c37c65
commit cf88fc7a5d
6 changed files with 40 additions and 22 deletions

View file

@ -7,7 +7,7 @@ AMI BIOS Guard Extractor
Copyright (C) 2018-2022 Plato Mavropoulos
"""
title = 'AMI BIOS Guard Extractor v4.0_a8'
TITLE = 'AMI BIOS Guard Extractor v4.0_a9'
import os
import re
@ -140,8 +140,8 @@ def get_ami_pfat(input_buffer):
return match, buffer
def get_file_name(index, title):
return safe_name('%0.2d -- %s' % (index, title))
def get_file_name(index, name):
return safe_name('%0.2d -- %s' % (index, name))
def parse_bg_script(script_data, padding):
is_opcode_div = len(script_data) % 8 == 0
@ -310,7 +310,7 @@ if __name__ == '__main__':
arguments = argparser.parse_args()
# Initialize script (must be after argparse)
input_files,output_path,padding = script_init(title, arguments, 4)
exit_code,input_files,output_path,padding = script_init(TITLE, arguments, 4)
for input_file in input_files:
input_name = os.path.basename(input_file)
@ -330,4 +330,8 @@ if __name__ == '__main__':
parse_pfat_file(pfat_buffer, extract_path, padding)
exit_code -= 1
printer('Done!', pause=True)
sys.exit(exit_code)

View file

@ -7,7 +7,7 @@ AMI UCP BIOS Extractor
Copyright (C) 2021-2022 Plato Mavropoulos
"""
title = 'AMI UCP BIOS Extractor v2.0_a10'
TITLE = 'AMI UCP BIOS Extractor v2.0_a11'
import os
import re
@ -500,7 +500,7 @@ if __name__ == '__main__':
is_checksum = arguments.checksum # Set Checksum verification optional argument
# Initialize script (must be after argparse)
input_files,output_path,padding = script_init(title, arguments, 4)
exit_code,input_files,output_path,padding = script_init(TITLE, arguments, 4)
for input_file in input_files:
input_name = os.path.basename(input_file)
@ -521,4 +521,8 @@ if __name__ == '__main__':
ucp_extract(main_uaf_bin, extract_path, main_uaf_tag, padding, is_checksum)
exit_code -= 1
printer('Done!', pause=True)
sys.exit(exit_code)

View file

@ -7,7 +7,7 @@ Dell PFS Update Extractor
Copyright (C) 2018-2022 Plato Mavropoulos
"""
title = 'Dell PFS Update Extractor v6.0_a7'
TITLE = 'Dell PFS Update Extractor v6.0_a8'
import os
import io
@ -922,7 +922,7 @@ if __name__ == '__main__':
is_structure = arguments.structure # Set Structure output mode optional argument
# Initialize script (must be after argparse)
input_files,output_path,padding = script_init(title, arguments, 4)
exit_code,input_files,output_path,padding = script_init(TITLE, arguments, 4)
for input_file in input_files:
input_name = os.path.basename(input_file)
@ -966,4 +966,8 @@ if __name__ == '__main__':
# Call the PFS ZLIB Section Parser function
pfs_section_parse(input_buffer, offset, extract_path, extract_name, 1, 1, False, padding, is_structure, is_advanced)
exit_code -= 1
printer('Done!', pause=True)
sys.exit(exit_code)

View file

@ -31,7 +31,7 @@ You can either Drag & Drop or manually enter Dell PFS Update images(s). Optional
#### **Compatibility**
Should work at all Windows, Linux or macOS operating systems which have Python 3.7 support.
Should work at all Windows, Linux or macOS operating systems which have Python 3.8 support.
#### **Prerequisites**
@ -43,7 +43,7 @@ Optionally, to decompile the Intel BIOS Guard (PFAT) Scripts, you must have the
PyInstaller can build/freeze/compile the utility at all three supported platforms, it is simple to run and gets updated often.
1. Make sure Python 3.7.0 or newer is installed:
1. Make sure Python 3.8.0 or newer is installed:
> python --version
@ -90,7 +90,7 @@ You can either Drag & Drop or manually enter AMI UCP BIOS executable file(s). Op
#### **Compatibility**
Should work at all Windows, Linux or macOS operating systems which have Python 3.7 support.
Should work at all Windows, Linux or macOS operating systems which have Python 3.8 support.
#### **Prerequisites**
@ -107,7 +107,7 @@ Optionally, to decompile the AMI UCP \> AMI PFAT \> Intel BIOS Guard Scripts (wh
PyInstaller can build/freeze/compile the utility at all three supported platforms, it is simple to run and gets updated often.
1. Make sure Python 3.7.0 or newer is installed:
1. Make sure Python 3.8.0 or newer is installed:
> python --version
@ -155,7 +155,7 @@ You can either Drag & Drop or manually enter AMI BIOS Guard (PFAT) image file(s)
#### **Compatibility**
Should work at all Windows, Linux or macOS operating systems which have Python 3.7 support.
Should work at all Windows, Linux or macOS operating systems which have Python 3.8 support.
#### **Prerequisites**
@ -167,7 +167,7 @@ Optionally, to decompile the AMI PFAT \> Intel BIOS Guard Scripts, you must have
PyInstaller can build/freeze/compile the utility at all three supported platforms, it is simple to run and gets updated often.
1. Make sure Python 3.7.0 or newer is installed:
1. Make sure Python 3.8.0 or newer is installed:
> python --version

View file

@ -132,8 +132,11 @@ def process_input_files(argparse_args, sys_argv=None):
else:
input_files = [file.name for file in argparse_args.files]
# Set output path via argparse Output Path or argparse Input Path or first input file Path
output_path = argparse_args.output_dir or argparse_args.input_dir or path_parent(input_files[0])
# Set output fallback value for missing argparse Output and Input Path
output_fallback = path_parent(input_files[0]) if input_files else None
# Set output path via argparse Output path or argparse Input path or first input file path
output_path = argparse_args.output_dir or argparse_args.input_dir or output_fallback
else:
# Script w/o parameters
input_path_user = get_dequoted_path(input('\nEnter input directory path: '))

View file

@ -34,14 +34,14 @@ def is_auto_exit():
def check_sys_py():
sys_py = get_py_ver()
if sys_py < (3,7):
sys.stdout.write('\nError: Python >= 3.7 required, not %d.%d!' % (sys_py[0], sys_py[1]))
if sys_py < (3,8):
sys.stdout.write('\nError: Python >= 3.8 required, not %d.%d!' % (sys_py[0], sys_py[1]))
if not is_auto_exit():
# noinspection PyUnresolvedReferences
(raw_input if sys_py[0] <= 2 else input)('\nPress enter to exit') # pylint: disable=E0602
sys.exit(1)
sys.exit(125)
# Check OS Platform
def check_sys_os():
@ -53,7 +53,7 @@ def check_sys_os():
if not is_auto_exit():
input('\nPress enter to exit')
sys.exit(2)
sys.exit(126)
# Fix Windows Unicode console redirection
if os_win: sys.stdout.reconfigure(encoding='utf-8')
@ -93,7 +93,10 @@ def script_init(title, arguments, padding=0):
# Process input files and generate output path
input_files,output_path = process_input_files(arguments, sys.argv)
return input_files, output_path, padding
# Count input files for exit code
input_count = len(input_files)
return input_count, input_files, output_path, padding
# https://stackoverflow.com/a/781074 by Torsten Marek
def nice_exc_handler(exc_type, exc_value, tb):
@ -107,7 +110,7 @@ def nice_exc_handler(exc_type, exc_value, tb):
if not is_auto_exit():
input('\nPress enter to exit')
sys.exit(3)
sys.exit(127)
# Show message(s) while controlling padding, newline, pausing & separator
def printer(in_message='', padd_count=0, new_line=True, pause=False, sep_char=' '):