Updated docstrings longer than 72 characters
This commit is contained in:
parent
387062074a
commit
c501c8b23f
10 changed files with 30 additions and 18 deletions
|
|
@ -170,7 +170,13 @@ def backup_browsers():
|
||||||
function=archive_browser, name=name)
|
function=archive_browser, name=name)
|
||||||
|
|
||||||
def clean_chromium_profile(profile):
|
def clean_chromium_profile(profile):
|
||||||
"""Renames profile, creates a new folder, and copies the user data to it."""
|
"""Recreate profile with only the essential user data.
|
||||||
|
|
||||||
|
This is done by renaming the existing profile, creating a new folder
|
||||||
|
with the original name, then copying the essential files from the
|
||||||
|
backup folder. This way the original state is preserved in case
|
||||||
|
something goes wrong.
|
||||||
|
"""
|
||||||
if profile is None:
|
if profile is None:
|
||||||
raise Exception
|
raise Exception
|
||||||
backup_path = '{path}_{Date}.bak'.format(
|
backup_path = '{path}_{Date}.bak'.format(
|
||||||
|
|
@ -203,7 +209,13 @@ def clean_internet_explorer(**kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def clean_mozilla_profile(profile):
|
def clean_mozilla_profile(profile):
|
||||||
"""Renames profile, creates a new folder, and copies the user data to it."""
|
"""Recreate profile with only the essential user data.
|
||||||
|
|
||||||
|
This is done by renaming the existing profile, creating a new folder
|
||||||
|
with the original name, then copying the essential files from the
|
||||||
|
backup folder. This way the original state is preserved in case
|
||||||
|
something goes wrong.
|
||||||
|
"""
|
||||||
if profile is None:
|
if profile is None:
|
||||||
raise Exception
|
raise Exception
|
||||||
backup_path = '{path}_{Date}.bak'.format(
|
backup_path = '{path}_{Date}.bak'.format(
|
||||||
|
|
@ -229,7 +241,7 @@ def clean_mozilla_profile(profile):
|
||||||
f.write('user_pref("{}", {});\n'.format(k, v))
|
f.write('user_pref("{}", {});\n'.format(k, v))
|
||||||
|
|
||||||
def get_browser_details(name):
|
def get_browser_details(name):
|
||||||
"""Get install status and profile details for all supported browsers."""
|
"""Get installation and profile details for all supported browsers."""
|
||||||
browser = SUPPORTED_BROWSERS[name].copy()
|
browser = SUPPORTED_BROWSERS[name].copy()
|
||||||
|
|
||||||
# Update user_data_path
|
# Update user_data_path
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ def abort():
|
||||||
exit_script()
|
exit_script()
|
||||||
|
|
||||||
def ask(prompt='Kotaero!'):
|
def ask(prompt='Kotaero!'):
|
||||||
"""Prompt the user with a Y/N question, log answer, and return a bool."""
|
"""Prompt the user with a Y/N question, returns bool."""
|
||||||
answer = None
|
answer = None
|
||||||
prompt = '{} [Y/N]: '.format(prompt)
|
prompt = '{} [Y/N]: '.format(prompt)
|
||||||
while answer is None:
|
while answer is None:
|
||||||
|
|
@ -110,7 +110,7 @@ def ask(prompt='Kotaero!'):
|
||||||
return answer
|
return answer
|
||||||
|
|
||||||
def choice(choices, prompt='Kotaero!'):
|
def choice(choices, prompt='Kotaero!'):
|
||||||
"""Prompt the user with a choice question, log answer, and returns str."""
|
"""Prompt the user with a choice question, returns str."""
|
||||||
answer = None
|
answer = None
|
||||||
choices = [str(c) for c in choices]
|
choices = [str(c) for c in choices]
|
||||||
choices_short = {c[:1].upper(): c for c in choices}
|
choices_short = {c[:1].upper(): c for c in choices}
|
||||||
|
|
@ -252,7 +252,7 @@ def get_ticket_number():
|
||||||
return ticket_number
|
return ticket_number
|
||||||
|
|
||||||
def human_readable_size(size, decimals=0):
|
def human_readable_size(size, decimals=0):
|
||||||
"""Convert size in bytes to a human-readable format and return a str."""
|
"""Convert size from bytes to a human-readable format, returns str."""
|
||||||
# Prep string formatting
|
# Prep string formatting
|
||||||
width = 3+decimals
|
width = 3+decimals
|
||||||
if decimals > 0:
|
if decimals > 0:
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ SEM_NOOPENFILEERRORBOX = 0x8000
|
||||||
SEM_FAIL = SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS
|
SEM_FAIL = SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS
|
||||||
|
|
||||||
def cleanup_transfer(dest_path):
|
def cleanup_transfer(dest_path):
|
||||||
"""Fix attributes and move extraneous items outside the Transfer folder."""
|
"""Fix attributes and move excluded items to separate folder."""
|
||||||
try:
|
try:
|
||||||
# Remove dest_path if empty
|
# Remove dest_path if empty
|
||||||
os.rmdir(dest_path)
|
os.rmdir(dest_path)
|
||||||
|
|
@ -221,7 +221,7 @@ def fix_path_sep(path_str):
|
||||||
return re.sub(r'(\\|/)+', lambda s: os.sep, path_str)
|
return re.sub(r'(\\|/)+', lambda s: os.sep, path_str)
|
||||||
|
|
||||||
def is_valid_wim_file(item):
|
def is_valid_wim_file(item):
|
||||||
"""Checks if the provided os.DirEntry is a valid WIM file, returns bool."""
|
"""Checks if the item is a valid WIM file, returns bool."""
|
||||||
valid = bool(item.is_file() and REGEX_WIM_FILE.search(item.name))
|
valid = bool(item.is_file() and REGEX_WIM_FILE.search(item.name))
|
||||||
if valid:
|
if valid:
|
||||||
extract_item('wimlib', silent=True)
|
extract_item('wimlib', silent=True)
|
||||||
|
|
|
||||||
|
|
@ -255,7 +255,7 @@ class ImageObj(BaseObj):
|
||||||
self.path))
|
self.path))
|
||||||
|
|
||||||
def set_details(self):
|
def set_details(self):
|
||||||
"""Setup loopback device, set details via lsblk, then detach device."""
|
"""Set details using a temp loopback device."""
|
||||||
self.type = 'image'
|
self.type = 'image'
|
||||||
self.loop_dev = setup_loopback_device(self.path)
|
self.loop_dev = setup_loopback_device(self.path)
|
||||||
self.details = get_device_details(self.loop_dev)
|
self.details = get_device_details(self.loop_dev)
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ def get_installed_office():
|
||||||
return programs
|
return programs
|
||||||
|
|
||||||
def get_shell_path(folder, user='current'):
|
def get_shell_path(folder, user='current'):
|
||||||
"""Get shell path using SHGetKnownFolderPath via knownpaths, returns str.
|
"""Get shell path using knownpaths, returns str.
|
||||||
|
|
||||||
NOTE: Only works for the current user.
|
NOTE: Only works for the current user.
|
||||||
Code based on https://gist.github.com/mkropat/7550097
|
Code based on https://gist.github.com/mkropat/7550097
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ def run_chkdsk_offline():
|
||||||
raise GenericError
|
raise GenericError
|
||||||
|
|
||||||
def run_dism(repair=False):
|
def run_dism(repair=False):
|
||||||
"""Run DISM /RestoreHealth, then /CheckHealth, and then report errors."""
|
"""Run DISM to either scan or repair component store health."""
|
||||||
if global_vars['OS']['Version'] in ('8', '8.1', '10'):
|
if global_vars['OS']['Version'] in ('8', '8.1', '10'):
|
||||||
if repair:
|
if repair:
|
||||||
# Restore Health
|
# Restore Health
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ def monitor_sensors(monitor_pane, monitor_file):
|
||||||
break
|
break
|
||||||
|
|
||||||
def save_average_temp(sensor_data, temp_label, seconds=10):
|
def save_average_temp(sensor_data, temp_label, seconds=10):
|
||||||
"""Calculate average temps and record under temp_label, returns dict."""
|
"""Save average temps under temp_label, returns dict."""
|
||||||
clear_temps(sensor_data)
|
clear_temps(sensor_data)
|
||||||
|
|
||||||
# Get temps
|
# Get temps
|
||||||
|
|
|
||||||
|
|
@ -181,11 +181,11 @@ def config_classicstart():
|
||||||
popen_program(cs_exe)
|
popen_program(cs_exe)
|
||||||
|
|
||||||
def config_explorer_system():
|
def config_explorer_system():
|
||||||
"""Configure Windows Explorer for all users via Registry settings."""
|
"""Configure Windows Explorer for all users."""
|
||||||
write_registry_settings(SETTINGS_EXPLORER_SYSTEM, all_users=True)
|
write_registry_settings(SETTINGS_EXPLORER_SYSTEM, all_users=True)
|
||||||
|
|
||||||
def config_explorer_user():
|
def config_explorer_user():
|
||||||
"""Configure Windows Explorer for current user via Registry settings."""
|
"""Configure Windows Explorer for current user."""
|
||||||
write_registry_settings(SETTINGS_EXPLORER_USER, all_users=False)
|
write_registry_settings(SETTINGS_EXPLORER_USER, all_users=False)
|
||||||
|
|
||||||
def disable_windows_telemetry():
|
def disable_windows_telemetry():
|
||||||
|
|
@ -241,7 +241,7 @@ def install_adobe_reader():
|
||||||
run_program(cmd)
|
run_program(cmd)
|
||||||
|
|
||||||
def install_chrome_extensions():
|
def install_chrome_extensions():
|
||||||
"""Update registry to install Google Chrome extensions for all users."""
|
"""Install Google Chrome extensions for all users."""
|
||||||
write_registry_settings(SETTINGS_GOOGLE_CHROME, all_users=True)
|
write_registry_settings(SETTINGS_GOOGLE_CHROME, all_users=True)
|
||||||
|
|
||||||
def install_classicstart_skin():
|
def install_classicstart_skin():
|
||||||
|
|
@ -258,7 +258,7 @@ def install_classicstart_skin():
|
||||||
shutil.copy(source, dest)
|
shutil.copy(source, dest)
|
||||||
|
|
||||||
def install_firefox_extensions():
|
def install_firefox_extensions():
|
||||||
"""Update registry to install Firefox extensions for all users."""
|
"""Install Firefox extensions for all users."""
|
||||||
dist_path = r'{PROGRAMFILES}\Mozilla Firefox\distribution\extensions'.format(
|
dist_path = r'{PROGRAMFILES}\Mozilla Firefox\distribution\extensions'.format(
|
||||||
**global_vars['Env'])
|
**global_vars['Env'])
|
||||||
source_path = r'{CBinDir}\FirefoxExtensions.7z'.format(**global_vars)
|
source_path = r'{CBinDir}\FirefoxExtensions.7z'.format(**global_vars)
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ def format_mbr(disk):
|
||||||
run_diskpart(script)
|
run_diskpart(script)
|
||||||
|
|
||||||
def mount_windows_share():
|
def mount_windows_share():
|
||||||
"""Mount the Windows images share unless labeled as already mounted."""
|
"""Mount the Windows images share unless already mounted."""
|
||||||
if not WINDOWS_SERVER['Mounted']:
|
if not WINDOWS_SERVER['Mounted']:
|
||||||
# Mounting read-write in case a backup was done in the same session
|
# Mounting read-write in case a backup was done in the same session
|
||||||
# and the server was left mounted read-write. This avoids throwing an
|
# and the server was left mounted read-write. This avoids throwing an
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,7 @@ def menu_root():
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
def menu_setup():
|
def menu_setup():
|
||||||
"""Format a disk (MBR/GPT), apply a Windows image, and setup boot files."""
|
"""Format a disk, apply a Windows image, and create boot files."""
|
||||||
errors = False
|
errors = False
|
||||||
other_results = {
|
other_results = {
|
||||||
'Error': {
|
'Error': {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue