More misc cleanup
This commit is contained in:
parent
11cf75d4a6
commit
b47c214133
4 changed files with 7 additions and 8 deletions
|
|
@ -4,10 +4,9 @@ import subprocess
|
||||||
|
|
||||||
from borrowed import acpi
|
from borrowed import acpi
|
||||||
from functions.common import *
|
from functions.common import *
|
||||||
from os import environ
|
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
SLMGR = r'{}\System32\slmgr.vbs'.format(environ.get('SYSTEMROOT'))
|
SLMGR = r'{}\System32\slmgr.vbs'.format(global_vars['Env']['SYSTEMROOT'])
|
||||||
|
|
||||||
def activate_with_bios():
|
def activate_with_bios():
|
||||||
"""Attempt to activate Windows with a key stored in the BIOS."""
|
"""Attempt to activate Windows with a key stored in the BIOS."""
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ class NotInstalledError(Exception):
|
||||||
class NoProfilesError(Exception):
|
class NoProfilesError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class PathNotFoundException(Exception):
|
class PathNotFoundError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class UnsupportedOSError(Exception):
|
class UnsupportedOSError(Exception):
|
||||||
|
|
@ -174,7 +174,7 @@ def human_readable_size(size, decimals=0):
|
||||||
size = convert_to_bytes(size)
|
size = convert_to_bytes(size)
|
||||||
|
|
||||||
# Verify we have a valid size
|
# Verify we have a valid size
|
||||||
if size <= 0:
|
if size < 0:
|
||||||
return '{size:>{width}} b'.format(size='???', width=width)
|
return '{size:>{width}} b'.format(size='???', width=width)
|
||||||
|
|
||||||
# Convert to sensible units
|
# Convert to sensible units
|
||||||
|
|
@ -432,7 +432,7 @@ def try_and_print(message='Trying...',
|
||||||
err = traceback.format_exc()
|
err = traceback.format_exc()
|
||||||
|
|
||||||
# Return or raise?
|
# Return or raise?
|
||||||
if bool(err) and not catch_all:
|
if err and not catch_all:
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
return {'CS': not bool(err), 'Error': err}
|
return {'CS': not bool(err), 'Error': err}
|
||||||
|
|
|
||||||
|
|
@ -374,7 +374,7 @@ def scan_source_wim(source_wim, dest_path, rel_path=None, interactive=True):
|
||||||
|
|
||||||
def select_destination(folder_path, prompt='Select destination'):
|
def select_destination(folder_path, prompt='Select destination'):
|
||||||
"""Select destination drive, returns path as string."""
|
"""Select destination drive, returns path as string."""
|
||||||
disk = select_disk(prompt)
|
disk = select_volume(prompt)
|
||||||
if 'fixed' not in disk['Disk'].opts:
|
if 'fixed' not in disk['Disk'].opts:
|
||||||
folder_path = folder_path.replace('\\', '-')
|
folder_path = folder_path.replace('\\', '-')
|
||||||
path = '{disk}{folder_path}_{Date}'.format(
|
path = '{disk}{folder_path}_{Date}'.format(
|
||||||
|
|
@ -388,7 +388,7 @@ def select_destination(folder_path, prompt='Select destination'):
|
||||||
|
|
||||||
return path
|
return path
|
||||||
|
|
||||||
def select_disk(title='Select disk', auto_select=True):
|
def select_volume(title='Select disk', auto_select=True):
|
||||||
"""Select disk from attached disks. returns dict."""
|
"""Select disk from attached disks. returns dict."""
|
||||||
actions = [{'Name': 'Quit', 'Letter': 'Q'}]
|
actions = [{'Name': 'Quit', 'Letter': 'Q'}]
|
||||||
disks = []
|
disks = []
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ def get_shell_path(folder, user='current'):
|
||||||
if folderid:
|
if folderid:
|
||||||
try:
|
try:
|
||||||
path = knownpaths.get_path(folderid, getattr(knownpaths.UserHandle, user))
|
path = knownpaths.get_path(folderid, getattr(knownpaths.UserHandle, user))
|
||||||
except PathNotFoundException:
|
except PathNotFoundError:
|
||||||
# Folder not found, ignore and return None
|
# Folder not found, ignore and return None
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue