Add installed RAM sections
This commit is contained in:
parent
337b6d95e1
commit
526f6e26eb
3 changed files with 30 additions and 3 deletions
|
|
@ -140,7 +140,7 @@ BASE_MENUS = {
|
||||||
MenuEntry('Operating System', 'auto_show_os_name'),
|
MenuEntry('Operating System', 'auto_show_os_name'),
|
||||||
MenuEntry('Windows Activation', 'auto_show_activation'),
|
MenuEntry('Windows Activation', 'auto_show_activation'),
|
||||||
MenuEntry('Secure Boot', 'auto_show_secure_boot_status'),
|
MenuEntry('Secure Boot', 'auto_show_secure_boot_status'),
|
||||||
MenuEntry('Installed RAM', no_op),
|
MenuEntry('Installed RAM', 'auto_show_installed_ram'),
|
||||||
MenuEntry('Storage Volumes', no_op),
|
MenuEntry('Storage Volumes', no_op),
|
||||||
MenuEntry('Virus Protection', no_op),
|
MenuEntry('Virus Protection', no_op),
|
||||||
MenuEntry('Partitions 4K Aligned', no_op),
|
MenuEntry('Partitions 4K Aligned', no_op),
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ from wk.cfg.windows_builds import (
|
||||||
WINDOWS_BUILDS,
|
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, bytes_to_string, sleep
|
||||||
|
|
||||||
|
|
||||||
# STATIC VARIABLES
|
# STATIC VARIABLES
|
||||||
|
|
@ -65,6 +65,8 @@ KNOWN_HIVE_NAMES = {
|
||||||
winreg.HKEY_USERS: 'HKEY_USERS',
|
winreg.HKEY_USERS: 'HKEY_USERS',
|
||||||
}
|
}
|
||||||
OS_VERSION = float(platform.win32_ver()[0])
|
OS_VERSION = float(platform.win32_ver()[0])
|
||||||
|
RAM_OK = 5.5 * 1024**3 # ~6 GiB assuming a bit of shared memory
|
||||||
|
RAM_WARNING = 3.5 * 1024**3 # ~4 GiB assuming a bit of shared memory
|
||||||
REG_MSISERVER = r'HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\MSIServer'
|
REG_MSISERVER = r'HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\MSIServer'
|
||||||
SLMGR = pathlib.Path(f'{os.environ.get("SYSTEMROOT")}/System32/slmgr.vbs')
|
SLMGR = pathlib.Path(f'{os.environ.get("SYSTEMROOT")}/System32/slmgr.vbs')
|
||||||
|
|
||||||
|
|
@ -143,6 +145,22 @@ def set_timezone(zone):
|
||||||
|
|
||||||
|
|
||||||
# Info Functions
|
# Info Functions
|
||||||
|
def get_installed_ram(as_list=False, raise_exceptions=False):
|
||||||
|
"""Get installed RAM."""
|
||||||
|
mem = psutil.virtual_memory()
|
||||||
|
mem_str = bytes_to_string(mem.total, decimals=1)
|
||||||
|
|
||||||
|
# Raise exception if necessary
|
||||||
|
if raise_exceptions:
|
||||||
|
if RAM_OK > mem.total >= RAM_WARNING:
|
||||||
|
raise GenericWarning(mem_str)
|
||||||
|
if mem.total > RAM_WARNING:
|
||||||
|
raise GenericError(mem_str)
|
||||||
|
|
||||||
|
# Done
|
||||||
|
return [mem_str] if as_list else mem_str
|
||||||
|
|
||||||
|
|
||||||
def get_os_activation(as_list=False, check=True):
|
def get_os_activation(as_list=False, check=True):
|
||||||
"""Get OS activation status, returns str.
|
"""Get OS activation status, returns str.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ if platform.system() == 'Windows':
|
||||||
from wk.os.win import (
|
from wk.os.win import (
|
||||||
OS_VERSION,
|
OS_VERSION,
|
||||||
activate_with_bios,
|
activate_with_bios,
|
||||||
|
get_installed_ram,
|
||||||
get_os_activation,
|
get_os_activation,
|
||||||
get_os_name,
|
get_os_name,
|
||||||
is_secure_boot_enabled,
|
is_secure_boot_enabled,
|
||||||
|
|
@ -68,6 +69,7 @@ else:
|
||||||
"""No-op function."""
|
"""No-op function."""
|
||||||
# wk.os.win
|
# wk.os.win
|
||||||
activate_with_bios = no_op
|
activate_with_bios = no_op
|
||||||
|
get_installed_ram = no_op
|
||||||
get_os_activation = no_op
|
get_os_activation = no_op
|
||||||
get_os_name = no_op
|
get_os_name = no_op
|
||||||
is_secure_boot_enabled = no_op
|
is_secure_boot_enabled = no_op
|
||||||
|
|
@ -563,8 +565,15 @@ 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_installed_ram():
|
||||||
|
"""Display installed RAM."""
|
||||||
|
TRY_PRINT.run('Installed RAM...', get_installed_ram,
|
||||||
|
as_list=True, raise_exceptions=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def auto_show_os_activation():
|
def auto_show_os_activation():
|
||||||
"""Display OS Name."""
|
"""Display OS activation status."""
|
||||||
TRY_PRINT.run('Activation...', get_os_activation, as_list=True)
|
TRY_PRINT.run('Activation...', get_os_activation, as_list=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue