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

This commit is contained in:
2Shirt 2023-03-26 23:22:34 -07:00
commit 9953f3978c
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
40 changed files with 144 additions and 280 deletions

6
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,6 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.257'
hooks:
- id: ruff

View file

@ -1,8 +1,2 @@
# WizardKit: Scripts # # WizardKit: Scripts #
## pylint ##
These scripts use two spaces per indent instead of the default four. As such you will need to update your pylintrc file or run like this:
`pylint --indent-after-paren=2 --indent-string=' ' wk`

View file

@ -1,18 +1,12 @@
"""WizardKit: Auto Repair Tool""" """WizardKit: Auto Repair Tool"""
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
import os import wk
import sys
os.chdir(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(os.getcwd())
import wk # pylint: disable=wrong-import-position
# Classes # Classes
REBOOT_STR = wk.std.color_string('Reboot', 'YELLOW') REBOOT_STR = wk.std.color_string('Reboot', 'YELLOW')
class MenuEntry(): class MenuEntry():
# pylint: disable=too-few-public-methods
"""Simple class to allow cleaner code below.""" """Simple class to allow cleaner code below."""
def __init__(self, name, function=None, selected=True, **kwargs): def __init__(self, name, function=None, selected=True, **kwargs):
self.name = name self.name = name
@ -184,5 +178,5 @@ if __name__ == '__main__':
wk.std.abort() wk.std.abort()
except SystemExit: except SystemExit:
raise raise
except: #pylint: disable=bare-except except: # noqa: E722
wk.std.major_exception() wk.std.major_exception()

View file

@ -1,17 +1,11 @@
"""WizardKit: Auto System Setup Tool""" """WizardKit: Auto System Setup Tool"""
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
import os import wk
import sys
os.chdir(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(os.getcwd())
import wk # pylint: disable=wrong-import-position
# Classes # Classes
class MenuEntry(): class MenuEntry():
# pylint: disable=too-few-public-methods
"""Simple class to allow cleaner code below.""" """Simple class to allow cleaner code below."""
def __init__(self, name, function=None, selected=True, **kwargs): def __init__(self, name, function=None, selected=True, **kwargs):
self.name = name self.name = name
@ -170,5 +164,5 @@ if __name__ == '__main__':
wk.std.abort() wk.std.abort()
except SystemExit: except SystemExit:
raise raise
except: #pylint: disable=bare-except except: # noqa: E722
wk.std.major_exception() wk.std.major_exception()

View file

@ -1,12 +1,7 @@
"""WizardKit: Build Kit (Windows).""" """WizardKit: Build Kit (Windows)."""
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
import os import wk
import sys
os.chdir(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(os.getcwd())
import wk # pylint: disable=wrong-import-position
if __name__ == '__main__': if __name__ == '__main__':
@ -16,5 +11,5 @@ if __name__ == '__main__':
wk.std.abort() wk.std.abort()
except SystemExit: except SystemExit:
raise raise
except: #pylint: disable=bare-except except: # noqa: E722
wk.std.major_exception() wk.std.major_exception()

View file

@ -1,6 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""WizardKit: ddrescue TUI""" """WizardKit: ddrescue TUI"""
# pylint: disable=invalid-name
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
from docopt import docopt from docopt import docopt
@ -20,5 +19,5 @@ if __name__ == '__main__':
wk.clone.ddrescue.main() wk.clone.ddrescue.main()
except SystemExit: except SystemExit:
raise raise
except: #pylint: disable=bare-except except: # noqa: E722
wk.std.major_exception() wk.std.major_exception()

View file

@ -5,12 +5,9 @@ python.exe -i embedded_python_env.py
""" """
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
import os import wk
import sys
os.chdir(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(os.getcwd())
import wk # pylint: disable=wrong-import-position
wk.std.print_colored( wk.std.print_colored(
(wk.cfg.main.KIT_NAME_FULL, ': ', 'Debug Console'), (wk.cfg.main.KIT_NAME_FULL, ': ', 'Debug Console'),
('GREEN', None, 'YELLOW'), ('GREEN', None, 'YELLOW'),

View file

@ -1,11 +1,6 @@
"""WizardKit: Export Bitlocker Tool""" """WizardKit: Export Bitlocker Tool"""
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
import os import wk
import sys
os.chdir(os.path.dirname(os.path.realpath(__file__))) wk.os.win.export_bitlocker_info()
sys.path.append(os.getcwd())
import wk # pylint: disable=wrong-import-position
wk.os.win.export_bitlocker_info()

View file

@ -1,6 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""WizardKit: Hardware Diagnostics""" """WizardKit: Hardware Diagnostics"""
# pylint: disable=invalid-name
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
from docopt import docopt from docopt import docopt
@ -20,5 +19,5 @@ if __name__ == '__main__':
wk.hw.diags.main() wk.hw.diags.main()
except SystemExit: except SystemExit:
raise raise
except: #pylint: disable=bare-except except: # noqa: E722
wk.std.major_exception() wk.std.major_exception()

View file

@ -1,13 +1,9 @@
"""WizardKit: Launch Snappy Driver Installer Origin""" """WizardKit: Launch Snappy Driver Installer Origin"""
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
import os import wk
import sys from wk.cfg.net import SDIO_SERVER
os.chdir(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(os.getcwd())
import wk # pylint: disable=wrong-import-position
from wk.cfg.net import SDIO_SERVER # pylint: disable=wrong-import-position
# STATIC VARIABLES # STATIC VARIABLES
MOUNT_EXCEPTIONS = ( MOUNT_EXCEPTIONS = (
@ -70,7 +66,9 @@ def use_network_sdio():
if __name__ == '__main__': if __name__ == '__main__':
wk.std.set_title(f'{wk.cfg.main.KIT_NAME_FULL}: Snappy Driver Installer Origin Launcher') wk.std.set_title(
f'{wk.cfg.main.KIT_NAME_FULL}: Snappy Driver Installer Origin Launcher',
)
log_dir = wk.log.format_log_path(tool=True).parent log_dir = wk.log.format_log_path(tool=True).parent
USE_NETWORK = False USE_NETWORK = False

View file

@ -1,6 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""WizardKit: Mount Backup Shares""" """WizardKit: Mount Backup Shares"""
# pylint: disable=invalid-name
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
import wk import wk

View file

@ -1,150 +0,0 @@
#!/bin/bash
#
## sort photorec results into something usefull
## Set paths
recup_dir="${1%/}"
[ -n "$recup_dir" ] || recup_dir="."
recup_dir="$(realpath "$recup_dir")"
out_dir="$recup_dir/Recovered"
bad_dir="$recup_dir/Corrupt"
## Test path before starting (using current dir if not specified)
for d in $recup_dir/recup*; do
### Source: http://stackoverflow.com/a/6364244
## Check if the glob gets expanded to existing files.
## If not, f here will be exactly the pattern above
## and the exists test will evaluate to false.
[ -e "$d" ] && echo "Found recup folder(s)" || {
echo "ERROR: No recup folders found"
echo "Usage: $0 recup_dir"
exit 1
}
## This is all we needed to know, so we can break after the first iteration
break
done
# Hard link files into folders by type
for d in $recup_dir/recup*; do
if [ -d "$d" ]; then
echo "Linking $d"
pushd $d >/dev/null
find -type f | while read k; do
file="$(basename "$k")"
src="$(realpath "$k")"
ext="$(echo "${file##*.}" | tr '[:upper:]' '[:lower:]')"
ext_dir="$out_dir/$ext"
if [ "${file##*.}" = "$file" ]; then
ext_dir="$out_dir/_MISC_"
elif [ "$ext" = "jpg" ] && [ "${file:0:1}" = "t" ]; then
ext_dir="$out_dir/jpg-thumbnail"
fi
#echo " $file -> $ext_dir"
[ -d "$ext_dir" ] || mkdir -p "$ext_dir"
ln "$src" "$ext_dir"
done
popd >/dev/null
else
echo "ERROR: '$d' not a directory"
fi
done
## Check the files output by photorec for corruption
pushd "$out_dir" >/dev/null
# Check archives with 7-Zip
#for d in 7z bz2 gz lzh lzo rar tar xz zip; do
# if [ -d "$d" ]; then
# echo "Checking $d files"
# pushd "$d" >/dev/null
# for f in *; do
# if ! 7z t "$f" >/dev/null 2>&1; then
# #echo " BAD: $f"
# [ -d "$bad_dir/$d" ] || mkdir -p "$bad_dir/$d"
# mv -n "$f" "$bad_dir/$d/$f"
# fi
# done
# popd >/dev/null
# fi
#done
# Check Audio/Video files with ffprobe
for d in avi flac flv m4a m4p m4v mkv mid mov mp2 mp3 mp4 mpg mpg2 ogg ts vob wav; do
if [ -d "$d" ]; then
echo "Checking $d files"
pushd "$d" >/dev/null
for f in *; do
if ! ffprobe "$f" >/dev/null 2>&1; then
#echo " BAD: $f"
[ -d "$bad_dir/$d" ] || mkdir -p "$bad_dir/$d"
mv -n "$f" "$bad_dir/$d/$f"
fi
done
popd >/dev/null
fi
done
# Check .doc files with antiword
if [ -d "doc" ]; then
echo "Checking doc files"
pushd "doc" >/dev/null
for f in *doc; do
if ! antiword "$f" >/dev/null 2>&1; then
#echo " BAD: $f"
[ -d "$bad_dir/doc" ] || mkdir -p "$bad_dir/doc"
mv -n "$f" "$bad_dir/doc/$f"
fi
done
popd >/dev/null
fi
# Check .docx files with 7z and grep
if [ -d "docx" ]; then
echo "Checking docx files"
pushd "docx" >/dev/null
for f in *docx; do
if ! 7z l "$f" | grep -q -s "word/document.xml"; then
#echo " BAD: $f"
[ -d "$bad_dir/docx" ] || mkdir -p "$bad_dir/docx"
mv -n "$f" "$bad_dir/docx/$f"
fi
done
popd >/dev/null
fi
# Sort pictures by date (only for common camera formats)
for d in jpg mrw orf raf raw rw2 tif x3f; do
if [ -d "$d" ]; then
echo "Sorting $d files by date"
pushd "$d" >/dev/null
for f in *; do
date_dir="$(date -d "$(stat -c %y "$f")" +"%F")"
[ -d "$date_dir" ] || mkdir "$date_dir"
mv -n "$f" "$date_dir/"
done
popd >/dev/null
fi
done
# Sort mov files by encoded date
if [ -d "mov" ]; then
echo "Sorting mov files by date"
pushd "mov" >/dev/null
for f in *mov; do
enc_date="$(mediainfo "$f" | grep -i "Encoded date" | head -1 | sed -r 's/.*: //')"
date_dir="$(date -d "$enc_date" +"%F")"
echo "$date_dir" | grep -E -q -s '^[0-9]{4}-[0-9]{2}-[0-9]{2}$' || date_dir="Unknown Date"
[ -d "$date_dir" ] || mkdir "$date_dir"
mv -n "$f" "$date_dir/"
done
popd >/dev/null
fi
## sort audio files by tags
## sort matroska files by metadata
## return to original dir
popd >/dev/null

18
scripts/pyproject.toml Normal file
View file

@ -0,0 +1,18 @@
[tool.ruff.per-file-ignores]
# Init files
"wk/__init__.py" = ["F401"]
"wk/cfg/__init__.py" = ["F401"]
"wk/clone/__init__.py" = ["F401"]
"wk/hw/__init__.py" = ["F401"]
"wk/kit/__init__.py" = ["F401"]
"wk/os/__init__.py" = ["F401"]
"wk/repairs/__init__.py" = ["F401"]
"wk/setup/__init__.py" = ["F401"]
# Long lines
"wk/borrowed/acpi.py" = ["E501", "F841"]
"wk/cfg/ddrescue.py" = ["E501"]
"wk/cfg/hw.py" = ["E501"]
"wk/cfg/launchers.py" = ["E501"]
"wk/cfg/setup.py" = ["E501"]
"wk/cfg/sources.py" = ["E501"]

View file

@ -1,5 +1,4 @@
"""WizardKit: Config - ddrescue""" """WizardKit: Config - ddrescue"""
# pylint: disable=line-too-long
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
from collections import OrderedDict from collections import OrderedDict

View file

@ -1,5 +1,4 @@
"""WizardKit: Config - Hardware""" """WizardKit: Config - Hardware"""
# pylint: disable=line-too-long
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
import re import re

View file

@ -1,5 +1,4 @@
"""WizardKit: Config - Launchers (Windows)""" """WizardKit: Config - Launchers (Windows)"""
# pylint: disable=line-too-long
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
LAUNCHERS = { LAUNCHERS = {

View file

@ -1,5 +1,4 @@
"""WizardKit: Config - Setup""" """WizardKit: Config - Setup"""
# pylint: disable=line-too-long
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
@ -47,8 +46,11 @@ REG_ESET_NOD32_SETTINGS = {
}, },
} }
REG_WINDOWS_EXPLORER = { REG_WINDOWS_EXPLORER = {
# pylint: disable=line-too-long
'HKLM': { 'HKLM': {
# Allow password sign-in for MS accounts
r'Software\Microsoft\Windows NT\CurrentVersion\PasswordLess\Device': (
('DevicePasswordLessBuildVersion', 0, 'DWORD'),
),
# Disable Location Tracking # Disable Location Tracking
r'Software\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}': ( r'Software\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}': (
('SensorPermissionState', 0, 'DWORD'), ('SensorPermissionState', 0, 'DWORD'),

View file

@ -1,5 +1,4 @@
"""WizardKit: Config - Tool Sources""" """WizardKit: Config - Tool Sources"""
# pylint: disable=line-too-long
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2

View file

@ -1,5 +1,4 @@
"""WizardKit: ddrescue TUI""" """WizardKit: ddrescue TUI"""
# pylint: disable=too-many-lines
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
import atexit import atexit
@ -129,7 +128,6 @@ TIMEZONE = pytz.timezone(cfg.main.LINUX_TIME_ZONE)
# Classes # Classes
class BlockPair(): class BlockPair():
"""Object for tracking source to dest recovery data.""" """Object for tracking source to dest recovery data."""
# pylint: disable=too-many-instance-attributes
def __init__(self, source, destination, model, working_dir): def __init__(self, source, destination, model, working_dir):
"""Initialize BlockPair() """Initialize BlockPair()
@ -357,7 +355,6 @@ class BlockPair():
class State(): class State():
# pylint: disable=too-many-instance-attributes,too-many-public-methods
"""Object for tracking hardware diagnostic data.""" """Object for tracking hardware diagnostic data."""
def __init__(self): def __init__(self):
self.block_pairs = [] self.block_pairs = []
@ -727,7 +724,6 @@ class State():
return sum(pair.size for pair in self.block_pairs) return sum(pair.size for pair in self.block_pairs)
def init_recovery(self, docopt_args): def init_recovery(self, docopt_args):
# pylint: disable=too-many-branches,too-many-statements
"""Select source/dest and set env.""" """Select source/dest and set env."""
std.clear_screen() std.clear_screen()
source_parts = [] source_parts = []
@ -2022,7 +2018,6 @@ def source_or_destination_changed(state):
def main(): def main():
# pylint: disable=too-many-branches
"""Main function for ddrescue TUI.""" """Main function for ddrescue TUI."""
args = docopt(DOCSTRING) args = docopt(DOCSTRING)
log.update_log_path(dest_name='ddrescue-TUI', timestamp=True) log.update_log_path(dest_name='ddrescue-TUI', timestamp=True)
@ -2179,7 +2174,6 @@ def mount_raw_image_macos(path):
def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True): def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True):
# pylint: disable=too-many-statements
"""Run ddrescue using passed settings.""" """Run ddrescue using passed settings."""
cmd = build_ddrescue_cmd(block_pair, pass_name, settings) cmd = build_ddrescue_cmd(block_pair, pass_name, settings)
poweroff_source_after_idle = True poweroff_source_after_idle = True
@ -2327,7 +2321,6 @@ def run_ddrescue(state, block_pair, pass_name, settings, dry_run=True):
def run_recovery(state, main_menu, settings_menu, dry_run=True): def run_recovery(state, main_menu, settings_menu, dry_run=True):
# pylint: disable=too-many-branches
"""Run recovery passes.""" """Run recovery passes."""
atexit.register(state.save_debug_reports) atexit.register(state.save_debug_reports)
attempted_recovery = False attempted_recovery = False

View file

@ -1,11 +1,9 @@
"""WizardKit: Debug Functions""" """WizardKit: Debug Functions"""
# pylint: disable=invalid-name
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
# Classes # Classes
class Debug(): class Debug():
# pylint: disable=too-few-public-methods
"""Object used when dumping debug data.""" """Object used when dumping debug data."""
def method(self): def method(self):
"""Dummy method used to identify functions vs data.""" """Dummy method used to identify functions vs data."""

View file

@ -21,7 +21,6 @@ LOG = logging.getLogger(__name__)
# Classes # Classes
class NonBlockingStreamReader(): class NonBlockingStreamReader():
"""Class to allow non-blocking reads from a stream.""" """Class to allow non-blocking reads from a stream."""
# pylint: disable=too-few-public-methods
# Credits: # Credits:
## https://gist.github.com/EyalAr/7915597 ## https://gist.github.com/EyalAr/7915597
## https://stackoverflow.com/a/4896288 ## https://stackoverflow.com/a/4896288
@ -204,7 +203,6 @@ def popen_program(cmd, minimized=False, pipe=False, shell=False, **kwargs):
shell=shell, shell=shell,
**kwargs) **kwargs)
try: try:
# pylint: disable=consider-using-with
proc = subprocess.Popen(**cmd_kwargs) proc = subprocess.Popen(**cmd_kwargs)
except FileNotFoundError: except FileNotFoundError:
LOG.error('Command not found: %s', cmd) LOG.error('Command not found: %s', cmd)
@ -216,7 +214,6 @@ def popen_program(cmd, minimized=False, pipe=False, shell=False, **kwargs):
def run_program(cmd, check=True, pipe=True, shell=False, **kwargs): def run_program(cmd, check=True, pipe=True, shell=False, **kwargs):
# pylint: disable=subprocess-run-check
"""Run program and return a subprocess.CompletedProcess object.""" """Run program and return a subprocess.CompletedProcess object."""
LOG.debug( LOG.debug(
'cmd: %s, check: %s, pipe: %s, shell: %s', 'cmd: %s, check: %s, pipe: %s, shell: %s',

View file

@ -371,7 +371,6 @@ class State():
# Functions # Functions
def build_menu(cli_mode=False, quick_mode=False) -> std.Menu: def build_menu(cli_mode=False, quick_mode=False) -> std.Menu:
# pylint: disable=too-many-branches
"""Build main menu, returns wk.std.Menu.""" """Build main menu, returns wk.std.Menu."""
menu = std.Menu(title=None) menu = std.Menu(title=None)
@ -427,7 +426,6 @@ def build_menu(cli_mode=False, quick_mode=False) -> std.Menu:
def cpu_stress_tests(state, test_objects, test_mode=False) -> None: def cpu_stress_tests(state, test_objects, test_mode=False) -> None:
# pylint: disable=too-many-statements
"""CPU & cooling check using Prime95 and Sysbench.""" """CPU & cooling check using Prime95 and Sysbench."""
LOG.info('CPU Test (Prime95)') LOG.info('CPU Test (Prime95)')
aborted = False aborted = False
@ -568,7 +566,6 @@ def cpu_stress_tests(state, test_objects, test_mode=False) -> None:
def disk_attribute_check(state, test_objects, test_mode=False) -> None: def disk_attribute_check(state, test_objects, test_mode=False) -> None:
# pylint: disable=unused-argument
"""Disk attribute check.""" """Disk attribute check."""
LOG.info('Disk Attribute Check') LOG.info('Disk Attribute Check')
for test in test_objects: for test in test_objects:
@ -654,7 +651,6 @@ def disk_io_benchmark(
def disk_self_test(state, test_objects, test_mode=False) -> None: def disk_self_test(state, test_objects, test_mode=False) -> None:
# pylint: disable=unused-argument
"""Disk self-test if available.""" """Disk self-test if available."""
LOG.info('Disk Self-Test(s)') LOG.info('Disk Self-Test(s)')
aborted = False aborted = False
@ -827,7 +823,6 @@ def disk_volume_utilization(state, test_objects, test_mode=False) -> None:
def main() -> None: def main() -> None:
# pylint: disable=too-many-branches
"""Main function for hardware diagnostics.""" """Main function for hardware diagnostics."""
args = docopt(DOCSTRING) args = docopt(DOCSTRING)
log.update_log_path(dest_name='Hardware-Diagnostics', timestamp=True) log.update_log_path(dest_name='Hardware-Diagnostics', timestamp=True)

View file

@ -33,7 +33,6 @@ WK_LABEL_REGEX = re.compile(
# Classes # Classes
@dataclass(**DATACLASS_DECORATOR_KWARGS) @dataclass(**DATACLASS_DECORATOR_KWARGS)
class Disk: class Disk:
# pylint: disable=too-many-instance-attributes
"""Object for tracking disk specific data.""" """Object for tracking disk specific data."""
attributes: dict[Any, dict] = field(init=False, default_factory=dict) attributes: dict[Any, dict] = field(init=False, default_factory=dict)
bus: str = field(init=False) bus: str = field(init=False)

View file

@ -121,7 +121,6 @@ class Sensors():
self, out_path, alt_max=None, self, out_path, alt_max=None,
exit_on_thermal_limit=True, temp_labels=None, exit_on_thermal_limit=True, temp_labels=None,
thermal_action=None) -> None: thermal_action=None) -> None:
# pylint: disable=too-many-arguments
"""Write report to path every second until stopped. """Write report to path every second until stopped.
thermal_action is a cmd to run if ThermalLimitReachedError is caught. thermal_action is a cmd to run if ThermalLimitReachedError is caught.
@ -182,7 +181,6 @@ class Sensors():
self, out_path, alt_max=None, self, out_path, alt_max=None,
exit_on_thermal_limit=True, temp_labels=None, exit_on_thermal_limit=True, temp_labels=None,
thermal_action=None) -> None: thermal_action=None) -> None:
# pylint: disable=too-many-arguments
"""Start background thread to save report to file. """Start background thread to save report to file.
thermal_action is a cmd to run if ThermalLimitReachedError is caught. thermal_action is a cmd to run if ThermalLimitReachedError is caught.
@ -315,7 +313,11 @@ def get_sensor_data_linux() -> dict[Any, Any]:
## current temp is labeled xxxx_input ## current temp is labeled xxxx_input
for source, labels in sources.items(): for source, labels in sources.items():
for label, temp in labels.items(): for label, temp in labels.items():
if label.startswith('fan') or label.startswith('in') or label.startswith('curr'): if (
label.startswith('fan')
or label.startswith('in')
or label.startswith('curr')
):
# Skip fan RPMs and voltages # Skip fan RPMs and voltages
continue continue
if 'input' in label: if 'input' in label:

View file

@ -8,7 +8,6 @@ from wk.cfg.python import DATACLASS_DECORATOR_KWARGS
@dataclass(**DATACLASS_DECORATOR_KWARGS) @dataclass(**DATACLASS_DECORATOR_KWARGS)
class Test: class Test:
# pylint: disable=too-many-instance-attributes
"""Object for tracking test specific data.""" """Object for tracking test specific data."""
dev: Any dev: Any
label: str label: str

View file

@ -228,7 +228,11 @@ def download_fastcopy():
def download_furmark(): def download_furmark():
"""Download FurMark.""" """Download FurMark."""
installer = download_to_temp('FurMark_Setup.exe', SOURCES['FurMark'], referer=SOURCES['FurMark']) installer = download_to_temp(
'FurMark_Setup.exe',
SOURCES['FurMark'],
referer=SOURCES['FurMark'],
)
out_path = BIN_DIR.joinpath('FurMark') out_path = BIN_DIR.joinpath('FurMark')
tmp_path = TMP_DIR.joinpath('FurMarkInstall') tmp_path = TMP_DIR.joinpath('FurMarkInstall')
run_program([installer, f'/DIR={tmp_path}', '/SILENT']) run_program([installer, f'/DIR={tmp_path}', '/SILENT'])

View file

@ -55,13 +55,23 @@ def download_file(out_path, source_url, as_new=False, overwrite=False, referer=N
# Request download # Request download
with requests.Session() as session: with requests.Session() as session:
try: try:
response = session.get(source_url, allow_redirects=True, headers=headers, stream=True) response = session.get(
except requests.RequestException as _err: source_url,
allow_redirects=True,
headers=headers,
stream=True,
)
except requests.RequestException:
try: try:
sleep(1) sleep(1)
response = session.get(source_url, allow_redirects=True, headers=headers, stream=True) response = session.get(
except requests.RequestException as _err2: source_url,
download_failed = _err2 allow_redirects=True,
headers=headers,
stream=True,
)
except requests.RequestException as _err:
download_failed = _err
else: else:
if not response.ok: if not response.ok:
download_failed = response download_failed = response

View file

@ -90,7 +90,6 @@ def apply_image(part_path, image_path, hide_macos_boot=True):
def build_ufd(): def build_ufd():
# pylint: disable=too-many-statements
"""Build UFD using selected sources.""" """Build UFD using selected sources."""
args = docopt(DOCSTRING) args = docopt(DOCSTRING)
if args['--debug']: if args['--debug']:

View file

@ -41,7 +41,6 @@ def enable_debug_mode():
def format_log_path( def format_log_path(
log_dir=None, log_name=None, timestamp=False, log_dir=None, log_name=None, timestamp=False,
kit=False, tool=False, append=False): kit=False, tool=False, append=False):
# pylint: disable=too-many-arguments
"""Format path based on args passed, returns pathlib.Path obj.""" """Format path based on args passed, returns pathlib.Path obj."""
log_path = pathlib.Path( log_path = pathlib.Path(
f'{log_dir if log_dir else DEFAULT_LOG_DIR}/' f'{log_dir if log_dir else DEFAULT_LOG_DIR}/'

View file

@ -178,7 +178,6 @@ def mount(source, mount_point=None, read_write=False):
def mount_volumes(device_path=None, read_write=False, scan_corestorage=False): def mount_volumes(device_path=None, read_write=False, scan_corestorage=False):
# pylint: disable=too-many-branches
"""Mount all detected volumes. """Mount all detected volumes.
NOTE: If device_path is specified then only volumes NOTE: If device_path is specified then only volumes

View file

@ -6,6 +6,7 @@ import logging
import os import os
import pathlib import pathlib
import platform import platform
import re
from contextlib import suppress from contextlib import suppress
import psutil import psutil
@ -73,6 +74,9 @@ KNOWN_HIVE_NAMES = {
RAM_OK = 5.5 * 1024**3 # ~6 GiB assuming a bit of shared memory 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 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'
REGEX_4K_ALIGNMENT = re.compile(
r'^(?P<description>.*?)\s+(?P<size>\d+)\s+(?P<offset>\d+)',
)
SLMGR = pathlib.Path(f'{os.environ.get("SYSTEMROOT")}/System32/slmgr.vbs') SLMGR = pathlib.Path(f'{os.environ.get("SYSTEMROOT")}/System32/slmgr.vbs')
SYSTEMDRIVE = os.environ.get('SYSTEMDRIVE') SYSTEMDRIVE = os.environ.get('SYSTEMDRIVE')
@ -165,19 +169,41 @@ def set_timezone(zone):
# Info Functions # Info Functions
def check_4k_alignment(show_alert=False): def check_4k_alignment(show_alert=False):
"""Check if all partitions are 4K aligned, returns book.""" """Check if all partitions are 4K aligned, returns book."""
cmd = ['WMIC', 'partition', 'get', 'StartingOffset'] cmd = ['WMIC', 'partition', 'get', 'Caption,Size,StartingOffset']
report = []
show_alert = False
# Check offsets # Check offsets
proc = run_program(cmd) proc = run_program(cmd)
for offset in proc.stdout.splitlines(): for line in proc.stdout.splitlines():
offset = offset.strip() line = line.strip()
if not offset.isnumeric(): if not line or not line.startswith('Disk'):
continue continue
if int(offset) % 4096 != 0: match = REGEX_4K_ALIGNMENT.match(line)
# Not aligned if not match:
if show_alert: LOG.error('Failed to parse partition info for: %s', line)
show_alert_box('One or more partitions are not 4K aligned') continue
raise GenericError('One or more partitions are not 4K aligned') if int(match.group('offset')) % 4096 == 0:
report.append(
color_string(
f'{match.group("description")}'
f' ({bytes_to_string(match.group("size"), decimals=1)})'
,
'RED'
)
)
# Show alert
if show_alert:
show_alert_box('One or more partitions not 4K aligned')
# Done
if report:
report.insert(
0,
color_string('One or more partitions not 4K aligned', 'YELLOW'),
)
return report
def defender_is_disabled(): def defender_is_disabled():
@ -411,7 +437,6 @@ def show_alert_box(message, title=None):
# 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
"""Delete a key from the registry. """Delete a key from the registry.
NOTE: If recurse is False then it will only work on empty keys. NOTE: If recurse is False then it will only work on empty keys.
@ -575,7 +600,6 @@ def reg_write_settings(settings):
def reg_set_value(hive, key, name, data, data_type, option=None): def reg_set_value(hive, key, name, data, data_type, option=None):
# pylint: disable=too-many-arguments
"""Set value for hive/key.""" """Set value for hive/key."""
access = winreg.KEY_WRITE access = winreg.KEY_WRITE
data_type = reg_get_data_type(data_type) data_type = reg_get_data_type(data_type)
@ -759,7 +783,7 @@ def start_service(service_name):
run_program(cmd, check=False) run_program(cmd, check=False)
# Verify service was started # Verify service was started
if not get_service_status(service_name) in ('running', 'start_pending'): if get_service_status(service_name) not in ('running', 'start_pending'):
raise GenericError(f'Failed to start service {service_name}') raise GenericError(f'Failed to start service {service_name}')

View file

@ -1,5 +1,4 @@
"""WizardKit: Repairs - Windows""" """WizardKit: Repairs - Windows"""
# pylint: disable=too-many-lines
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
import atexit import atexit
@ -564,7 +563,12 @@ def set_log_path():
# Ignore and use default values # Ignore and use default values
update_log_path(dest_name='Auto Repairs', timestamp=True) update_log_path(dest_name='Auto Repairs', timestamp=True)
else: else:
update_log_path(dest_name=log_path, keep_history=False, timestamp=False, append=True) update_log_path(
dest_name=log_path,
keep_history=False,
timestamp=False,
append=True,
)
def show_main_menu(base_menus, menus, presets, title): def show_main_menu(base_menus, menus, presets, title):

View file

@ -1,5 +1,4 @@
"""WizardKit: Setup - Windows""" """WizardKit: Setup - Windows"""
# pylint: disable=too-many-lines
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
import configparser import configparser

View file

@ -1,5 +1,4 @@
"""WizardKit: Standard Functions""" """WizardKit: Standard Functions"""
# pylint: disable=too-many-lines
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
import inspect import inspect
@ -134,7 +133,6 @@ class Menu():
def _get_display_name( def _get_display_name(
self, name, details, self, name, details,
index=None, no_checkboxes=True, setting_item=False): index=None, no_checkboxes=True, setting_item=False):
# pylint: disable=too-many-arguments
"""Format display name based on details and args, returns str.""" """Format display name based on details and args, returns str."""
disabled = details.get('Disabled', False) disabled = details.get('Disabled', False)
if setting_item and not details['Selected']: if setting_item and not details['Selected']:
@ -400,7 +398,6 @@ class Menu():
class TryAndPrint(): class TryAndPrint():
# pylint: disable=too-many-instance-attributes
"""Object used to standardize running functions and returning the result. """Object used to standardize running functions and returning the result.
The errors and warning attributes are used to allow fine-tuned results The errors and warning attributes are used to allow fine-tuned results
@ -521,7 +518,6 @@ class TryAndPrint():
def run( def run(
self, message, function, *args, self, message, function, *args,
catch_all=None, msg_good=None, verbose=None, **kwargs): catch_all=None, msg_good=None, verbose=None, **kwargs):
# pylint: disable=catching-non-exception
"""Run a function and print the results, returns results as dict. """Run a function and print the results, returns results as dict.
If catch_all is True then (nearly) all exceptions will be caught. If catch_all is True then (nearly) all exceptions will be caught.

View file

@ -203,7 +203,6 @@ def prep_file(path):
def resize_pane(pane_id=None, width=None, height=None, **kwargs): def resize_pane(pane_id=None, width=None, height=None, **kwargs):
# pylint: disable=unused-argument
"""Resize current or target pane. """Resize current or target pane.
NOTE: kwargs is only here to make calling this function easier NOTE: kwargs is only here to make calling this function easier

View file

@ -1,16 +1,11 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""WizardKit: Debug Launcher""" """WizardKit: Debug Launcher"""
# pylint: disable=invalid-name
# vim: sts=2 sw=2 ts=2 # vim: sts=2 sw=2 ts=2
import os
import pathlib import pathlib
import pickle import pickle
import sys
os.chdir(os.path.dirname(os.path.realpath(__file__))) import wk
sys.path.append(os.getcwd())
import wk # pylint: disable=wrong-import-position
# STATIC VARIABLES # STATIC VARIABLES

View file

@ -118,12 +118,11 @@ function update_live_env() {
sed -i -r "s/SUPPORT_URL/$KIT_NAME_SHORT/" "$PROFILE_DIR/profiledef.sh" sed -i -r "s/SUPPORT_URL/$KIT_NAME_SHORT/" "$PROFILE_DIR/profiledef.sh"
# Boot config (legacy) # Boot config (legacy)
mkdir -p "$PROFILE_DIR/syslinux/wimboot" mkdir -p "$TEMP_DIR" 2>/dev/null
git clone --depth=1 https://github.com/ipxe/wimboot "$TEMP_DIR/wimboot"
rsync -aI "$TEMP_DIR/wimboot"/{LICENSE.txt,README.md,wimboot} "$PROFILE_DIR/syslinux/wimboot/"
cp "$ROOT_DIR/images/Syslinux.jpg" "$PROFILE_DIR/syslinux/syslinux.jpg" cp "$ROOT_DIR/images/Syslinux.jpg" "$PROFILE_DIR/syslinux/syslinux.jpg"
sed -i -r "s/__+/$KIT_NAME_FULL/" "$PROFILE_DIR/syslinux/syslinux.cfg" sed -i -r "s/__+/$KIT_NAME_FULL/" "$PROFILE_DIR/syslinux/syslinux.cfg"
mkdir -p "$TEMP_DIR" 2>/dev/null
curl -Lo "$TEMP_DIR/wimboot.zip" "http://git.ipxe.org/releases/wimboot/wimboot-latest.zip"
7z e -aoa "$TEMP_DIR/wimboot.zip" -o"$PROFILE_DIR/syslinux/wimboot" 'wimboot*/LICENSE.txt' 'wimboot*/README.txt' 'wimboot*/wimboot'
# Boot config (UEFI) # Boot config (UEFI)
curl -Lo "$TEMP_DIR/refind.zip" "https://sourceforge.net/projects/refind/files/latest/download" curl -Lo "$TEMP_DIR/refind.zip" "https://sourceforge.net/projects/refind/files/latest/download"
@ -134,7 +133,14 @@ function update_live_env() {
rsync -aI "$TEMP_DIR/refind"/refind*/refind/icons/ "$PROFILE_DIR/EFI/boot/icons/" rsync -aI "$TEMP_DIR/refind"/refind*/refind/icons/ "$PROFILE_DIR/EFI/boot/icons/"
sed -i "s/%ARCHISO_LABEL%/${label}/" "$PROFILE_DIR/EFI/boot/refind.conf" sed -i "s/%ARCHISO_LABEL%/${label}/" "$PROFILE_DIR/EFI/boot/refind.conf"
# Memtest86 # Memtest86+ (Open Source)
mkdir -p "$PROFILE_DIR/EFI/memtest86+"
mkdir -p "$TEMP_DIR/memtest86+"
curl -Lo "$TEMP_DIR/memtest86+/memtest86-binaries.zip" "https://memtest.org/download/v6.10/mt86plus_6.10.binaries.zip"
7z e "$TEMP_DIR/memtest86+/memtest86-binaries.zip" -o"$TEMP_DIR/memtest86+" "memtest64.efi"
mv "$TEMP_DIR/memtest86+/memtest64.efi" "$PROFILE_DIR/EFI/memtest86+/bootx64.efi"
# Memtest86 (Passmark)
mkdir -p "$PROFILE_DIR/EFI/memtest86/Benchmark" mkdir -p "$PROFILE_DIR/EFI/memtest86/Benchmark"
mkdir -p "$TEMP_DIR/memtest86" mkdir -p "$TEMP_DIR/memtest86"
curl -Lo "$TEMP_DIR/memtest86/memtest86-usb.zip" "https://www.memtest86.com/downloads/memtest86-usb.zip" curl -Lo "$TEMP_DIR/memtest86/memtest86-usb.zip" "https://www.memtest86.com/downloads/memtest86-usb.zip"
@ -142,7 +148,7 @@ function update_live_env() {
7z e -aoa "$TEMP_DIR/memtest86/memtest86-usb.img" -o"$TEMP_DIR/memtest86" "MemTest86.img" 7z e -aoa "$TEMP_DIR/memtest86/memtest86-usb.img" -o"$TEMP_DIR/memtest86" "MemTest86.img"
7z x -aoa "$TEMP_DIR/memtest86/MemTest86.img" -o"$TEMP_DIR/memtest86" 7z x -aoa "$TEMP_DIR/memtest86/MemTest86.img" -o"$TEMP_DIR/memtest86"
rm "$TEMP_DIR/memtest86/EFI/BOOT/BOOTIA32.efi" rm "$TEMP_DIR/memtest86/EFI/BOOT/BOOTIA32.efi"
mv "$TEMP_DIR/memtest86/EFI/BOOT/BOOTX64.efi" "$PROFILE_DIR/EFI/memtest86/memtestx64.efi" mv "$TEMP_DIR/memtest86/EFI/BOOT/BOOTX64.efi" "$PROFILE_DIR/EFI/memtest86/bootx64.efi"
mv "$TEMP_DIR/memtest86/EFI/BOOT"/* "$PROFILE_DIR/EFI/memtest86"/ mv "$TEMP_DIR/memtest86/EFI/BOOT"/* "$PROFILE_DIR/EFI/memtest86"/
mv "$TEMP_DIR/memtest86/help"/* "$PROFILE_DIR/EFI/memtest86"/ mv "$TEMP_DIR/memtest86/help"/* "$PROFILE_DIR/EFI/memtest86"/
mv "$TEMP_DIR/memtest86/license.rtf" "$PROFILE_DIR/EFI/memtest86"/ mv "$TEMP_DIR/memtest86/license.rtf" "$PROFILE_DIR/EFI/memtest86"/

View file

@ -3,7 +3,7 @@
timeout 0 timeout 0
scanfor manual scanfor manual
showtools firmware,reboot,shutdown showtools firmware,reboot,shutdown
default_selection MemTest86 default_selection Linux
csr_values 10,77 csr_values 10,77
#use_graphics_for osx,linux,windows #use_graphics_for osx,linux,windows
@ -15,11 +15,6 @@ selection_small selection_small.png
hideui arrows,badges hideui arrows,badges
# Entries # Entries
menuentry "MemTest86" {
icon /EFI/boot/icons/wk_memtest.png
loader /EFI/memtest86/bootx64.efi
}
menuentry "Linux" { menuentry "Linux" {
icon /EFI/boot/icons/wk_arch.png icon /EFI/boot/icons/wk_arch.png
loader /arch/boot/x86_64/vmlinuz-linux loader /arch/boot/x86_64/vmlinuz-linux
@ -32,6 +27,19 @@ menuentry "Linux" {
} }
} }
menuentry "MemTest86+" {
icon /EFI/boot/icons/wk_memtest.png
options "nobigstatus nopause"
loader /EFI/memtest86+/bootx64.efi
submenuentry "Memtest86+ (Open Source)" {
loader /EFI/memtest86+/bootx64.efi
}
submenuentry "Memtest86 (Passmark)" {
loader /EFI/memtest86/bootx64.efi
options
}
}
#UFD-MACOS-10.11#menuentry "macOS (El Capitan)" { #UFD-MACOS-10.11#menuentry "macOS (El Capitan)" {
#UFD-MACOS-10.11# icon /EFI/boot/icons/wk_mac_10.11.png #UFD-MACOS-10.11# icon /EFI/boot/icons/wk_mac_10.11.png
#UFD-MACOS-10.11# volume "PARTUUID" #UFD-MACOS-10.11# volume "PARTUUID"

View file

@ -35,11 +35,11 @@ MENU SEPARATOR
MENU CLEAR MENU CLEAR
DEFAULT memtest DEFAULT wk_linux
TIMEOUT 0 TIMEOUT 0
INCLUDE memtest.cfg
INCLUDE linux.cfg INCLUDE linux.cfg
INCLUDE memtest.cfg
#UFD-WINPE#INCLUDE winpe.cfg #UFD-WINPE#INCLUDE winpe.cfg
#UFD-ESET#INCLUDE eset.cfg #UFD-ESET#INCLUDE eset.cfg

View file

@ -190,6 +190,9 @@ if ($MyInvocation.InvocationName -ne ".") {
} }
Remove-Item "$Temp\python*.zip" Remove-Item "$Temp\python*.zip"
Remove-Item "$Temp\*.whl" Remove-Item "$Temp\*.whl"
foreach ($File in Get-ChildItem "$Bin\Python\*\*._pth") {
Add-Content "$File" "`n#WizardKit`n..\..\Scripts"
}
## Done ## ## Done ##
Pop-Location Pop-Location