Updated common.py

This commit is contained in:
2Shirt 2018-12-27 19:43:37 -07:00
parent 327c5b8a33
commit c74e2c7667
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -227,7 +227,7 @@ def get_process(name=None):
return proc return proc
def get_simple_string(prompt='Enter string'): def get_simple_string(prompt='Enter string'):
"""Get string from user (minimal allowed character set) and return as str.""" """Get string from user (restricted character set), returns str."""
simple_string = None simple_string = None
while simple_string is None: while simple_string is None:
_input = input('{}: '.format(prompt)) _input = input('{}: '.format(prompt))
@ -319,7 +319,8 @@ def major_exception():
pause('Press Enter to exit...') pause('Press Enter to exit...')
exit_script(1) exit_script(1)
def menu_select(title='~ Untitled Menu ~', def menu_select(
title='[Untitled Menu]',
prompt='Please make a selection', secret_actions=[], secret_exit=False, prompt='Please make a selection', secret_actions=[], secret_exit=False,
main_entries=[], action_entries=[], disabled_label='DISABLED', main_entries=[], action_entries=[], disabled_label='DISABLED',
spacer=''): spacer=''):
@ -485,14 +486,16 @@ def run_program(cmd, args=[], check=True, pipe=True, shell=False, **kwargs):
return subprocess.run(**cmd_kwargs) return subprocess.run(**cmd_kwargs)
def set_title(title='~Some Title~'): def set_title(title='[Some Title]'):
"""Set title. """Set title.
Used for window title and menu titles.""" Used for window title and menu titles."""
global_vars['Title'] = title global_vars['Title'] = title
os.system('title {}'.format(title)) os.system('title {}'.format(title))
def show_data(message='~Some message~', data='~Some data~', indent=8, width=32, def show_data(
message='[Some message]', data='[Some data]',
indent=8, width=32,
info=False, warning=False, error=False): info=False, warning=False, error=False):
"""Display info with formatting.""" """Display info with formatting."""
message = '{indent}{message:<{width}}{data}'.format( message = '{indent}{message:<{width}}{data}'.format(
@ -554,7 +557,7 @@ def try_and_print(message='Trying...',
} }
The the ExceptionClassNames will be excepted conditions The the ExceptionClassNames will be excepted conditions
and the result string will be printed in the correct color. and the result string will be printed in the correct color.
catch_all=False will result in unspecified exceptions being re-raised.""" catch_all=False will re-raise unspecified exceptions."""
err = None err = None
out = None out = None
w_exceptions = other_results.get('Warning', {}).keys() w_exceptions = other_results.get('Warning', {}).keys()
@ -712,9 +715,16 @@ def check_os():
tmp['Arch'] = 64 tmp['Arch'] = 64
# Get Windows build info # Get Windows build info
build_info = WINDOWS_BUILDS.get( build_info = WINDOWS_BUILDS.get(tmp['CurrentBuild'], None)
tmp['CurrentBuild'], if build_info is None:
('Unknown', 'Build {}'.format(tmp['CurrentBuild']), None, None, 'unrecognized')) # Not in windows_builds.py
build_info = [
'Unknown',
'Build {}'.format(tmp['CurrentBuild']),
None,
None,
'unrecognized']
else:
build_info = list(build_info) build_info = list(build_info)
tmp['Version'] = build_info.pop(0) tmp['Version'] = build_info.pop(0)
tmp['Release'] = build_info.pop(0) tmp['Release'] = build_info.pop(0)
@ -831,3 +841,5 @@ def set_log_file(log_name):
if __name__ == '__main__': if __name__ == '__main__':
print("This file is not meant to be called directly.") print("This file is not meant to be called directly.")
# vim: sts=2 sw=2 ts=2