Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
2Shirt 2022-09-18 15:42:47 -07:00
commit bd7bfdb6bb
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
4 changed files with 48 additions and 40 deletions

View file

@ -33,4 +33,9 @@ WINDOWS_BUILDS = {
'10.0.19042': '20H2',
'10.0.19043': '21H1',
'10.0.19044': '21H2',
'10.0.19045': '22H2',
# Windows 11
'10.0.22000': '21H2',
'10.0.22621': '22H2',
}

View file

@ -206,8 +206,8 @@ def mount_volumes(device_path=None, read_write=False, scan_corestorage=False):
json_data = get_json_from_command(cmd)
# Build list of volumes
for dev in _get_volumes(json_data.get('blockdevices', [{}])[0]):
volumes.append(dev)
for dev in json_data.get('blockdevices', [{}]):
volumes.extend(_get_volumes(dev))
if dev.get('parttype', '') == UUID_CORESTORAGE:
containers.append(dev['name'])

View file

@ -253,6 +253,8 @@ def get_os_name(as_list=False, check=True):
display_name = (
f'{reg_read_value("HKLM", key, "ProductName")} {ARCH}-bit {details}'
)
if build_version >= 22000:
display_name = display_name.replace('Windows 10', 'Windows 11')
# Check for support issues
if check:

View file

@ -501,42 +501,6 @@ class TryAndPrint():
# Done
return result_msg
@cache
def _get_exception(self, name):
"""Get exception by name, returns exception object.
[Doctest]
>>> t = TryAndPrint()
>>> t._get_exception('AttributeError')
<class 'AttributeError'>
>>> t._get_exception('CalledProcessError')
<class 'subprocess.CalledProcessError'>
>>> t._get_exception('GenericError')
<class 'wk.std.GenericError'>
"""
LOG.debug('Getting exception: %s', name)
obj = getattr(sys.modules[__name__], name, None)
if obj:
return obj
# Try builtin classes
obj = getattr(sys.modules['builtins'], name, None)
if obj:
return obj
# Try all modules
for _mod in sys.modules.values():
obj = getattr(_mod, name, None)
if obj:
break
# Check if not found
if not obj:
raise AttributeError(f'Failed to find exception: {name}')
# Done
return obj
def _log_result(self, message, result_msg):
"""Log result text without color formatting."""
log_text = f'{" "*self.indent}{message:<{self.width}}{result_msg}'
@ -595,8 +559,8 @@ class TryAndPrint():
verbose = verbose if verbose is not None else self.verbose
# Build exception tuples
e_exceptions = tuple(self._get_exception(e) for e in self.list_errors)
w_exceptions = tuple(self._get_exception(e) for e in self.list_warnings)
e_exceptions = tuple(get_exception(e) for e in self.list_errors)
w_exceptions = tuple(get_exception(e) for e in self.list_warnings)
# Run function and catch exceptions
print(f'{" "*self.indent}{message:<{self.width}}', end='', flush=True)
@ -830,6 +794,43 @@ def generate_debug_report():
return '\n'.join(report)
@cache
def get_exception(name):
"""Get exception by name, returns exception object.
[Doctest]
>>> t = TryAndPrint()
>>> t._get_exception('AttributeError')
<class 'AttributeError'>
>>> t._get_exception('CalledProcessError')
<class 'subprocess.CalledProcessError'>
>>> t._get_exception('GenericError')
<class 'wk.std.GenericError'>
"""
LOG.debug('Getting exception: %s', name)
obj = getattr(sys.modules[__name__], name, None)
if obj:
return obj
# Try builtin classes
obj = getattr(sys.modules['builtins'], name, None)
if obj:
return obj
# Try all modules
for _mod in sys.modules.values():
obj = getattr(_mod, name, None)
if obj:
break
# Check if not found
if not obj:
raise AttributeError(f'Failed to find exception: {name}')
# Done
return obj
def get_log_filepath():
"""Get the log filepath from the root logger, returns pathlib.Path obj.