Add show_os_name() with support status checks
This commit is contained in:
parent
d725837f9b
commit
423cd343fb
6 changed files with 82 additions and 8 deletions
|
|
@ -135,10 +135,9 @@ BASE_MENUS = {
|
||||||
'System Information': (
|
'System Information': (
|
||||||
MenuEntry('AIDA64 Report', 'auto_export_aida64_report'),
|
MenuEntry('AIDA64 Report', 'auto_export_aida64_report'),
|
||||||
MenuEntry('Backup Registry', 'auto_backup_registry'),
|
MenuEntry('Backup Registry', 'auto_backup_registry'),
|
||||||
MenuEntry('Everything (File List)', no_op),
|
|
||||||
),
|
),
|
||||||
'System Summary': (
|
'System Summary': (
|
||||||
MenuEntry('Operating System', no_op),
|
MenuEntry('Operating System', 'auto_show_os_name'),
|
||||||
MenuEntry('Windows Activation', no_op),
|
MenuEntry('Windows Activation', no_op),
|
||||||
MenuEntry('Secure Boot', no_op),
|
MenuEntry('Secure Boot', no_op),
|
||||||
MenuEntry('Installed RAM', no_op),
|
MenuEntry('Installed RAM', no_op),
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,4 @@ from . import main
|
||||||
from . import net
|
from . import net
|
||||||
from . import sources
|
from . import sources
|
||||||
from . import ufd
|
from . import ufd
|
||||||
|
from . import windows_builds
|
||||||
|
|
|
||||||
36
scripts/wk/cfg/windows_builds.py
Normal file
36
scripts/wk/cfg/windows_builds.py
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
"""WizardKit: Config - Windows Builds"""
|
||||||
|
# vim: sts=2 sw=2 ts=2
|
||||||
|
|
||||||
|
|
||||||
|
OLDEST_SUPPORTED_BUILD = 19041 # Windows 10 20H1
|
||||||
|
OUTDATED_BUILD_NUMBERS = (
|
||||||
|
9600, # Windows 8.1 Update
|
||||||
|
18363, # Windows 10 19H2
|
||||||
|
)
|
||||||
|
WINDOWS_BUILDS = {
|
||||||
|
# Windows 7
|
||||||
|
'6.1.7600': 'RTM "Vienna"',
|
||||||
|
'6.1.7601': 'SP1 "Vienna"',
|
||||||
|
|
||||||
|
# Windows 8
|
||||||
|
'6.2.9200': 'RTM',
|
||||||
|
|
||||||
|
# Widnows 8.1
|
||||||
|
'6.3.9200': '"Blue"',
|
||||||
|
'6.3.9600': '"Update"',
|
||||||
|
|
||||||
|
# Windows 10
|
||||||
|
'10.0.10240': '1507 "Threshold 1"',
|
||||||
|
'10.0.10586': '1511 "Threshold 2"',
|
||||||
|
'10.0.14393': '1607 "Redstone 1"',
|
||||||
|
'10.0.15063': '1703 "Redstone 2"',
|
||||||
|
'10.0.16299': '1709 "Redstone 3"',
|
||||||
|
'10.0.17134': '1803 "Redstone 4"',
|
||||||
|
'10.0.17763': '1809 "Redstone 5"',
|
||||||
|
'10.0.18362': '1903 / 19H1',
|
||||||
|
'10.0.18363': '1909 / 19H2',
|
||||||
|
'10.0.19041': '2004 / 20H1',
|
||||||
|
'10.0.19042': '20H2',
|
||||||
|
'10.0.19043': '21H1',
|
||||||
|
'10.0.19044': '21H2',
|
||||||
|
}
|
||||||
|
|
@ -16,12 +16,18 @@ except ImportError as err:
|
||||||
raise err
|
raise err
|
||||||
|
|
||||||
from wk.borrowed import acpi
|
from wk.borrowed import acpi
|
||||||
|
from wk.cfg.windows_builds import (
|
||||||
|
OLDEST_SUPPORTED_BUILD,
|
||||||
|
OUTDATED_BUILD_NUMBERS,
|
||||||
|
WINDOWS_BUILDS,
|
||||||
|
)
|
||||||
from wk.exe import run_program
|
from wk.exe import run_program
|
||||||
from wk.std import GenericError, GenericWarning, sleep
|
from wk.std import GenericError, GenericWarning, sleep
|
||||||
|
|
||||||
|
|
||||||
# STATIC VARIABLES
|
# STATIC VARIABLES
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
ARCH = '64' if platform.architecture()[0] == '64bit' else '32'
|
||||||
CONEMU = 'ConEmuPID' in os.environ
|
CONEMU = 'ConEmuPID' in os.environ
|
||||||
KNOWN_DATA_TYPES = {
|
KNOWN_DATA_TYPES = {
|
||||||
'BINARY': winreg.REG_BINARY,
|
'BINARY': winreg.REG_BINARY,
|
||||||
|
|
@ -120,6 +126,33 @@ def is_activated():
|
||||||
return act_str and 'permanent' in act_str
|
return act_str and 'permanent' in act_str
|
||||||
|
|
||||||
|
|
||||||
|
# System Info Functions
|
||||||
|
def show_os_name(check=True):
|
||||||
|
"""Build OS display name and print it to screen.
|
||||||
|
|
||||||
|
NOTE: If check=True then an exception is raised if the OS version is
|
||||||
|
outdated or unsupported.
|
||||||
|
"""
|
||||||
|
key = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion'
|
||||||
|
build_version = int(reg_read_value("HKLM", key, "CurrentBuild"))
|
||||||
|
build_version_full = platform.win32_ver()[1]
|
||||||
|
details = WINDOWS_BUILDS.get(build_version_full, f'Build {build_version}')
|
||||||
|
display_name = (
|
||||||
|
f'{reg_read_value("HKLM", key, "ProductName")} {ARCH}-bit {details}'
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check for support issues
|
||||||
|
if check:
|
||||||
|
if build_version in OUTDATED_BUILD_NUMBERS:
|
||||||
|
raise GenericWarning(f'{display_name} (outdated)')
|
||||||
|
|
||||||
|
if build_version < OLDEST_SUPPORTED_BUILD:
|
||||||
|
raise GenericError(f'{display_name} (unsupported)')
|
||||||
|
|
||||||
|
# Done
|
||||||
|
print(display_name)
|
||||||
|
|
||||||
|
|
||||||
# Registry Functions
|
# Registry Functions
|
||||||
def reg_delete_key(hive, key, recurse=False):
|
def reg_delete_key(hive, key, recurse=False):
|
||||||
# pylint: disable=raise-missing-from
|
# pylint: disable=raise-missing-from
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,7 @@ from wk.std import (
|
||||||
)
|
)
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
from wk.os.win import (
|
from wk.os.win import (
|
||||||
|
OS_VERSION,
|
||||||
get_timezone,
|
get_timezone,
|
||||||
set_timezone,
|
set_timezone,
|
||||||
reg_delete_value,
|
reg_delete_value,
|
||||||
|
|
@ -64,6 +65,7 @@ if platform.system() == 'Windows':
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# Workaround to allow basic testing under non-Windows environments
|
# Workaround to allow basic testing under non-Windows environments
|
||||||
|
OS_VERSION = -1
|
||||||
def no_op(*args, **kwargs): # pylint: disable=unused-argument
|
def no_op(*args, **kwargs): # pylint: disable=unused-argument
|
||||||
"""No-op function."""
|
"""No-op function."""
|
||||||
# wk.os.win
|
# wk.os.win
|
||||||
|
|
@ -133,9 +135,6 @@ PROGRAMFILES_32 = os.environ.get(
|
||||||
'PROGRAMFILES', r'C:\Program Files (x86)',
|
'PROGRAMFILES', r'C:\Program Files (x86)',
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
OS_VERSION = -1
|
|
||||||
if platform.system() == 'Windows':
|
|
||||||
OS_VERSION = float(platform.win32_ver()[0])
|
|
||||||
POWER_PLANS = {
|
POWER_PLANS = {
|
||||||
'Balanced': '381b4222-f694-41f0-9685-ff5bb260df2e',
|
'Balanced': '381b4222-f694-41f0-9685-ff5bb260df2e',
|
||||||
'Custom': '01189998-8199-9119-725c-ccccccccccc3',
|
'Custom': '01189998-8199-9119-725c-ccccccccccc3',
|
||||||
|
|
|
||||||
|
|
@ -42,10 +42,12 @@ from wk.std import (
|
||||||
)
|
)
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
from wk.os.win import (
|
from wk.os.win import (
|
||||||
|
OS_VERSION,
|
||||||
activate_with_bios,
|
activate_with_bios,
|
||||||
reg_read_value,
|
reg_read_value,
|
||||||
reg_set_value,
|
reg_set_value,
|
||||||
reg_write_settings,
|
reg_write_settings,
|
||||||
|
show_os_name,
|
||||||
)
|
)
|
||||||
from wk.repairs.win import (
|
from wk.repairs.win import (
|
||||||
backup_all_browser_profiles,
|
backup_all_browser_profiles,
|
||||||
|
|
@ -59,6 +61,7 @@ if platform.system() == 'Windows':
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# Workaround to allow basic testing under non-Windows environments
|
# Workaround to allow basic testing under non-Windows environments
|
||||||
|
OS_VERSION = -1
|
||||||
def no_op(*args, **kwargs): # pylint: disable=unused-argument
|
def no_op(*args, **kwargs): # pylint: disable=unused-argument
|
||||||
"""No-op function."""
|
"""No-op function."""
|
||||||
# wk.os.win
|
# wk.os.win
|
||||||
|
|
@ -66,6 +69,7 @@ else:
|
||||||
reg_read_value = no_op
|
reg_read_value = no_op
|
||||||
reg_set_value = no_op
|
reg_set_value = no_op
|
||||||
reg_write_settings = no_op
|
reg_write_settings = no_op
|
||||||
|
show_os_name = no_op
|
||||||
# wk.repairs.win
|
# wk.repairs.win
|
||||||
backup_all_browser_profiles = no_op
|
backup_all_browser_profiles = no_op
|
||||||
backup_registry = no_op
|
backup_registry = no_op
|
||||||
|
|
@ -97,9 +101,6 @@ LIBREOFFICE_XCU_DATA = '''<?xml version="1.0" encoding="UTF-8"?>
|
||||||
</oor:items>
|
</oor:items>
|
||||||
'''
|
'''
|
||||||
MENU_PRESETS = Menu()
|
MENU_PRESETS = Menu()
|
||||||
OS_VERSION = -1
|
|
||||||
if platform.system() == 'Windows':
|
|
||||||
OS_VERSION = float(platform.win32_ver()[0])
|
|
||||||
PROGRAMFILES_32 = os.environ.get(
|
PROGRAMFILES_32 = os.environ.get(
|
||||||
'PROGRAMFILES(X86)', os.environ.get(
|
'PROGRAMFILES(X86)', os.environ.get(
|
||||||
'PROGRAMFILES', r'C:\Program Files (x86)',
|
'PROGRAMFILES', r'C:\Program Files (x86)',
|
||||||
|
|
@ -558,6 +559,11 @@ def auto_restore_default_uac():
|
||||||
TRY_PRINT.run('User Account Control...', restore_default_uac)
|
TRY_PRINT.run('User Account Control...', restore_default_uac)
|
||||||
|
|
||||||
|
|
||||||
|
def auto_show_os_name():
|
||||||
|
"""Display OS Name."""
|
||||||
|
TRY_PRINT.run('Operating System...', show_os_name)
|
||||||
|
|
||||||
|
|
||||||
def auto_windows_temp_fix():
|
def auto_windows_temp_fix():
|
||||||
"""Restore default ACLs for Windows\\Temp."""
|
"""Restore default ACLs for Windows\\Temp."""
|
||||||
TRY_PRINT.run(r'Windows\Temp fix...', fix_windows_temp)
|
TRY_PRINT.run(r'Windows\Temp fix...', fix_windows_temp)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue